mirror of
https://github.com/github/semantic.git
synced 2025-01-03 04:51:57 +03:00
Define a Location typeclass of which Cell is an associated type.
This commit is contained in:
parent
9ce0fb1fef
commit
095ece3182
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user