]> Git — Sourcephile - haskell/symantic.git/blob - symantic/Language/Symantic/Interpreting/Eval.hs
Add Doc_Align and Doc_Wrap.
[haskell/symantic.git] / symantic / Language / Symantic / Interpreting / Eval.hs
1 -- | Interpreter to evaluate a term as a host-term.
2 module Language.Symantic.Interpreting.Eval where
3
4 import Control.Monad
5
6 -- * Type 'Eval'
7
8 -- | Interpreter's data.
9 newtype Eval a = Eval { unEval :: a }
10 instance Functor Eval where
11 fmap f (Eval a) = Eval (f a)
12 instance Applicative Eval where
13 pure = Eval
14 (Eval f) <*> (Eval a) = Eval (f a)
15 instance Monad Eval where
16 return = Eval
17 (Eval a) >>= f = f a
18
19 -- | Interpreter.
20 eval :: Eval a -> a
21 eval = unEval
22
23 -- ** Constructors
24 eval0 :: a -> Eval a
25 eval0 = Eval
26
27 eval1 :: (a -> b) -> Eval a -> Eval b
28 eval1 = liftM
29
30 eval2 :: (a -> b -> c) -> Eval a -> Eval b -> Eval c
31 eval2 = liftM2
32
33 eval3 :: (a -> b -> c -> d) -> Eval a -> Eval b -> Eval c -> Eval d
34 eval3 = liftM3