aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/function.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/function.lux')
-rw-r--r--stdlib/source/lux/function.lux20
1 files changed, 20 insertions, 0 deletions
diff --git a/stdlib/source/lux/function.lux b/stdlib/source/lux/function.lux
new file mode 100644
index 000000000..cddf5d472
--- /dev/null
+++ b/stdlib/source/lux/function.lux
@@ -0,0 +1,20 @@
+(;module:
+ lux
+ (lux (control monoid)))
+
+## [Functions]
+(def: #export (const c)
+ {#;doc "Create constant functions."}
+ (All [a b] (-> a (-> b a)))
+ (lambda [_] c))
+
+(def: #export (flip f)
+ {#;doc "Flips the order of the arguments of a function."}
+ (All [a b c]
+ (-> (-> a b c) (-> b a c)))
+ (lambda [x y] (f y x)))
+
+## [Structures]
+(struct: #export Monoid<Function> (Monoid (All [a] (-> a a)))
+ (def: unit id)
+ (def: append .))