|
Play Framework/Scala example source code file (Applicative.scala)
The Applicative.scala Play Framework example source code/* * Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com> */ package play.api.libs.functional import scala.language.higherKinds trait Applicative[M[_]] { def pure[A](a: A): M[A] def map[A, B](m: M[A], f: A => B): M[B] def apply[A, B](mf: M[A => B], ma: M[A]): M[B] } class ApplicativeOps[M[_], A](ma: M[A])(implicit a: Applicative[M]) { def ~>[B](mb: M[B]): M[B] = a(a(a.pure((_: A) => (b: B) => b), ma), mb) def andKeep[B](mb: M[B]): M[B] = ~>(mb) def <~[B](mb: M[B]): M[A] = a(a(a.pure((a: A) => (_: B) => a), ma), mb) def keepAnd[B](mb: M[B]): M[A] = <~(mb) def <~>[B, C](mb: M[B])(implicit witness: <:<[A, B => C]): M[C] = apply(mb) def apply[B, C](mb: M[B])(implicit witness: <:<[A, B => C]): M[C] = a(a.map(ma, witness), mb) } Other Play Framework source code examplesHere is a short list of links related to this Play Framework Applicative.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.