Skip to content

Instantly share code, notes, and snippets.

@stephen-lazaro
Last active November 9, 2018 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephen-lazaro/f52816592ad4ab529715f63a150f71c4 to your computer and use it in GitHub Desktop.
Save stephen-lazaro/f52816592ad4ab529715f63a150f71c4 to your computer and use it in GitHub Desktop.
// Aka an Applicative, though we won't talk about the connection here.
trait Monoidal[F[_]] {
  // Named this way for Historical Reasons™
  def pure[A](x: A): F[A] 
  def map[A, B](fa: F[A])(f: A => B): F[B]
  def product[A, B](fa: F[A], fb: F[B]): F[(A, B)]
}
object Monoidal {
  // Some convenient boilerplate to "summon" our semigroupal
// again, ignore this if it doesn't make sense, allows Semigroupal[RowDecoder].map to work
  def apply[F[_]](implicit semi: Monoidal[F]): Monoidal[F] = semi
}
// Specialized to RowDecoder!
implicit val monoidalForRowDecoder = new Monoidal[RowDecoder] {
 def pure[A](x: A): RowDecoder[A] = ???
 def map[A, B](fa: RowDecoder[A])(f: A => B): RowDecoder[B] = ???
 def product[A, B](fa: RowDecoder[A], fb: RowDecoder[B]): RowDecoder[(A, B)] = ???
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment