summaryrefslogtreecommitdiff
path: root/src/GF/GFCC/Raw/ErrM.hs
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2007-12-13 22:15:19 +0000
committeraarne <aarne@cs.chalmers.se>2007-12-13 22:15:19 +0000
commit9e0dd0a41a9d386d4cc9ae6bab6fa2e1862e829f (patch)
tree80b8db48188b041e128c45f077157474b5223680 /src/GF/GFCC/Raw/ErrM.hs
parented5a85ce1d48e8a8c4c151c19b5dc3adf55ce4cb (diff)
some generated GFCCRaw files added to darcs; make gf3langs for alltenses
Diffstat (limited to 'src/GF/GFCC/Raw/ErrM.hs')
-rw-r--r--src/GF/GFCC/Raw/ErrM.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/GF/GFCC/Raw/ErrM.hs b/src/GF/GFCC/Raw/ErrM.hs
new file mode 100644
index 000000000..ce9401669
--- /dev/null
+++ b/src/GF/GFCC/Raw/ErrM.hs
@@ -0,0 +1,26 @@
+-- BNF Converter: Error Monad
+-- Copyright (C) 2004 Author: Aarne Ranta
+
+-- This file comes with NO WARRANTY and may be used FOR ANY PURPOSE.
+module GF.GFCC.Raw.ErrM where
+
+-- the Error monad: like Maybe type with error msgs
+
+import Control.Monad (MonadPlus(..), liftM)
+
+data Err a = Ok a | Bad String
+ deriving (Read, Show, Eq, Ord)
+
+instance Monad Err where
+ return = Ok
+ fail = Bad
+ Ok a >>= f = f a
+ Bad s >>= f = Bad s
+
+instance Functor Err where
+ fmap = liftM
+
+instance MonadPlus Err where
+ mzero = Bad "Err.mzero"
+ mplus (Bad _) y = y
+ mplus x _ = x