1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 07:55:12 +03:00

Define an Effect instance for Env.

This commit is contained in:
Rob Rix 2019-11-01 14:30:32 -04:00
parent 77fc730fe1
commit 9c5289f54b
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -40,6 +40,12 @@ instance HFunctor (Env name addr) where
Bind name addr m k -> Bind name addr (f m) (f . k)
Lookup name k -> Lookup name (f . k)
instance Effect (Env name addr) where
handle ctx hdl = \case
Alloc name k -> Alloc name (hdl . (<$ ctx) . k)
Bind name addr m k -> Bind name addr (hdl (m <$ ctx)) (hdl . fmap k)
Lookup name k -> Lookup name (hdl . (<$ ctx) . k)
data Heap addr value m k
= Deref addr (Maybe value -> m k)