Created
August 19, 2014 23:48
-
-
Save jroesch/5c470f299cfabf9746b5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| data UnAuthErr = MkErr deriving (Eq, Show) | |
| data Req = MkReq deriving (Eq, Show) | |
| data Credentials = MkCredentials deriving (Eq, Show) | |
| data Auth a = Error a | |
| | Request Req a | |
| | Auth Credentials a | |
| deriving (Eq, Show) | |
| instance Functor Auth where | |
| fmap f (Error a) = Error (f a) | |
| fmap f (Request Req a) = Req Req (f a) | |
| fmap f (Auth creds a) = Auth Creds (f a) | |
| onlyIfAuth :: Free Auth (Either UnAuthErr a) -> | |
| onlyIfAuth = iterM $ \auth -> | |
| -- interpret here | |
| tryMe = onlyIfAuth someFreeTerm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment