diff options
author | Eduardo Julian | 2018-04-06 08:32:41 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-04-06 08:32:41 -0400 |
commit | ca238f9c89d3156842b0a3d5fe24a5d69b2eedb0 (patch) | |
tree | 50ba106541f2357daf27393df28e8b263f7311e1 /new-luxc/source/luxc/lang/analysis/case | |
parent | 84d7e87817cd2c074653b34d028c8fa807febc7f (diff) |
- Adapted new-luxc's code to latest stdlib changes.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/analysis/case.lux | 23 | ||||
-rw-r--r-- | new-luxc/source/luxc/lang/analysis/case/coverage.lux | 13 |
2 files changed, 21 insertions, 15 deletions
diff --git a/new-luxc/source/luxc/lang/analysis/case.lux b/new-luxc/source/luxc/lang/analysis/case.lux index c40bb2ac3..a9731a1d7 100644 --- a/new-luxc/source/luxc/lang/analysis/case.lux +++ b/new-luxc/source/luxc/lang/analysis/case.lux @@ -22,13 +22,18 @@ [".A" structure] (case [".A" coverage]))))) -(exception: #export Cannot-Match-Type-With-Pattern) -(exception: #export Sum-Type-Has-No-Case) -(exception: #export Unrecognized-Pattern-Syntax) -(exception: #export Cannot-Simplify-Type-For-Pattern-Matching) -(exception: #export Cannot-Have-Empty-Branches) -(exception: #export Non-Exhaustive-Pattern-Matching) -(exception: #export Symbols-Must-Be-Unqualified-Inside-Patterns) +(do-template [<name>] + [(exception: #export (<name> {message Text}) + message)] + + [Cannot-Match-Type-With-Pattern] + [Sum-Type-Has-No-Case] + [Unrecognized-Pattern-Syntax] + [Cannot-Simplify-Type-For-Pattern-Matching] + [Cannot-Have-Empty-Branches] + [Non-Exhaustive-Pattern-Matching] + [Symbols-Must-Be-Unqualified-Inside-Patterns] + ) (def: (pattern-error type pattern) (-> Type Code Text) @@ -204,7 +209,7 @@ [[memberP+ thenA] (list/fold (: (All [a] (-> [Type Code] (Meta [(List la.Pattern) a]) (Meta [(List la.Pattern) a]))) - (function [[memberT memberC] then] + (function (_ [memberT memberC] then) (do @ [[memberP [memberP+ thenA]] ((:! (All [a] (-> (Maybe Nat) Type Code (Meta a) (Meta [la.Pattern a]))) analyse-pattern) @@ -292,7 +297,7 @@ (analyse inputC)) outputH (analyse-pattern #.None inputT patternH (analyse bodyH)) outputT (monad.map @ - (function [[patternT bodyT]] + (function (_ [patternT bodyT]) (analyse-pattern #.None inputT patternT (analyse bodyT))) branchesT) outputHC (|> outputH product.left coverageA.determine) diff --git a/new-luxc/source/luxc/lang/analysis/case/coverage.lux b/new-luxc/source/luxc/lang/analysis/case/coverage.lux index ae72b47e4..b81a3b7a9 100644 --- a/new-luxc/source/luxc/lang/analysis/case/coverage.lux +++ b/new-luxc/source/luxc/lang/analysis/case/coverage.lux @@ -13,6 +13,9 @@ (luxc ["&" lang] (lang ["la" analysis]))) +(exception: #export (Unknown-Pattern {message Text}) + message) + ## The coverage of a pattern-matching expression summarizes how well ## all the possible values of an input are being covered by the ## different patterns involved. @@ -42,8 +45,6 @@ _ false)) -(exception: #export Unknown-Pattern) - (def: #export (determine pattern) (-> la.Pattern (Meta Coverage)) (case pattern @@ -142,7 +143,7 @@ (let [flatR (flatten-alt reference) flatS (flatten-alt sample)] (and (n/= (list.size flatR) (list.size flatS)) - (list.every? (function [[coverageR coverageS]] + (list.every? (function (_ [coverageR coverageS]) (= coverageR coverageS)) (list.zip2 flatR flatS)))) @@ -184,7 +185,7 @@ ## else (do e.Monad<Error> [casesM (monad.fold @ - (function [[tagA coverageA] casesSF'] + (function (_ [tagA coverageA] casesSF') (case (dict.get tagA casesSF') (#.Some coverageSF) (do @ @@ -251,7 +252,7 @@ [#let [fuse-once (: (-> Coverage (List Coverage) (e.Error [(Maybe Coverage) (List Coverage)])) - (function [coverage possibilities] + (function (_ coverage possibilities) (loop [alts possibilities] (case alts #.Nil @@ -284,7 +285,7 @@ #.None (case (list.reverse possibilities) (#.Cons last prevs) - (wrap (list/fold (function [left right] (#Alt left right)) + (wrap (list/fold (function (_ left right) (#Alt left right)) last prevs)) |