aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux.lux
diff options
context:
space:
mode:
authorEduardo Julian2019-05-28 18:48:01 -0400
committerEduardo Julian2019-05-28 18:48:01 -0400
commit926c3e1dcc392dc21b77a93200fa3e01eb113cf2 (patch)
tree72a57dde416f7d263514190950a6686714008dee /stdlib/source/lux.lux
parenta420abd8ef1d5a008a5a0b6f75590cab2a9baac5 (diff)
Applied several tweaks to make the code easier to process by the new compiler.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux.lux32
1 files changed, 23 insertions, 9 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index 9e370f12b..b75b5bebe 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -5568,12 +5568,19 @@
(def: (multi-level-case$ g!_ [[init-pattern levels] body])
(-> Code [Multi-Level-Case Code] (List Code))
(let [inner-pattern-body (list@fold (function (_ [calculation pattern] success)
- (` (case (~ calculation)
- (~ pattern)
- (~ success)
-
- (~ g!_)
- #.None)))
+ (let [bind? (case pattern
+ [_ (#.Identifier _)]
+ #1
+
+ _
+ #0)]
+ (` (case (~ calculation)
+ (~ pattern)
+ (~ success)
+
+ (~+ (if bind?
+ (list)
+ (list g!_ (` #.None))))))))
(` (#.Some (~ body)))
(: (List [Code Code]) (list@reverse levels)))]
(list init-pattern inner-pattern-body)))
@@ -5601,6 +5608,12 @@
(^ (list& [_meta (#Form levels)] body next-branches))
(do meta-monad
[mlc (multi-level-case^ levels)
+ #let [initial-bind? (case mlc
+ [[_ (#.Identifier _)] _]
+ #1
+
+ _
+ #0)]
expected get-expected-type
g!temp (gensym "temp")]
(let [output (list g!temp
@@ -5613,9 +5626,10 @@
("lux check" (#.Apply (~ (type-to-code expected)) Maybe)
(case (~ g!temp)
(~+ (multi-level-case$ g!temp [mlc body]))
-
- (~ g!temp)
- #.None)))))]
+
+ (~+ (if initial-bind?
+ (list)
+ (list g!temp (` #.None)))))))))]
(wrap output)))
_