[commit: ghc] master: genprimopcode: Applicative instance for ParserM (dfc32cd5)
git at git.haskell.org
git at git.haskell.org
Tue Jan 14 09:46:55 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/dfc32cd54e1b6d624ebb9d26772ce787aac3421d/ghc
>---------------------------------------------------------------
commit dfc32cd54e1b6d624ebb9d26772ce787aac3421d
Author: Austin Seipp <austin at well-typed.com>
Date: Mon Jan 13 17:57:47 2014 -0600
genprimopcode: Applicative instance for ParserM
Signed-off-by: Austin Seipp <austin at well-typed.com>
>---------------------------------------------------------------
dfc32cd54e1b6d624ebb9d26772ce787aac3421d
utils/genprimopcode/ParserM.hs | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/utils/genprimopcode/ParserM.hs b/utils/genprimopcode/ParserM.hs
index aaaf6ac..0a69db6 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) ->
More information about the ghc-commits
mailing list