diff options
Diffstat (limited to 'stdlib/source/library/lux/data/collection/sequence.lux')
-rw-r--r-- | stdlib/source/library/lux/data/collection/sequence.lux | 186 |
1 files changed, 93 insertions, 93 deletions
diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index b6bdf698a..bae056369 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -369,112 +369,112 @@ (syntax (_ [elems (<>.some <code>.any)]) (in (.list (` (..of_list (.list (~+ elems)))))))) -(implementation: (node_equivalence //#=) +(def: (node_equivalence //#=) (All (_ a) (-> (Equivalence a) (Equivalence (Node a)))) - - (def: (= v1 v2) - (case [v1 v2] - [{#Base b1} {#Base b2}] - (array.= //#= b1 b2) - - [{#Hierarchy h1} {#Hierarchy h2}] - (array.= (node_equivalence //#=) h1 h2) - - _ - #0))) - -(implementation: .public (equivalence //#=) + (implementation + (def: (= v1 v2) + (case [v1 v2] + [{#Base b1} {#Base b2}] + (array.= //#= b1 b2) + + [{#Hierarchy h1} {#Hierarchy h2}] + (array.= (node_equivalence //#=) h1 h2) + + _ + #0)))) + +(def: .public (equivalence //#=) (All (_ a) (-> (Equivalence a) (Equivalence (Sequence a)))) - - (def: (= v1 v2) - (and (n.= (the #size v1) (the #size v2)) - (let [(open "node#[0]") (node_equivalence //#=)] - (and (node#= {#Base (the #tail v1)} - {#Base (the #tail v2)}) - (node#= {#Hierarchy (the #root v1)} - {#Hierarchy (the #root v2)})))))) - -(implementation: node_mix + (implementation + (def: (= v1 v2) + (and (n.= (the #size v1) (the #size v2)) + (let [(open "node#[0]") (node_equivalence //#=)] + (and (node#= {#Base (the #tail v1)} + {#Base (the #tail v2)}) + (node#= {#Hierarchy (the #root v1)} + {#Hierarchy (the #root v2)}))))))) + +(def: node_mix (Mix Node) - - (def: (mix $ init xs) - (case xs - {#Base base} - (array.mix (function (_ _ item output) ($ item output)) - init - base) - - {#Hierarchy hierarchy} - (array.mix (function (_ _ node init') (mix $ init' node)) + (implementation + (def: (mix $ init xs) + (case xs + {#Base base} + (array.mix (function (_ _ item output) ($ item output)) + init + base) + + {#Hierarchy hierarchy} + (array.mix (function (_ _ node init') (mix $ init' node)) + init + hierarchy))))) + +(def: .public mix + (Mix Sequence) + (implementation + (def: (mix $ init xs) + (let [(open "[0]") node_mix] + (mix $ + (mix $ init - hierarchy)))) + {#Hierarchy (the #root xs)}) + {#Base (the #tail xs)}))))) -(implementation: .public mix - (Mix Sequence) - - (def: (mix $ init xs) - (let [(open "[0]") node_mix] - (mix $ - (mix $ - init - {#Hierarchy (the #root xs)}) - {#Base (the #tail xs)})))) - -(implementation: .public monoid +(def: .public monoid (All (_ a) (Monoid (Sequence a))) - - (def: identity ..empty) - - (def: (composite xs ys) - (list#mix suffix xs (..list ys)))) + (implementation + (def: identity ..empty) + + (def: (composite xs ys) + (list#mix suffix xs (..list ys))))) -(implementation: node_functor +(def: node_functor (Functor Node) - - (def: (each $ xs) - (case xs - {#Base base} - {#Base (array.each $ base)} - - {#Hierarchy hierarchy} - {#Hierarchy (array.each (each $) hierarchy)}))) - -(implementation: .public functor + (implementation + (def: (each $ xs) + (case xs + {#Base base} + {#Base (array.each $ base)} + + {#Hierarchy hierarchy} + {#Hierarchy (array.each (each $) hierarchy)})))) + +(def: .public functor (Functor Sequence) - - (def: (each $ xs) - [#level (the #level xs) - #size (the #size xs) - #root (let [... TODO: This binding was established to get around a compilation error. Fix and inline! - $ (at node_functor each $)] - (|> xs (the #root) (array.each $))) - #tail (|> xs (the #tail) (array.each $))])) - -(implementation: .public apply + (implementation + (def: (each $ xs) + [#level (the #level xs) + #size (the #size xs) + #root (let [ ... TODO: This binding was established to get around a compilation error. Fix and inline! + $ (at node_functor each $)] + (|> xs (the #root) (array.each $))) + #tail (|> xs (the #tail) (array.each $))]))) + +(def: .public apply (Apply Sequence) - - (def: functor ..functor) - - (def: (on fa ff) - (let [(open "[0]") ..functor - (open "[0]") ..mix - (open "[0]") ..monoid - results (each (function (_ f) (each f fa)) - ff)] - (mix composite identity results)))) - -(implementation: .public monad + (implementation + (def: functor ..functor) + + (def: (on fa ff) + (let [(open "[0]") ..functor + (open "[0]") ..mix + (open "[0]") ..monoid + results (each (function (_ f) (each f fa)) + ff)] + (mix composite identity results))))) + +(def: .public monad (Monad Sequence) - - (def: functor ..functor) + (implementation + (def: functor ..functor) - (def: in - (|>> sequence)) + (def: in + (|>> sequence)) - (def: conjoint - (let [(open "[0]") ..mix - (open "[0]") ..monoid] - (mix (function (_ post pre) (composite pre post)) identity)))) + (def: conjoint + (let [(open "[0]") ..mix + (open "[0]") ..monoid] + (mix (function (_ post pre) (composite pre post)) identity))))) (def: .public reversed (All (_ a) (-> (Sequence a) (Sequence a))) |