Last active
December 21, 2015 04:09
-
-
Save jedws/6247542 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalaz.{ Free, Functor, Monad, Scalaz, \/, syntax } | |
import Free._ | |
import Scalaz.Id | |
import syntax.id._ | |
import syntax.monad._ | |
package times { | |
case class Times[+A](times: Vector[(Long, String)], a: A) | |
object Times { | |
implicit object TimesMonad extends Monad[Times] { | |
override def point[A](a: => A): Times[A] = | |
Times(Vector(), a) | |
override def bind[A, B](fa: Times[A])(f: A => Times[B]) = | |
f(fa.a) |> { fb => Times(fa.times ++ fb.times, fb.a) } | |
override def map[A, B](fa: Times[A])(f: A => B): Times[B] = | |
Times(fa.times, f(fa.a)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment