diff options
author | LuxLang | 2015-10-01 12:50:27 -0400 |
---|---|---|
committer | LuxLang | 2015-10-01 12:50:27 -0400 |
commit | 3e2ce4d30fd457205b0d0268d870d47a8d1ec738 (patch) | |
tree | 580b42a5024c8767b2f2dd78a77a9911593acb77 /source/lux/codata/function.lux | |
parent | e543739f21e03be7cc0192bf510f350f7065bfa5 (diff) | |
parent | 6fcf9690f914e9b8b4f0ab767164bc97aeb12ca4 (diff) |
Merge pull request #12 from LuxLang/v0.3
V0.3
Diffstat (limited to '')
-rw-r--r-- | source/lux/codata/function.lux | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/lux/codata/function.lux b/source/lux/codata/function.lux new file mode 100644 index 000000000..1b7336049 --- /dev/null +++ b/source/lux/codata/function.lux @@ -0,0 +1,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 [x y] (f y x))) + +(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 ++ .)) |