Commit dfc32cd5 authored by Austin Seipp's avatar Austin Seipp
Browse files

genprimopcode: Applicative instance for ParserM


Signed-off-by: default avatarAustin Seipp <austin@well-typed.com>
parent b9b94ec8
...@@ -16,13 +16,21 @@ module ParserM ( ...@@ -16,13 +16,21 @@ module ParserM (
-- Other -- Other
happyError happyError
) where ) where
import Control.Applicative
import Control.Monad (ap, liftM)
import Data.Word (Word8) import Data.Word (Word8)
import Data.Char (ord) import Data.Char (ord)
-- Parser Monad -- Parser Monad
newtype ParserM a = ParserM (AlexInput -> St -> Either String (AlexInput, St, a)) newtype ParserM a = ParserM (AlexInput -> St -> Either String (AlexInput, St, a))
instance Functor ParserM where
fmap = liftM
instance Applicative ParserM where
pure = return
(<*>) = ap
instance Monad ParserM where instance Monad ParserM where
ParserM m >>= k = ParserM $ \i s -> case m i s of ParserM m >>= k = ParserM $ \i s -> case m i s of
Right (i', s', x) -> Right (i', s', x) ->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment