Created
April 25, 2011 22:00
-
-
Save purefn/941344 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._ | |
import Scalaz._ | |
import effects._ | |
trait Request | |
trait Response | |
case class WebState(_request: Request, _response: Response) | |
sealed trait Web[A] extends NewType[Web.T[A]] | |
object Web { | |
type I[A] = IterVM[IO, String, A] | |
type T[A] = StateT[I, WebState, Option[Validation[Response, A]]] | |
def apply[A](a: T[A]): Web[A] = new Web[A] { | |
val value = a | |
} | |
implicit def IterVMPure[M[_]: Pure, E] = new Pure[({ type λ[α] = IterVM[M, E, α] })#λ] { | |
import IterV._ | |
def pure[A](a: ⇒ A): IterVM[M, E, A] = DoneM(a, Empty[E]) | |
} | |
implicit def pureWeb: Pure[Web] = new Pure[Web] { | |
def pure[A](a: ⇒ A): Web[A] = { | |
val b = some(a.success[Response]) | |
val c = b.pure[I] | |
Web(c.pure[T]) // <-- fails to compile with "could not find implicit value for parameter p: scalaz.Pure[Web.T] even though there is a Pure[StateT] available | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment