aboutsummaryrefslogtreecommitdiff
path: root/source/lux/codata/function.lux
blob: a23e969b3d3f3eb4d488a87bf59c769706715b8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
##  Copyright (c) Eduardo Julian. All rights reserved.
##  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
##  If a copy of the MPL was not distributed with this file,
##  You can obtain one at http://mozilla.org/MPL/2.0/.

(;import lux
         (lux/control (monoid #as m)))

## [Functions]
(def #export (const x y)
  (All [a b] (-> a (-> b a)))
  x)

(def #export (flip f)
  (All [a b c]
    (-> (-> a b c) (-> b a c)))
  (lambda [y x] (f x y)))

(def #export (. f g)
  (All [a b c]
    (-> (-> b c) (-> a b) (-> a c)))
  (lambda [x] (f (g x))))

## [Structures]
(defstruct #export Comp/Monoid (All [a] (m;Monoid (-> a a)))
  (def unit id)
  (def ++ .))