[Ur] Bug Report
Adam Chlipala
adamc at impredicative.com
Sat Dec 17 20:39:08 EST 2011
James Parker wrote:
> I'm still trying to wrap my head around the concepts of monads and was wondering if you could help me with one more thing. In my getUser function, I am trying to return an option record of a user's name, email, id, etc if they're logged in. Unfortunately I'm having trouble understanding what the compiler is looking for. I think it may have something to do with escaping the transaction monad? The code is available here:
>
> https://github.com/jprider63/UMDTalks/blob/master/umdtalks.ur
>
If you just look at the types of [return] and [bind] (where the [x <-
... ; ...] notation desugars into calls to the latter), it should be
clear exactly what "the rules" are. If you don't understand the types,
then we can try to help you learn the appropriate features of the Ur
type system!
The short, program-specific answer is that you need to push the final
[return] through to the "leaves" of the function, but it really will be
more helpful to understand the types of [return] and [bind] well enough
to derive that answer from first principles. Online resources about
monads in Haskell should be useful here.
More information about the Ur
mailing list