diff options
author | Austin Seipp <austin@well-typed.com> | 2013-09-11 18:46:54 -0500 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2013-09-11 18:47:15 -0500 |
commit | b20cf4ecbf244f091f4084c11ae2350d248ce6ef (patch) | |
tree | d595c6c632773bb4110468c23467f0b339096538 /compiler/main/CmdLineParser.hs | |
parent | 1ef941a82eafb8f22c19e2643685679d2454c24a (diff) | |
download | haskell-b20cf4ecbf244f091f4084c11ae2350d248ce6ef.tar.gz |
Fix AMP warnings.
Authored-by: David Luposchainsky <dluposchainsky@gmail.com>
Signed-off-by: Austin Seipp <austin@well-typed.com>
Diffstat (limited to 'compiler/main/CmdLineParser.hs')
-rw-r--r-- | compiler/main/CmdLineParser.hs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/compiler/main/CmdLineParser.hs b/compiler/main/CmdLineParser.hs index 252a376432..6681186246 100644 --- a/compiler/main/CmdLineParser.hs +++ b/compiler/main/CmdLineParser.hs @@ -30,6 +30,9 @@ import SrcLoc import Data.Function import Data.List +import Control.Monad (liftM, ap) +import Control.Applicative (Applicative(..)) + -------------------------------------------------------- -- The Flag and OptKind types @@ -72,6 +75,13 @@ newtype EwM m a = EwM { unEwM :: Located String -- Current parse arg -> Errs -> Warns -> m (Errs, Warns, a) } +instance Monad m => Functor (EwM m) where + fmap = liftM + +instance Monad m => Applicative (EwM m) where + pure = return + (<*>) = ap + instance Monad m => Monad (EwM m) where (EwM f) >>= k = EwM (\l e w -> do (e', w', r) <- f l e w unEwM (k r) l e' w') @@ -108,6 +118,13 @@ liftEwM action = EwM (\_ es ws -> do { r <- action; return (es, ws, r) }) -- (CmdLineP s) typically instantiates the 'm' in (EwM m) and (OptKind m) newtype CmdLineP s a = CmdLineP { runCmdLine :: s -> (a, s) } +instance Functor (CmdLineP s) where + fmap = liftM + +instance Applicative (CmdLineP s) where + pure = return + (<*>) = ap + instance Monad (CmdLineP s) where m >>= k = CmdLineP $ \s -> let (a, s') = runCmdLine m s |