aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/codata/function.lux
blob: cddf5d472b1c6060aa32cc8cc88997c8ae3a82c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 .))