From 095ece31826ed9f8961da9f5bcd62ac2b9a9d6c6 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 29 Mar 2018 09:07:53 -0400 Subject: [PATCH] Define a Location typeclass of which Cell is an associated type. --- src/Data/Abstract/Address.hs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Data/Abstract/Address.hs b/src/Data/Abstract/Address.hs index b7c1e82bb..7fc6bf9e6 100644 --- a/src/Data/Abstract/Address.hs +++ b/src/Data/Abstract/Address.hs @@ -14,19 +14,25 @@ instance Ord l => Ord1 (Address l) where liftCompare = genericLiftCompare instance Show l => Show1 (Address l) where liftShowsPrec = genericLiftShowsPrec +class Location loc where + -- | The type into which stored values will be written for a given location type. + type family Cell loc :: * -> * + + -- | 'Precise' models precise store semantics where only the 'Latest' value is taken. Everything gets it's own address (always makes a new allocation) which makes for a larger store. newtype Precise = Precise { unPrecise :: Int } deriving (Eq, Ord, Show) +instance Location Precise where + type Cell Precise = Latest + + -- | 'Monovariant' models using one address for a particular name. It trackes the set of values that a particular address takes and uses it's name to lookup in the store and only allocation if new. newtype Monovariant = Monovariant { unMonovariant :: Name } deriving (Eq, Ord, Show) - --- | The type into which stored values will be written for a given location type. -type family Cell l :: * -> * -type instance Cell Precise = Latest -type instance Cell Monovariant = Set +instance Location Monovariant where + type Cell Monovariant = Set -- | A cell holding a single value. Writes will replace any prior value.