diff options
Diffstat (limited to 'stdlib/source/lux/macro/code.lux')
-rw-r--r-- | stdlib/source/lux/macro/code.lux | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/stdlib/source/lux/macro/code.lux b/stdlib/source/lux/macro/code.lux index d8763c3e5..67be6ce56 100644 --- a/stdlib/source/lux/macro/code.lux +++ b/stdlib/source/lux/macro/code.lux @@ -1,17 +1,18 @@ (.module: [lux (#- nat int rev) - [control [equivalence (#+ Equivalence)]] + [control + [equivalence (#+ Equivalence)]] [data - bool + bit number [text (#+ Equivalence<Text>) ("text/" Monoid<Text>)] ident - [collection [list #* ("list/" Functor<List> Fold<List>)]] + [collection [list ("list/" Functor<List> Fold<List>)]] ]]) ## [Types] ## (type: (Code' w) -## (#.Bool Bool) +## (#.Bit Bit) ## (#.Nat Nat) ## (#.Int Int) ## (#.Frac Frac) @@ -34,7 +35,7 @@ (-> <type> Code) [_cursor (<tag> x)])] - [bool Bool #.Bool] + [bit Bit #.Bit] [nat Nat #.Nat] [int Int #.Int] [rev Rev #.Rev] @@ -63,7 +64,7 @@ (^template [<tag> <eq>] [[_ (<tag> x')] [_ (<tag> y')]] (:: <eq> = x' y')) - ([#.Bool Equivalence<Bool>] + ([#.Bit Equivalence<Bit>] [#.Nat Equivalence<Nat>] [#.Int Equivalence<Int>] [#.Rev Equivalence<Rev>] @@ -74,20 +75,13 @@ (^template [<tag>] [[_ (<tag> xs')] [_ (<tag> ys')]] - (and (:: Equivalence<Nat> = (size xs') (size ys')) - (list/fold (function (_ [x' y'] old) - (and old (= x' y'))) - true - (zip2 xs' ys')))) + (:: (list.Equivalence<List> =) = xs' ys')) ([#.Form] [#.Tuple]) [[_ (#.Record xs')] [_ (#.Record ys')]] - (and (:: Equivalence<Nat> = (size xs') (size ys')) - (list/fold (function (_ [[xl' xr'] [yl' yr']] old) - (and old (= xl' yl') (= xr' yr'))) - true - (zip2 xs' ys'))) + (:: (list.Equivalence<List> (equivalence.product = =)) + = xs' ys') _ false))) @@ -99,7 +93,7 @@ (^template [<tag> <struct>] [_ (<tag> value)] (:: <struct> encode value)) - ([#.Bool Codec<Text,Bool>] + ([#.Bit Codec<Text,Bit>] [#.Nat Codec<Text,Nat>] [#.Int Codec<Text,Int>] [#.Rev Codec<Text,Rev>] @@ -114,12 +108,19 @@ (^template [<tag> <open> <close>] [_ (<tag> members)] - ($_ text/compose <open> (|> members (list/map to-text) (interpose " ") (text.join-with "")) <close>)) + ($_ text/compose <open> (|> members (list/map to-text) (list.interpose " ") (text.join-with "")) <close>)) ([#.Form "(" ")"] [#.Tuple "[" "]"]) [_ (#.Record pairs)] - ($_ text/compose "{" (|> pairs (list/map (function (_ [left right]) ($_ text/compose (to-text left) " " (to-text right)))) (interpose " ") (text.join-with "")) "}") + ($_ text/compose + "{" + (|> pairs + (list/map (function (_ [left right]) + ($_ text/compose (to-text left) " " (to-text right)))) + (list.interpose " ") + (text.join-with "")) + "}") )) (def: #export (replace original substitute ast) |