1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00

Define an HFunctor instance for Env.

This commit is contained in:
Rob Rix 2019-11-01 13:18:57 -04:00
parent 78626539c5
commit 39a2df683d
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -1,8 +1,9 @@
{-# LANGUAGE DeriveFunctor, ExistentialQuantification, RankNTypes, StandaloneDeriving #-}
{-# LANGUAGE DeriveFunctor, ExistentialQuantification, LambdaCase, RankNTypes, StandaloneDeriving #-}
module Analysis.Analysis
( Analysis(..)
) where
import Control.Effect.Carrier
import Data.Text (Text)
-- | A record of functions necessary to perform analysis.
@ -32,6 +33,13 @@ data Env name addr m k
deriving instance Functor m => Functor (Env name addr m)
instance HFunctor (Env name addr) where
hmap f = \case
Alloc name k -> Alloc name (f . k)
Bind name addr m k -> Bind name addr (f m) (f . k)
Lookup name k -> Lookup name (f . k)
data Heap addr value m k
= Deref addr (Maybe value -> m k)
| Assign addr value (m k)