1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 00:42:33 +03:00

📝 Neutral.

This commit is contained in:
Rob Rix 2021-08-24 09:47:03 -04:00
parent 3cd8945a2b
commit b5b39bdc2f
No known key found for this signature in database
GPG Key ID: 2BE643E01DC032AE

View File

@ -45,6 +45,11 @@ data Concrete
| Bool Bool
| Int Int
| String Text
-- | A neutral value, consisting of a variable at the head, followed by a “spine” of eliminations.
--
-- This constructor is key to hereditary substitution, whereby a value in 'Concrete' is a normal form by virtue of either being a value (i.e. one of the other constructors) or 'Neutral', somewhere inside a 'Closure'. In the latter case, when the surrounding closure is eliminated, if it substitutes out the variable at the head, the eliminations are applied, immediately reducing it. Since eliminations cant be applied to any of the other constructors, theres no way to represent redexes, so were left with a new term which is itself either already a value, or else is a neutral term underneath a closure.
--
-- This is essential for parametric modular analysis, as it allows us to obtain the same benefits not just for variables inside closures, but also variables which arent known from the surrounding (local) context (e.g. as-yet-unresolved imports). That in turn allows analysis to be performed 1. before weve computed an import graph, which is particularly difficult in some languages, 2. completely in parallel, and 3. incrementally.
| Neutral Name (Snoc (Elim Concrete))
-- NB: We derive the 'Semigroup' instance for 'Concrete' to take the second argument. This is equivalent to stating that the return value of an imperative sequence of statements is the value of its final statement.
deriving Semigroup via Last Concrete