From 788afa5a960337778095b1d3aa3d43bed855ae7c Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 14 Aug 2018 14:41:33 -0400 Subject: [PATCH 1/2] Define a specialized Show instance for Bindings. --- src/Data/Abstract/Environment.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Data/Abstract/Environment.hs b/src/Data/Abstract/Environment.hs index 91f222e62..6d6e018a1 100644 --- a/src/Data/Abstract/Environment.hs +++ b/src/Data/Abstract/Environment.hs @@ -37,7 +37,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) @@ -49,6 +49,10 @@ 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. From b57bacb3022c7cb3dff09383e2de1a654e5c4dbb Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 14 Aug 2018 14:42:26 -0400 Subject: [PATCH 2/2] Flatten out the sets in the Heap Show instance. --- src/Data/Abstract/Heap.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/Abstract/Heap.hs b/src/Data/Abstract/Heap.hs index 740046f55..32d38ac96 100644 --- a/src/Data/Abstract/Heap.hs +++ b/src/Data/Abstract/Heap.hs @@ -52,4 +52,4 @@ instance (Ord address, Ord value) => Reducer (address, value) (Heap address valu snoc (Heap heap) (addr, a) = Heap (snoc heap (addr, a)) instance (Show address, Show value) => Show (Heap address value) where - showsPrec d = showsUnaryWith showsPrec "Heap" d . Monoidal.pairs . unHeap + showsPrec d = showsUnaryWith showsPrec "Heap" d . map (second toList) . Monoidal.pairs . unHeap