blob: 56b3e0286a026b9918a59ad98a9127b9370f926f (
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
|
## 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 #refer (#exclude Reader))
(lux/control (functor #as F #refer #all)
(monad #as M #refer #all)))
## [Types]
(deftype #export (Reader r a)
(-> r a))
## [Structures]
(defstruct #export Reader/Functor (All [r]
(Functor (Reader r)))
(def (F;map f fa)
(lambda [env]
(f (fa env)))))
(defstruct #export Reader/Monad (All [r]
(Monad (Reader r)))
(def M;_functor Reader/Functor)
(def (M;wrap x)
(lambda [env] x))
(def (M;join mma)
(lambda [env]
(mma env env))))
|