blob: 537382213ebfc70a2faabf3684a9f13eb39202d5 (
plain) (
blame)
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
|
# MIT License, Copyright (c) 2024 Marvin Borner
# for now, monads, functors, applicative, etc are all in here..
# TODO: more monad interface
:import std/List L
liftA map ⧗ (a → b) → (M a) → (M b)
liftA2 ap ∘∘ map ⧗ (a → b → c) → (M a) → (M b) → (M c)
liftA3 [[[[(liftA2 3 2 1) <*> 0]]]] ⧗ (a → b → c → d) → (M a) → (M b) → (M c) → (M d)
…<$… map ∘ k ⧗ a → (M b) → (M a)
…*>… [[(i <$ 1) <*> 0]] ⧗ (M a) → (M b) → (M b)
…<*… liftA2 k ⧗ (M a) → (M b) → (M a)
…=<<… \bind
…>>… [[1 >>= [1]]] ⧗ (M a) → (M b) → (M b)
# TODO: traverse, sequence
# in parser: string = traverse char!
some [y [liftA2 L.cons 1 many]] ⧗ (M a) → (M (List a))
many 0 <|> (pure L.empty)
many [y [some <|> (pure L.empty)]] ⧗ (M a) → (M (List a))
some liftA2 L.cons 1 0
between [[[2 *> 0 <* 1]]] ⧗ (M a) → (M a) → (M a) → (M a)
|