blob: dde38cc0c38b402e3615bf11a3b700716cbf0333 (
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
48
49
|
Scheme Monads
=============
In an attempt to understand how Monads in Haskell actually works I set out to
reimplement them myself in scheme.
Examples
--------
(use-modules (monad)
(monad state))
(run-state (do x <- (<$> sqrt (get))
let y = (+ x 10)
(put y)
(return-state x))
64)
;; => (8 18)
(>> (just 1)
(just 2))
;; => [Just 2]
Unfortunately, it doesn't really short circuit as one would have hoped:
(>> (nothing) (just (/ 1 0)))
<unnamed port>:1520:36: Throw to key `numerical-overflow' with args `("/"
"Numerical overflow" #f #f)'.
Usage
-----
The module `(monad)` contains all base bindings, allowing usage of the monad
system. The modules `(monad *)` contains different data types, including
optional, stacks, and more.
Documentation
-------------
Documentation can be build with
make doc
It however doesn't work to well, since the `(texinfo reflection)` modules is
less than perfect.
Tests & Examples
----------------
`tests/test.scm` contains a few tests and examples of how to use the code.
|