diff options
Diffstat (limited to 'stdlib/source/library/lux/data/product.lux')
-rw-r--r-- | stdlib/source/library/lux/data/product.lux | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/stdlib/source/library/lux/data/product.lux b/stdlib/source/library/lux/data/product.lux index aba9488bc..9a3bf40dc 100644 --- a/stdlib/source/library/lux/data/product.lux +++ b/stdlib/source/library/lux/data/product.lux @@ -6,21 +6,18 @@ [equivalence (#+ Equivalence)] [hash (#+ Hash)]]]]) -(template [<name> <doc>] - [(def: .public (<name> pair) - {#.doc (example <doc>)} +(template [<name>] + [(def: .public (<name> [left right]) (All [left right] (-> [left right] <name>)) - (let [[left right] pair] - <name>))] + <name>)] - [left "The left side of a pair."] - [right "The right side of a pair."] + [left] + [right] ) ... https://en.wikipedia.org/wiki/Currying (def: .public (curried f) - {#.doc (example "Converts a 2-argument function into nested single-argument functions.")} (All [a b c] (-> (-> [a b] c) (-> a b c))) @@ -28,7 +25,6 @@ (f [x y]))) (def: .public (uncurried f) - {#.doc (example "Converts nested single-argument functions into a 2-argument function.")} (All [a b c] (-> (-> a b c) (-> [a b] c))) @@ -36,13 +32,11 @@ (let [[x y] xy] (f x y)))) -(def: .public (swapped xy) - (All [a b] (-> [a b] [b a])) - (let [[x y] xy] - [y x])) +(def: .public (swapped [left right]) + (All [left right] (-> [left right] [right left])) + [right left]) (def: .public (then f g) - {#.doc (example "Apply functions to both sides of a pair.")} (All [a b c d] (-> (-> a c) (-> b d) (-> [a b] [c d]))) @@ -50,7 +44,6 @@ [(f x) (g y)])) (def: .public (forked f g) - {#.doc (example "Yields a pair by applying both functions to a single value.")} (All [a l r] (-> (-> a l) (-> a r) (-> a [l r]))) |