From dfc32cd54e1b6d624ebb9d26772ce787aac3421d Mon Sep 17 00:00:00 2001 From: Austin Seipp Date: Mon, 13 Jan 2014 17:57:47 -0600 Subject: genprimopcode: Applicative instance for ParserM Signed-off-by: Austin Seipp --- utils/genprimopcode/ParserM.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'utils/genprimopcode') 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) -> -- cgit v1.2.1