Last active
December 10, 2015 15:18
-
-
Save k0001/4453650 to your computer and use it in GitHub Desktop.
Control.Proxy.Trans.Parse
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
{ # LANGUAGE GeneralizedNewtypeDeriving #-} | |
module Control.Proxy.Trans.Parse ( | |
-- * ParseP | |
ParseP(..), | |
runParseP, | |
runParseK | |
) where | |
import Control.Applicative (Applicative) | |
import Control.Monad (MonadPlus) | |
import Control.Monad.Trans.Class (MonadTrans) | |
import Control.Monad.IO.Class (MonadIO) | |
import Control.Proxy.Class (Proxy, MonadPlusP, MonadIOP) | |
import Control.Proxy.Trans (ProxyTrans(..)) | |
import Control.Proxy.Trans.Either (EitherP, runEitherP) | |
import Control.Proxy.Trans.State (StateP, runStateP) | |
newtype ParseP e s p a' a b' b m r = | |
ParseP { unParseP :: EitherP e (StateP s p) a' a b' b m r } | |
deriving | |
( Functor | |
, Applicative | |
, Monad | |
, MonadTrans | |
, MonadPlus | |
, MonadIO | |
, Proxy | |
, MonadPlusP | |
, MonadIOP | |
) | |
instance ProxyTrans (ParseP e s) where | |
liftP = ParseP . liftP . liftP | |
runParseK :: s | |
-> (q -> ParseP e s p a' a b' b m r) | |
-> (q -> p a' a b' b m (Either e r, s)) | |
runParseK s k q = runParseP s $ k q | |
runParseP :: s | |
-> ParseP e s p a' a b' b m r | |
-> p a' a b' b m (Either e r, s) | |
unParseP s = runStateP s . runEitherP . unParseP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment