]> ruin.nu Git - proglang.git/blob - ErrM.hs
minor change
[proglang.git] / ErrM.hs
1 -- BNF Converter: Error Monad
2 -- Copyright (C) 2004  Author:  Aarne Ranta
3
4 -- This file comes with NO WARRANTY and may be used FOR ANY PURPOSE.
5 module ErrM where
6
7 -- the Error monad: like Maybe type with error msgs
8
9 data Err a = Ok a | Bad String
10   deriving (Read, Show, Eq)
11
12 instance Monad Err where
13   return      = Ok
14   fail        = Bad
15   Ok a  >>= f = f a
16   Bad s >>= f = Bad s