definition module Common from StdString import class toString class Functor f where (<$>) infixl 4 :: (a -> b) (f a) -> f b class Applicative f | Functor f where pure :: a -> f a (<*>) infixl 4 :: (f (a -> b)) (f a) -> f b class Alternative f | Applicative f where empty :: f a (<|>) infixl 3 :: (f a) (f a) -> f a class Monad m | Applicative m where (>>=) infixl 1 :: (m a) (a -> m b) -> m b :: Either l r = Left l | Right r instance Functor (Either e) instance Applicative (Either e) instance Monad (Either e) :: Error = Lextime String | Parsetime String | Runtime String | GenericError String instance toString Error (<+) infixr 5 :: a b -> String | toString a & toString b ($) infixr 0 :: (a -> b) a -> b (*>) infixl 4 :: (f a) (f b) -> f b | Applicative f (<*) infixl 4 :: (f a) (f b) -> f a | Applicative f some :: (f a) -> f [a] | Alternative f many :: (f a) -> f [a] | Alternative f sequence :: [a b] -> a [b] | Monad a mapM :: (a -> b c) [a] -> b [c] | Monad b foldM :: (a -> (b -> c a)) a [b] -> c a | Monad c liftM :: (a -> b) (c a) -> c b | Monad c liftM2 :: (a -> (b -> c)) (d a) (d b) -> d c | Monad d liftM3 :: (a -> (b -> (c -> d))) (e a) (e b) (e c) -> e d | Monad e