1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 18:06:14 +03:00

Define a more aesthetic Show instance for Bindings.

This commit is contained in:
Rob Rix 2018-08-03 11:04:47 -04:00
parent 47b734bb81
commit b831b1e137

View File

@ -36,7 +36,7 @@ import Prologue
-- | A map of names to values. Represents a single scope level of an environment chain.
newtype Bindings address = Bindings { unBindings :: Map.Map Name address }
deriving (Eq, Ord, Show)
deriving (Eq, Ord)
instance Semigroup (Bindings address) where
(<>) (Bindings a) (Bindings b) = Bindings (a <> b)
@ -48,6 +48,9 @@ instance Monoid (Bindings address) where
instance Lower (Bindings address) where
lowerBound = mempty
instance Show address => Show (Bindings address) where
showsPrec d = showsUnaryWith showsPrec "Bindings" d . pairs
-- | A LIFO stack of maps of names to addresses, representing a lexically-scoped evaluation environment.
-- All behaviors can be assumed to be frontmost-biased: looking up "a" will check the most specific
-- scope for "a", then the next, and so on.