diff options
author | Eduardo Julian | 2022-06-26 12:55:04 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-06-26 12:55:04 -0400 |
commit | 3053fd79bc6ae42415298ee056a268dc2c9b690c (patch) | |
tree | a71ac65955b42978160087b933c962b27f85fbcc /stdlib/source/polytypic | |
parent | 716ca5377386ca87eded7dd514ccc17f8ed281c3 (diff) |
New "parser" hierarchy. [Part 4]
Diffstat (limited to 'stdlib/source/polytypic')
-rw-r--r-- | stdlib/source/polytypic/lux/abstract/equivalence.lux | 6 | ||||
-rw-r--r-- | stdlib/source/polytypic/lux/abstract/functor.lux | 41 | ||||
-rw-r--r-- | stdlib/source/polytypic/lux/data/format/json.lux | 10 |
3 files changed, 28 insertions, 29 deletions
diff --git a/stdlib/source/polytypic/lux/abstract/equivalence.lux b/stdlib/source/polytypic/lux/abstract/equivalence.lux index fce8d86bd..3d8497e87 100644 --- a/stdlib/source/polytypic/lux/abstract/equivalence.lux +++ b/stdlib/source/polytypic/lux/abstract/equivalence.lux @@ -4,9 +4,8 @@ [abstract [monad (.only Monad do)]] [control - ["[0]" maybe] - ["<>" parser (.only) - ["<[0]>" type]]] + ["<>" parser] + ["[0]" maybe]] [data ["[0]" product] ["[0]" bit] @@ -35,6 +34,7 @@ ["[0]" day] ["[0]" month]] ["[0]" type (.only) + ["<[1]>" \\parser] ["[0]" poly (.only polytypic)] ["[0]" unit]]]] [\\library diff --git a/stdlib/source/polytypic/lux/abstract/functor.lux b/stdlib/source/polytypic/lux/abstract/functor.lux index 1ff6c0398..3cc3074b0 100644 --- a/stdlib/source/polytypic/lux/abstract/functor.lux +++ b/stdlib/source/polytypic/lux/abstract/functor.lux @@ -4,9 +4,7 @@ [abstract [monad (.only Monad do)]] [control - ["p" parser (.only) - ["<[0]>" type] - ["s" code (.only Parser)]]] + ["<>" parser]] [data ["[0]" product] ["[0]" text (.only) @@ -19,13 +17,14 @@ [number ["n" nat]]] ["[0]" type (.only) + ["<[1]>" \\parser] ["[0]" poly (.only polytypic)]]]] [\\library ["[0]" /]]) (def .public functor (polytypic functor - (do [! p.monad] + (do [! <>.monad] [.let [g!_ (code.local "____________") type_funcC (code.local "____________type_funcC") funcC (code.local "____________funcC") @@ -44,16 +43,16 @@ ((~! /.Functor) ((~ (poly.code *env* unwrappedT)) (~+ paramsC))))))))) Arg<?> (is (-> Code (<type>.Parser Code)) (function (Arg<?> valueC) - (all p.either + (all <>.either ... Type-var - (do p.monad + (do <>.monad [.let [varI (|> num_vars (n.* 2) --)] _ (<type>.this_parameter varI)] (in (` ((~ funcC) (~ valueC))))) ... Variants (do ! [_ (in []) - membersC (<type>.variant (p.many (Arg<?> valueC))) + membersC (<type>.variant (<>.many (Arg<?> valueC))) .let [last (-- (list.size membersC))]] (in (` (case (~ valueC) (~+ (list#conjoint (list#each (function (_ [tag memberC]) @@ -64,18 +63,18 @@ (` {(~ (code.nat tag)) #0 (~ memberC)})))) (list.enumeration membersC)))))))) ... Tuples - (do p.monad + (do <>.monad [pairsCC (is (<type>.Parser (List [Code Code])) (<type>.tuple (loop (again [idx 0 pairsCC (is (List [Code Code]) (list))]) - (p.either (let [slotC (|> idx %.nat (format "____________slot") code.local)] - (do ! - [_ (in []) - memberC (Arg<?> slotC)] - (again (++ idx) - (list#composite pairsCC (list [slotC memberC]))))) - (in pairsCC)))))] + (<>.either (let [slotC (|> idx %.nat (format "____________slot") code.local)] + (do ! + [_ (in []) + memberC (Arg<?> slotC)] + (again (++ idx) + (list#composite pairsCC (list [slotC memberC]))))) + (in pairsCC)))))] (in (` (case (~ valueC) [(~+ (list#each product.left pairsCC))] [(~+ (list#each product.right pairsCC))])))) @@ -84,7 +83,7 @@ [_ (in []) .let [g! (code.local "____________") outL (code.local "____________outL")] - [inT+ outC] (<type>.function (p.many <type>.any) + [inT+ outC] (<type>.function (<>.many <type>.any) (Arg<?> outL)) .let [inC+ (|> (list.size inT+) list.indices @@ -93,18 +92,18 @@ (let [(~ outL) ((~ valueC) (~+ inC+))] (~ outC)))))) ... Recursion - (do p.monad + (do <>.monad [_ <type>.recursive_call] (in (` ((~' each) (~ funcC) (~ valueC))))) ... Parameters - (do p.monad + (do <>.monad [_ <type>.any] (in valueC)) )))] [_ _ outputC] (is (<type>.Parser [Code (List Code) Code]) - (p.either (<type>.polymorphic - (Arg<?> inputC)) - (p.failure (format "Cannot create Functor for: " (%.type inputT)))))] + (<>.either (<type>.polymorphic + (Arg<?> inputC)) + (<>.failure (format "Cannot create Functor for: " (%.type inputT)))))] (in (` (is (~ (@Functor inputT)) (implementation (def ((~' each) (~ funcC) (~ inputC)) diff --git a/stdlib/source/polytypic/lux/data/format/json.lux b/stdlib/source/polytypic/lux/data/format/json.lux index 8ce7112e3..064e4bcce 100644 --- a/stdlib/source/polytypic/lux/data/format/json.lux +++ b/stdlib/source/polytypic/lux/data/format/json.lux @@ -5,10 +5,8 @@ [monad (.only do)] ["[0]" codec]] [control - ["[0]" try] - ["<>" parser (.only) - ["<[0]>" type] - ["<[0]>" code]]] + ["<>" parser] + ["[0]" try]] [data ["[0]" text (.only) ["%" \\format (.only format)]] @@ -21,7 +19,8 @@ ["[0]" dictionary]]] [macro [syntax (.only syntax)] - ["[0]" code]] + ["[0]" code (.only) + ["<[1]>" \\parser]]] [math [number ["n" nat (.use "[1]#[0]" decimal)] @@ -35,6 +34,7 @@ ["[0]" day] ["[0]" month]] ["[0]" type (.only) + ["<[1]>" \\parser] ["[0]" unit] ["[0]" poly (.only polytypic)]]]] [\\library |