From 26cf1d3a15abc1918593151acfd4feb58c6fdafa Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 19 Dec 2019 14:57:01 -0500 Subject: [PATCH] =?UTF-8?q?Revert=20"Represent=20import=20graphs=E2=80=99?= =?UTF-8?q?=20semi-abstract=20values=20more=20discretely."?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 2e3713db3442e56359d6e0b0f82aeb5fb9993c87. --- semantic-analysis/src/Analysis/ImportGraph.hs | 34 +++++-------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/semantic-analysis/src/Analysis/ImportGraph.hs b/semantic-analysis/src/Analysis/ImportGraph.hs index 220a537ab..06c94cc89 100644 --- a/semantic-analysis/src/Analysis/ImportGraph.hs +++ b/semantic-analysis/src/Analysis/ImportGraph.hs @@ -40,31 +40,16 @@ data Value semi = Value deriving (Eq, Ord, Show) instance Semigroup (Value (Semi term)) where - Value s1 g1 <> Value s2 g2 = Value (s1 <> s2) (Map.unionWith (<>) g1 g2) + Value _ g1 <> Value _ g2 = Value Abstract (Map.unionWith (<>) g1 g2) instance Monoid (Value (Semi term)) where - mempty = Value mempty mempty + mempty = Value Abstract mempty data Semi term - = Bottom - | Closure Path.AbsRelFile Span (Named (Scope () term Addr)) - | Unit - | Bool + = Closure Path.AbsRelFile Span (Named (Scope () term Addr)) -- FIXME: Bound String values. | String Text - | Top - -instance Semigroup (Semi term) where - s1 <> Bottom = s1 - Bottom <> s2 = s2 - Unit <> Unit = Unit - Bool <> Bool = Bool - String s1 <> String s2 - | s1 == s2 = String s1 - _ <> _ = Top - -instance Monoid (Semi term) where - mempty = Bottom + | Abstract deriving instance ( forall a . Eq a => Eq (f a), Monad f) => Eq (Semi f) deriving instance ( forall a . Eq a => Eq (f a) @@ -127,11 +112,11 @@ instance MonadTrans (DomainC term) where lift = DomainC . lift -- FIXME: decompose into a product domain and two atomic domains -instance (Alternative m, Has (Env Addr :+: A.Heap Addr (Value (Semi term)) :+: Reader Path.AbsRelFile :+: Reader Span) sig m) => Algebra (A.Domain term Addr (Value (Semi term)) :+: sig) (DomainC term m) where +instance Has (Env Addr :+: A.Heap Addr (Value (Semi term)) :+: Reader Path.AbsRelFile :+: Reader Span) sig m => Algebra (A.Domain term Addr (Value (Semi term)) :+: sig) (DomainC term m) where alg = \case L (A.Abstract i k) -> case i of - I.Unit -> k (Value Unit mempty) - I.Bool _ -> k (Value Bool mempty) + I.Unit -> k mempty + I.Bool _ -> k mempty I.String s -> k (Value (String s) mempty) I.Lam b -> do path <- ask @@ -145,10 +130,7 @@ instance (Alternative m, Has (Env Addr :+: A.Heap Addr (Value (Semi term)) :+: R v <$ A.assign @Addr @(Value (Semi term)) addr v k (fold fields) L (A.Concretize (Value s _) k) -> case s of - Bottom -> k I.Unit -- FIXME: what should we do when we don’t know anything about the value? - Unit -> k I.Unit - Bool -> k (I.Bool True) <|> k (I.Bool False) + Abstract -> k I.Unit -- FIXME: this should be broken down for case analysis String s -> k (I.String s) Closure _ _ b -> k (I.Lam b) - Top -> k I.Unit -- FIXME: what should we do when the value comprised multiple things? R other -> DomainC (send (handleCoercible other))