]> Git — Sourcephile - haskell/symantic.git/blob - symantic/Language/Symantic/Interpreting/Host.hs
Try the new Type and Term design against the actual needs.
[haskell/symantic.git] / symantic / Language / Symantic / Interpreting / Host.hs
1 -- | Interpreter to compute a host-term.
2 module Language.Symantic.Interpreting.Host where
3
4 import Control.Monad
5
6 -- * Type 'HostI'
7
8 -- | Interpreter's data.
9 newtype HostI h = HostI { unHostI :: h }
10 instance Functor HostI where
11 fmap f (HostI a) = HostI (f a)
12 instance Applicative HostI where
13 pure = HostI
14 (HostI f) <*> (HostI a) = HostI (f a)
15 instance Monad HostI where
16 return = HostI
17 (HostI a) >>= f = f a
18
19 -- | Interpreter.
20 host_from_term :: HostI h -> h
21 host_from_term = unHostI
22
23 hostI0 :: a -> HostI a
24 hostI0 = HostI
25
26 hostI1 :: (a -> b) -> HostI a -> HostI b
27 hostI1 = liftM
28
29 hostI2 :: (a -> b -> c) -> HostI a -> HostI b -> HostI c
30 hostI2 = liftM2
31
32 hostI3 :: (a -> b -> c -> d) -> HostI a -> HostI b -> HostI c -> HostI d
33 hostI3 = liftM3