Copyright | (c) Mats Rauhala 2020 |
---|---|
License | BSD-3 |
Maintainer | mats.rauhala@iki.fi |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe |
Language | Haskell2010 |
Let's assume we have a parser like the following
int :: Parser (ReaderT String Maybe) (Writer [Int]) Int Int int = parser (ReaderT readMaybe) (x -> x <$ tell [show x])
Then you can use the parser for parsing:
> runReaderT (decode int) "3" Just 3
Or for encoding:
> execWriter (encode int 3) ["3"]
Or combine both of them
> runReaderT (decode int) $ head $ execWriter $ encode int 3 Just 3
Documentation
The core bidirectional parser type
See the module for usage example
Instances
(Functor r, Functor w) => Profunctor (IParser r w) Source # | |
Defined in Data.IParser dimap :: (a -> b) -> (c -> d) -> IParser r w b c -> IParser r w a d # lmap :: (a -> b) -> IParser r w b c -> IParser r w a c # rmap :: (b -> c) -> IParser r w a b -> IParser r w a c # (#.) :: Coercible c b => q b c -> IParser r w a b -> IParser r w a c # (.#) :: Coercible b a => IParser r w b c -> q a b -> IParser r w a c # | |
(Functor w, Functor r) => Functor (IParser r w c) Source # | |
(Applicative w, Applicative r) => Applicative (IParser r w c) Source # | |
Defined in Data.IParser pure :: a -> IParser r w c a # (<*>) :: IParser r w c (a -> b) -> IParser r w c a -> IParser r w c b # liftA2 :: (a -> b -> c0) -> IParser r w c a -> IParser r w c b -> IParser r w c c0 # (*>) :: IParser r w c a -> IParser r w c b -> IParser r w c b # (<*) :: IParser r w c a -> IParser r w c b -> IParser r w c a # |
:: r a | The parser |
-> (c -> w a) | The encoder |
-> IParser r w c a |
Smart constructor for the parser