aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/analyser/case
diff options
context:
space:
mode:
authorEduardo Julian2017-10-18 12:42:46 -0400
committerEduardo Julian2017-10-18 12:42:46 -0400
commit901b09dada43ec6f3b21618800ec7400fda54a0d (patch)
treed62dde3df2ce4fd7d7cd8d0b177f6592f87817cb /new-luxc/source/luxc/analyser/case
parent14e381de130f0c8d3e333cf0523c6c98b9aa84b1 (diff)
- Updated to the latest changes in stdlib.
Diffstat (limited to 'new-luxc/source/luxc/analyser/case')
-rw-r--r--new-luxc/source/luxc/analyser/case/coverage.lux40
1 files changed, 20 insertions, 20 deletions
diff --git a/new-luxc/source/luxc/analyser/case/coverage.lux b/new-luxc/source/luxc/analyser/case/coverage.lux
index 94aa06e9b..cb066a2bf 100644
--- a/new-luxc/source/luxc/analyser/case/coverage.lux
+++ b/new-luxc/source/luxc/analyser/case/coverage.lux
@@ -4,7 +4,7 @@
eq)
(data [bool "B/" Eq<Bool>]
[number]
- ["R" result "R/" Monad<Result>]
+ ["e" error "error/" Monad<Error>]
(coll [list "L/" Fold<List>]
["D" dict])))
(luxc (lang ["la" analysis])))
@@ -97,8 +97,8 @@
## Because of that, the presence of redundant patterns is assumed to
## be a bug, likely due to programmer carelessness.
(def: redundant-pattern
- (R;Result Coverage)
- (R;fail "Redundant pattern."))
+ (e;Error Coverage)
+ (e;fail "Redundant pattern."))
(def: (flatten-alt coverage)
(-> Coverage (List Coverage))
@@ -144,7 +144,7 @@
## pattern-matching expression is exhaustive and whether it contains
## redundant patterns.
(def: #export (merge addition so-far)
- (-> Coverage Coverage (R;Result Coverage))
+ (-> Coverage Coverage (e;Error Coverage))
(case [addition so-far]
## The addition cannot possibly improve the coverage.
[_ #Exhaustive]
@@ -152,25 +152,25 @@
## The addition completes the coverage.
[#Exhaustive _]
- (R/wrap #Exhaustive)
+ (error/wrap #Exhaustive)
[#Partial #Partial]
- (R/wrap #Partial)
+ (error/wrap #Partial)
## 2 boolean coverages are exhaustive if they compliment one another.
(^multi [(#Bool sideA) (#Bool sideSF)]
(xor sideA sideSF))
- (R/wrap #Exhaustive)
+ (error/wrap #Exhaustive)
[(#Variant allA casesA) (#Variant allSF casesSF)]
(cond (not (n.= allSF allA))
- (R;fail "Variants do not match.")
+ (e;fail "Variants do not match.")
(:: (D;Eq<Dict> Eq<Coverage>) = casesSF casesA)
redundant-pattern
## else
- (do R;Monad<Result>
+ (do e;Monad<Error>
[casesM (monad;fold @
(function [[tagA coverageA] casesSF']
(case (D;get tagA casesSF')
@@ -196,11 +196,11 @@
## The 2 sequences cannot possibly be merged.
[false false]
- (R/wrap (#Alt so-far addition))
+ (error/wrap (#Alt so-far addition))
## Same prefix
[true false]
- (do R;Monad<Result>
+ (do e;Monad<Error>
[rightM (merge rightA rightSF)]
(if (exhaustive? rightM)
## If all that follows is exhaustive, then it can be safely dropped
@@ -211,7 +211,7 @@
## Same suffix
[false true]
- (do R;Monad<Result>
+ (do e;Monad<Error>
[leftM (merge leftA leftSF)]
(wrap (#Seq leftM rightA))))
@@ -223,7 +223,7 @@
## The right part is not necessary, since it can always match the left.
(^multi [single (#Seq left right)]
(C/= left single))
- (R/wrap single)
+ (error/wrap single)
## When merging a new coverage against one based on Alt, it may be
## that one of the many coverages in the Alt is complementary to
@@ -235,10 +235,10 @@
## This process must be repeated until no further productive
## merges can be done.
[_ (#Alt leftS rightS)]
- (do R;Monad<Result>
+ (do e;Monad<Error>
[#let [fuse-once (: (-> Coverage (List Coverage)
- (R;Result [(Maybe Coverage)
- (List Coverage)]))
+ (e;Error [(Maybe Coverage)
+ (List Coverage)]))
(function [coverage possibilities]
(loop [alts possibilities]
(case alts
@@ -247,7 +247,7 @@
(#;Cons alt alts')
(case (merge coverage alt)
- (#R;Success altM)
+ (#e;Success altM)
(case altM
(#Alt _)
(do @
@@ -257,8 +257,8 @@
_
(wrap [(#;Some altM) alts']))
- (#R;Error error)
- (R;fail error))
+ (#e;Error error)
+ (e;fail error))
))))]
[success possibilities] (fuse-once addition (flatten-alt so-far))]
(loop [success success
@@ -284,4 +284,4 @@
## The addition cannot possibly improve the coverage.
redundant-pattern
## There are now 2 alternative paths.
- (R/wrap (#Alt so-far addition)))))
+ (error/wrap (#Alt so-far addition)))))