You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 1, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: semantic-core/src/Data/Scope.hs
+19-7Lines changed: 19 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -12,8 +12,8 @@ module Data.Scope
12
12
, instantiate1
13
13
, instantiate
14
14
, instantiateEither
15
-
, un
16
-
, unEither
15
+
, unprefix
16
+
, unprefixEither
17
17
) where
18
18
19
19
importControl.Applicative (liftA2)
@@ -110,11 +110,23 @@ instantiateEither :: Monad f => (Either a b -> f c) -> Scope a f b -> f c
110
110
instantiateEither f = unScope >=> incr (f .Left) (>>= f .Right)
111
111
112
112
113
-
un:: (Int->t->Maybe (a, t)) ->t-> (Stacka, t)
114
-
un from = unEither (matchMaybe . from)
115
-
116
-
unEither:: (Int->t->Either (a, t) b) ->t-> (Stacka, b)
117
-
unEither from = go (0::Int) Nil
113
+
--| Unwrap a (possibly-empty) prefix of @a@s wrapping a @t@ using a helper function.
114
+
--
115
+
-- This allows us to peel a prefix of syntax, typically binders, off of a term, returning a stack of prefixing values (e.g. variables) and the outermost subterm rejected by the function.
116
+
unprefix
117
+
:: (Int->t->Maybe (a, t)) --^ A function taking the 0-based index into the prefix & the current term, and optionally returning a pair of the prefixing value and the inner subterm.
118
+
->t--^ The initial term.
119
+
-> (Stacka, t) --^ A stack of prefixing values & the final subterm.
120
+
unprefix from = unprefixEither (matchMaybe . from)
121
+
122
+
--| Unwrap a (possibly-empty) prefix of @a@s wrapping a @b@ within a @t@ using a helper function.
123
+
--
124
+
-- Compared to 'unprefix', this allows the helper function to extract inner terms of a different type, for example when @t@ is a right @b@-module.
125
+
unprefixEither
126
+
:: (Int->t->Either (a, t) b) --^ A function taking the 0-based index into the prefix & the current term, and returning either a pair of the prefixing value and the next inner subterm of type @t@, or the final inner subterm of type @b@.
127
+
->t--^ The initial term.
128
+
-> (Stacka, b) --^ A stack of prefixing values & the final subterm.
Copy file name to clipboardExpand all lines: src/Data/Abstract/Address/Monovariant.hs
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ import Data.Abstract.Name
9
9
importqualifiedData.SetasSet
10
10
importPrologue
11
11
12
-
--| '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.
12
+
--| 'Monovariant' models using one address for a particular name. It tracks the set of values that a particular address takes and uses it's name to lookup in the store and only allocation if new.
0 commit comments