mirror of
https://github.com/github/semantic.git
synced 2024-12-11 08:45:48 +03:00
📝 Env stuff.
This commit is contained in:
parent
b118bb5b38
commit
89f7101e27
@ -69,12 +69,15 @@ letBind diff f = embed (Let (Env [(n, diff)]) body)
|
|||||||
n = maybe (Metavar 0) succ (foldMaxMap maxBoundMetavariable body)
|
n = maybe (Metavar 0) succ (foldMaxMap maxBoundMetavariable body)
|
||||||
|
|
||||||
|
|
||||||
|
-- | An environment, binding 'Metavar'iables to values.
|
||||||
newtype Env a = Env { unEnv :: [(Metavar, a)] }
|
newtype Env a = Env { unEnv :: [(Metavar, a)] }
|
||||||
deriving (Eq, Foldable, Functor, Monoid, Ord, Semigroup, Show, Traversable)
|
deriving (Eq, Foldable, Functor, Monoid, Ord, Semigroup, Show, Traversable)
|
||||||
|
|
||||||
|
-- | Extend an 'Env' by binding a 'Metavar'iable to a value.
|
||||||
envExtend :: Metavar -> a -> Env a -> Env a
|
envExtend :: Metavar -> a -> Env a -> Env a
|
||||||
envExtend var val (Env m) = Env ((var, val) : m)
|
envExtend var val (Env m) = Env ((var, val) : m)
|
||||||
|
|
||||||
|
-- | Lookup the given 'Metavar'iable in an 'Env'.
|
||||||
envLookup :: Metavar -> Env a -> Maybe a
|
envLookup :: Metavar -> Env a -> Maybe a
|
||||||
envLookup var = lookup var . unEnv
|
envLookup var = lookup var . unEnv
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user