diff options
author | Austin Seipp <austin@well-typed.com> | 2014-01-13 17:57:47 -0600 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2014-01-14 03:46:07 -0600 |
commit | dfc32cd54e1b6d624ebb9d26772ce787aac3421d (patch) | |
tree | c32e18f27e0b7ac5624b074258817581d83167aa /utils | |
parent | b9b94ec82d9125da47c619c69e626120b3e60457 (diff) | |
download | haskell-dfc32cd54e1b6d624ebb9d26772ce787aac3421d.tar.gz |
genprimopcode: Applicative instance for ParserM
Signed-off-by: Austin Seipp <austin@well-typed.com>
Diffstat (limited to 'utils')
-rw-r--r-- | utils/genprimopcode/ParserM.hs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/utils/genprimopcode/ParserM.hs b/utils/genprimopcode/ParserM.hs index aaaf6ac66f..0a69db6b8f 100644 --- a/utils/genprimopcode/ParserM.hs +++ b/utils/genprimopcode/ParserM.hs @@ -16,13 +16,21 @@ module ParserM ( -- Other happyError ) where - +import Control.Applicative +import Control.Monad (ap, liftM) import Data.Word (Word8) import Data.Char (ord) -- Parser Monad 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 ParserM m >>= k = ParserM $ \i s -> case m i s of Right (i', s', x) -> |