summaryrefslogtreecommitdiff
path: root/paper/While/Common.dcl
blob: c2d58d449e58995e336680e711ae54b09285e62c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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
(on) infix 0 :: (b -> c) (a a -> b) -> (a a -> c)

(*>) 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