summaryrefslogtreecommitdiff
path: root/paper/While/Common.dcl
diff options
context:
space:
mode:
authorCamil Staps2016-05-10 21:12:44 +0200
committerCamil Staps2016-05-10 21:12:44 +0200
commitd2b12fdf5681a71f1f6a295b0591e4d8213fb41d (patch)
treec242637b4491ce3d1a44b6f8b51f398f20fc0daf /paper/While/Common.dcl
parentMakefile: bibtex may fail (diff)
Straightforward While lexer, parser and interpreter
Diffstat (limited to 'paper/While/Common.dcl')
-rw-r--r--paper/While/Common.dcl47
1 files changed, 47 insertions, 0 deletions
diff --git a/paper/While/Common.dcl b/paper/While/Common.dcl
new file mode 100644
index 0000000..6945c08
--- /dev/null
+++ b/paper/While/Common.dcl
@@ -0,0 +1,47 @@
+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