aboutsummaryrefslogtreecommitdiff
path: root/src/context.hs
blob: c5abfe0a8b38c8cb43bde3e7abd557396a84fd05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Context where

import Data.List
import Control.Alternative

type Label = String
data State a = State [a]
data Context a = Context [Decl] a

instance Functor Context where
    fmap f (Context state x) = Context (f x) state

getLabel :: Declaration a => State a -> Label -> Maybe a
getLabel (State decls) l = find (label . (l ==)) decls

class Declaration a where
    label :: a -> Label
    -- value for variable
    -- partial expression where the only variable left is the argument
    resolve :: a -> State -> b