Quantcast

Re: Downsides of the Prompt Monad

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Downsides of the Prompt Monad

oleg-30

David Menendez wrote
> It's worth noting that Prompt p is the free monad for a type constructor p,
> just as Free f is the free monad for a Functor f. As such, when p is a
> Functor, they are isomorphic.

> data Free f a = Var a | Wrap (f (Free f a))
> newtype Prompt p a =
>   Prompt { unPrompt :: forall b. (forall i. p i -> (i -> b) -> b) -> (a -> b) -> b }
> -- equivalently, Prompt p a = Done a | forall i. Prompt (p i) (i -> Prompt
> p a)

Indeed. The Freer monad paper, Sec 2.4, describes this correspondence
in general:
        type FFree p = Free (Lan p)
(FFree p is the alternative Prompt p in David's message)

where Lan p is a (simple version) of the left Kan extension that turns
any p :: * -> * into a functor. Once (Lan p) is a Functor, the
standard free monad construction applies.

The Freer monad paper then goes on to say that since the continuation
is made explicit, it can be represented in a better way than just a
function.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Loading...