From 737a4820b130c966615a93243b65463d04a0322d Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 11 Oct 2017 17:10:44 -0400 Subject: - Added monoid composition. --- stdlib/source/lux/control/monoid.lux | 10 +++++++++- stdlib/source/lux/data/bool.lux | 2 +- stdlib/source/lux/data/coll/list.lux | 2 +- stdlib/source/lux/data/number.lux | 2 +- stdlib/source/lux/data/text.lux | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/stdlib/source/lux/control/monoid.lux b/stdlib/source/lux/control/monoid.lux index 53f91474f..6634445a6 100644 --- a/stdlib/source/lux/control/monoid.lux +++ b/stdlib/source/lux/control/monoid.lux @@ -1,6 +1,5 @@ (;module: lux) -## Signatures (sig: #export (Monoid a) {#;doc "A way to compose values. @@ -9,3 +8,12 @@ identity) (: (-> a a a) compose)) + +(def: #export (compose Monoid Monoid) + (All [l r] (-> (Monoid l) (Monoid r) (Monoid [l r]))) + (struct (def: identity + [(:: Monoid identity) (:: Monoid identity)]) + + (def: (compose [lL rL] [lR rR]) + [(:: Monoid compose lL lR) + (:: Monoid compose rL rR)]))) diff --git a/stdlib/source/lux/data/bool.lux b/stdlib/source/lux/data/bool.lux index b07d3c8df..c5b345ce1 100644 --- a/stdlib/source/lux/data/bool.lux +++ b/stdlib/source/lux/data/bool.lux @@ -1,6 +1,6 @@ (;module: lux - (lux (control monoid + (lux (control [monoid #+ Monoid] [eq #+ Eq] hash codec))) diff --git a/stdlib/source/lux/data/coll/list.lux b/stdlib/source/lux/data/coll/list.lux index 5db72e77e..cab5479be 100644 --- a/stdlib/source/lux/data/coll/list.lux +++ b/stdlib/source/lux/data/coll/list.lux @@ -1,6 +1,6 @@ (;module: lux - (lux (control monoid + (lux (control [monoid #+ Monoid] ["F" functor] ["A" applicative] ["M" monad #+ do Monad] diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux index 769561b83..332ce6562 100644 --- a/stdlib/source/lux/data/number.lux +++ b/stdlib/source/lux/data/number.lux @@ -1,7 +1,7 @@ (;module: {#;doc "Implementations of common structures for Lux's primitive number types."} lux (lux (control number - monoid + [monoid #+ Monoid] [eq #+ Eq] hash [order] diff --git a/stdlib/source/lux/data/text.lux b/stdlib/source/lux/data/text.lux index dd25a1359..835d55fd1 100644 --- a/stdlib/source/lux/data/text.lux +++ b/stdlib/source/lux/data/text.lux @@ -1,6 +1,6 @@ (;module: lux - (lux (control monoid + (lux (control [monoid #+ Monoid] [eq #+ Eq] [order] ["M" monad #+ do Monad] -- cgit v1.2.3