diff options
Diffstat (limited to 'stdlib/source')
-rw-r--r-- | stdlib/source/lux/control/monoid.lux | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/stdlib/source/lux/control/monoid.lux b/stdlib/source/lux/control/monoid.lux index c073bdb0b..09737cb12 100644 --- a/stdlib/source/lux/control/monoid.lux +++ b/stdlib/source/lux/control/monoid.lux @@ -1,4 +1,5 @@ -(.module: lux) +(.module: lux + (// [fold #+ Fold])) (sig: #export (Monoid a) {#.doc "A way to compose values. @@ -11,9 +12,15 @@ (def: #export (compose Monoid<l> Monoid<r>) (All [l r] (-> (Monoid l) (Monoid r) (Monoid [l r]))) - (struct (def: identity - [(:: Monoid<l> identity) (:: Monoid<r> identity)]) - - (def: (compose [lL rL] [lR rR]) - [(:: Monoid<l> compose lL lR) - (:: Monoid<r> compose rL rR)]))) + (struct + (def: identity + [(:: Monoid<l> identity) (:: Monoid<r> identity)]) + + (def: (compose [lL rL] [lR rR]) + [(:: Monoid<l> compose lL lR) + (:: Monoid<r> compose rL rR)]))) + +(def: #export (fold Monoid<a> Fold<F> data) + (All [a F] (-> (Monoid a) (Fold F) (F a) a)) + (let [(^open "a/") Monoid<a>] + (:: Fold<F> fold a/compose a/identity data))) |