~jojo/Carth

ref: 36b6008c65cdf9373cbdd0a3b26fde6e68e79dd5 Carth/std/macros.carth -rw-r--r-- 522 bytes
36b6008cJoJo std: rename mod Memo back to Lazy & make Lazy thread safe 1 year, 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(defmacro apps
  (case (op x) x)
  (case (op x1 x2 xs ...) (apps op (op x1 x2) xs ...)))

(defmacro appsr
  (case (op x) x)
  (case (op x xs ...) (op x (appsr op xs ...))))

(defmacro list
  (case (xs ...) (appsr list/cons xs ... Nil)))

(defmacro +s (case (xs ...) (apps + xs ...)))

(defmacro io/wrap
  (case (computation) (IO (fun (real-world) [computation real-world]))))

(defmacro lazy
  (case (computation) (Lazy [(unsafe-perform-io mutex/new)
                             (box (Left (fun (Unit) computation)))])))