diff options
author | Eduardo Julian | 2018-04-05 07:48:25 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-04-05 07:48:25 -0400 |
commit | 435771d3c4d4ffa791805e7006ee3bde488a4090 (patch) | |
tree | 693b9e2a6d8c6ddf4e439336e5bfcd665c9955cd /stdlib/source/lux/macro/poly/functor.lux | |
parent | 3de94c8a341ef3f19fd75eeeb98e5333d2fe89d0 (diff) |
- Improved the syntax for the "lux.function" macro.
Diffstat (limited to 'stdlib/source/lux/macro/poly/functor.lux')
-rw-r--r-- | stdlib/source/lux/macro/poly/functor.lux | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/stdlib/source/lux/macro/poly/functor.lux b/stdlib/source/lux/macro/poly/functor.lux index f3ed46041..91a325198 100644 --- a/stdlib/source/lux/macro/poly/functor.lux +++ b/stdlib/source/lux/macro/poly/functor.lux @@ -17,23 +17,23 @@ (poly: #export Functor<?> (do @ - [#let [type-funcC (code.local-symbol "\u0000type-funcC") - funcC (code.local-symbol "\u0000funcC") - inputC (code.local-symbol "\u0000inputC")] + [#let [type-funcC (code.local-symbol "____________type-funcC") + funcC (code.local-symbol "____________funcC") + inputC (code.local-symbol "____________inputC")] *env* poly.env inputT poly.peek [polyC varsC non-functorT] (poly.local (list inputT) (poly.polymorphic poly.any)) #let [num-vars (list.size varsC)] #let [@Functor (: (-> Type Code) - (function [unwrappedT] + (function (_ unwrappedT) (if (n/= +1 num-vars) (` (functor.Functor (~ (poly.to-code *env* unwrappedT)))) (let [paramsC (|> num-vars n/dec list.indices (L/map (|>> %n code.local-symbol)))] (` (All [(~+ paramsC)] (functor.Functor ((~ (poly.to-code *env* unwrappedT)) (~+ paramsC))))))))) Arg<?> (: (-> Code (poly.Poly Code)) - (function Arg<?> [valueC] + (function (Arg<?> valueC) ($_ p.either ## Type-var (do p.Monad<Parser> @@ -45,7 +45,7 @@ [_ (wrap []) membersC (poly.variant (p.many (Arg<?> valueC)))] (wrap (` (case (~ valueC) - (~+ (L/join (L/map (function [[tag memberC]] + (~+ (L/join (L/map (function (_ [tag memberC]) (list (` ((~ (code.nat tag)) (~ valueC))) (` ((~ (code.nat tag)) (~ memberC))))) (list.enumerate membersC)))))))) @@ -55,7 +55,7 @@ (poly.tuple (loop [idx +0 pairsCC (: (List [Code Code]) (list))] - (p.either (let [slotC (|> idx %n (format "\u0000slot") code.local-symbol)] + (p.either (let [slotC (|> idx %n (format "____________slot") code.local-symbol)] (do @ [_ (wrap []) memberC (Arg<?> slotC)] @@ -68,13 +68,14 @@ ## Functions (do @ [_ (wrap []) - #let [outL (code.local-symbol "\u0000outL")] + #let [g! (code.local-symbol "____________") + outL (code.local-symbol "____________outL")] [inT+ outC] (poly.function (p.many poly.any) (Arg<?> outL)) #let [inC+ (|> (list.size inT+) n/dec (list.n/range +0) - (L/map (|>> %n (format "\u0000inC") code.local-symbol)))]] - (wrap (` (function [(~+ inC+)] + (L/map (|>> %n (format "____________inC") code.local-symbol)))]] + (wrap (` (function ((~ g!) (~+ inC+)) (let [(~ outL) ((~ valueC) (~+ inC+))] (~ outC)))))) ## Recursion |