Created
March 20, 2017 04:26
-
-
Save jbrown215/73354511fb7722de33671eb8b7371353 to your computer and use it in GitHub Desktop.
LH HandlerT Refinement
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
## 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