Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit d998f66

Browse files
committed
Give fromScope a parameter to bind over the contents of the scope.
1 parent 790f4e3 commit d998f66

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

semantic-core/src/Analysis/Eval.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ eval Analysis{..} eval = \case
3838
Term c -> case c of
3939
Let n -> alloc n >>= bind n >> unit
4040
a :>> b -> eval a >> eval b
41-
Lam (Ignored n) b -> abstract eval n (incr (const n) id <$> fromScope b)
41+
Lam (Ignored n) b -> abstract eval n (fromScope (incr (const (pure n)) id) b)
4242
f :$ a -> do
4343
f' <- eval f
4444
a' <- eval a

semantic-core/src/Data/Core/Pretty.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ prettyCore style = run . runReader @Prec 0 . go (pure . name)
106106

107107
-- Annotations are not pretty-printed, as it lowers the signal/noise ratio too profoundly.
108108
Ann _ c -> go var c
109-
where bind (Ignored x) f = let x' = name x in (,) x' <$> go (incr (const (pure x')) var) (fromScope f)
109+
where bind (Ignored x) f = let x' = name x in (,) x' <$> go (incr (const (pure x')) var) (fromScope sequenceA f)
110110
lambda = case style of
111111
Unicode -> symbol "λ"
112112
Ascii -> symbol "\\"

semantic-core/src/Data/Scope.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ instance HFunctor (Scope a) where
5656
hmap f = Scope . f . fmap (fmap f) . unScope
5757

5858
instance (Eq a, Eq b, forall a . Eq a => Eq (f a), Monad f) => Eq (Scope a f b) where
59-
(==) = (==) `on` fromScope
59+
(==) = (==) `on` fromScope sequenceA
6060

6161
instance (Ord a, Ord b, forall a . Eq a => Eq (f a)
6262
, forall a . Ord a => Ord (f a), Monad f) => Ord (Scope a f b) where
63-
compare = compare `on` fromScope
63+
compare = compare `on` fromScope sequenceA
6464

6565
deriving instance (Show a, Show b, forall a . Show a => Show (f a)) => Show (Scope a f b)
6666

@@ -78,8 +78,8 @@ instance RightModule (Scope a) where
7878
Scope m >>=* f = Scope (fmap (>>= f) <$> m)
7979

8080

81-
fromScope :: Monad f => Scope a f b -> f (Incr a b)
82-
fromScope = unScope >=> sequenceA
81+
fromScope :: Monad f => (Incr a (f b) -> f c) -> Scope a f b -> f c
82+
fromScope f = unScope >=> f
8383

8484
toScope :: Applicative f => f (Incr a b) -> Scope a f b
8585
toScope = Scope . fmap (fmap pure)

0 commit comments

Comments
 (0)