-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdo-syntax.lisp
More file actions
32 lines (24 loc) · 838 Bytes
/
do-syntax.lisp
File metadata and controls
32 lines (24 loc) · 838 Bytes
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
(eval-when (:compile-toplevel :load-toplevel :execute)
(ql:quickload 'trivia)
(use-package 'g)
(use-package 'trivia))
(defmacro do! (&body args)
(match args
((cons (list '<- var bind) rest) `(>>= ,bind (lambda (,var) (do! ,@rest))))
((cons x 'nil) x)
((cons x rest) `(>> ,x (do! ,@rest)))))
(time (funcall
(state-run
(do! ;; (state-3-add-x 10)
(<- y (state-3-add-x 10))
(<- x sget)
(spure (+ x y))))
3))
(do! ;; (state-3-add-x 10)
(<- y (state-3-add-x 10))
(<- x sget)
(spure (+ x y)))
(time (funcall (state-run (fmap (lambda (x) (+ x 50)) sget)) 10))
(time (funcall (state-run (fmap (lambda (x) (+ x 50)) sget)) 10))
(time (funcall (state-run (do! (<- x sget) (spure (+ x 50)))) 10))
(time (funcall (state-run (do! (<- x sget) (spure (+ x 50)))) 10))