aboutsummaryrefslogtreecommitdiffhomepage
path: root/samples/fun/deepthought_state.bruijn
blob: 5f5cb363979db6a6967b291a88ef7e30af92e419 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# state monad example: logger/writer

:import std/Combinator .
:import std/List .
:import std/Number .
:import std/Monad/State .

log [[[[0 (1 ++ 2) 3]]]]

deepthought answer >>= [correct >>= [check >>= [return]]]
	answer log (+42) "Finding answer... "
	correct log (0 =? (+42)) "Checking answer... "
	check 0 (log [[0]] "Is correct!") (log [[0]] "Is false!")
	return pure 2

:test (deepthought [[0]]) ([0 (+42) "Finding answer... Checking answer... Is correct!"])

main [deepthought [[0]] [[0]]]