blob: 15dc349ef22af2b9cbf8a2ffcdc1f207bc641590 (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
## 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/.
(;module:
lux
(lux (control monoid
eq
codec)
(codata function)))
## [Structures]
(struct: #export _ (Eq Bool)
(def: (= x y)
(if x
y
(not y))))
(do-template [<name> <unit> <op>]
[(struct: #export <name> (Monoid Bool)
(def: unit <unit>)
(def: (append x y)
(<op> x y)))]
[ Or@Monoid<Bool> false or]
[And@Monoid<Bool> true and]
)
(struct: #export _ (Codec Text Bool)
(def: (encode x)
(if x
"true"
"false"))
(def: (decode input)
(case input
"true" (#;Right true)
"false" (#;Right false)
_ (#;Left "Wrong syntax for Bool."))))
## [Values]
(def: #export complement
{#;doc "Generates the complement of a predicate.
That is a predicate that returns the oposite of the original predicate."}
(All [a] (-> (-> a Bool) (-> a Bool)))
(. not))
|