Skip to content

Instantly share code, notes, and snippets.

@amazari
Created February 25, 2015 16:29
Show Gist options
  • Save amazari/5e99ddbb8f6aa81df2bd to your computer and use it in GitHub Desktop.
Save amazari/5e99ddbb8f6aa81df2bd to your computer and use it in GitHub Desktop.
// Would love to use the following, sadly TypedPipe is not really monadic:
// * a bind/flatMap operator is missing:
// Indeed flatMap currently has the following signature:
// def flatMap[U](f: (T) ⇒ TraversableOnce[U]): TypedPipe[U]
// whereas a monadic bind would look like this
// def flatMap[U](f: (T) ⇒ TypedPipe[U]): TypedPipe[U]
// * return/unit can be implemented in such way:
// return[A]: A => TypedPipe[A] = a => TypedPipe.from(List(a))
for {
user <- usersPipe
birthdate <- birthDatesPipe if ( birthDate.userId == user.id )
present <- presentsPipe if ( present.userId == user.uid )
} yield ((sale, birthDate, present))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment