~jojo/Carth

ref: ae1d242d7d48292779dcbd953e5864bb4211e1ca Carth/examples/list-monad.carth -rw-r--r-- 484 bytes
ae1d242dJoJo Update stackage release & use default-extensions in cabal file 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(import list)
(import io)

(define main
  (flip io/for (<o display show-triple)
        (list/iter (let1 ns (list 1 2 3 4 5 6 7 8 9)
                     (do list/bind
                         (<- x ns)
                         (<- y ns)
                         (<- z ns)
                         (list/when (=s x y z)
                                    (list [x y z])))))))

(define (show-triple [a b c])
  (apps str-append "[" (show-int a) " " (show-int b) " " (show-int c) "]"))