summaryrefslogtreecommitdiff
path: root/utils/genprimopcode
diff options
context:
space:
mode:
authorAustin Seipp <austin@well-typed.com>2014-01-13 17:57:47 -0600
committerAustin Seipp <austin@well-typed.com>2014-01-14 03:46:07 -0600
commitdfc32cd54e1b6d624ebb9d26772ce787aac3421d (patch)
treec32e18f27e0b7ac5624b074258817581d83167aa /utils/genprimopcode
parentb9b94ec82d9125da47c619c69e626120b3e60457 (diff)
downloadhaskell-dfc32cd54e1b6d624ebb9d26772ce787aac3421d.tar.gz
genprimopcode: Applicative instance for ParserM
Signed-off-by: Austin Seipp <austin@well-typed.com>
Diffstat (limited to 'utils/genprimopcode')
-rw-r--r--utils/genprimopcode/ParserM.hs10
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) ->