Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
LH HandlerT Refinement
## HandlerT refinements
```
module spec Yesod.Core.Types where
data HandlerT site m a <p :: User -> Bool> = Yesod.Core.Types.HandlerT {
unHandlerT :: Yesod.Core.Types.HandlerData site (Yesod.Core.Types.MonadRoute m) -> m a
}
data variance HandlerT covariant covariant covariant contravariant
measure content :: HandlerT site m a -> a
instance Monad HandlerT where
>>= :: forall <p :: User -> Bool, f:: a -> b -> Bool>.
x:HandlerT <p> site m a
-> (u:a -> HandlerT <p> site m (b <f u>))
-> HandlerT <p> site m (b<f (content x)>);
>> :: x:HandlerT site m a
-> HandlerT site m b
-> HandlerT site m b;
return :: forall <p :: User -> Bool>. a -> HandlerT <p> site m a
```
## liftM implementation
{-@ liftM :: forall a b <p :: User -> Bool, f:: a -> b -> Bool>.
(u:a -> b<f u>)
-> x: HandlerT <p> App IO a
-> HandlerT <p> App IO (b<f (content x)>)
@-}
liftM :: (a -> b) -> Handler a -> Handler b
liftM f x = x >>= \x' -> return (f x')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment