scala - What methods are needed to create custom Applicative Functor to use with scalaz |@| -


i able use scalaz's |@| on own applicative functor.

example:
val spread: source[yield] = (y2 |@| y1)(_ - _)

this class

sealed abstract class source[+a] {   def map[b](f: => b): source[b]    def unit[a](a: a): source[a]   def purelist[a](la: list[a]): source[a]   def zero[a]: source[a]   def map2[a, b, c](as: source[a], bs: source[b], f: (a, b) => c): source[c] } 

i'm have implement map because it's functor.
applicative can implemented in various ways: example using apply() , unit() or map2() , unit().

do need ap , pure well?

as can see i'm not sure needed.

implicit val mya = new applicative[source] {} 

let compiler answer question you:

object creation impossible, since: has 2 unimplemented members. /** seen <$anon: scalaz.applicative[source]>, missing signatures follows.  *  convenience, these usable stub implementations.  */   // members declared in scalaz.applicative   def point[a](a: => a): source[a] = ???    // members declared in scalaz.apply   def ap[a, b](fa: => source[a])(f: => source[a => b]): source[b] = ??? 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -