blob: 3ad6b056bdbcf151fd10929ff42963e9047c334b (
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
28
29
30
31
32
|
## Copyright (c) Eduardo Julian. All rights reserved.
## The use and distribution terms for this software are covered by the
## Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
## which can be found in the file epl-v10.html at the root of this distribution.
## By using this software in any fashion, you are agreeing to be bound by
## the terms of this license.
## You must not remove this notice, or any other, from this software.
(;import lux
(lux/control (functor #as F #refer #all)
(monad #as M #refer #all)
(comonad #as CM #refer #all)))
## [Types]
(deftype #export (Id a)
(| (#Id a)))
## [Structures]
(defstruct #export Id/Functor (Functor Id)
(def (F;map f fa)
(let [(#Id a) fa]
(#Id (f a)))))
(defstruct #export Id/Monad (Monad Id)
(def M;_functor Id/Functor)
(def (M;wrap a) (#Id a))
(def (M;join mma) (let [(#Id ma) mma] ma)))
(defstruct #export Id/CoMonad (CoMonad Id)
(def CM;_functor Id/Functor)
(def (CM;unwrap wa) (let [(#Id a) wa] a))
(def (CM;split wa) (#Id wa)))
|