git.iko.soy/rowtype-yoga/purescript-native
on e82e607 help sign in
30 lines 600 B history raw
1module Main where
3import Prelude
5data Z
6data S n
8data Array n a = Array [a]
10nil :: forall a. Array Z a
11nil = Array []
13foreign import concat
14 "function concat(l1) {\
15 \ return function (l2) {\
16 \ return l1.concat(l2);\
17 \ };\
18 \}" :: forall a. [a] -> [a] -> [a]
20cons :: forall a n. a -> Array n a -> Array (S n) a
21cons x (Array xs) = Array $ concat [x] xs
23foreign import error
24 "function error(msg) {\
25 \ throw msg;\
26 \}" :: forall a. String -> a
28main = case cons 1 $ cons 2 $ cons 3 nil of
29 Array [1, 2, 3] -> Debug.Trace.trace "Done"
30 _ -> error "Failed"