git.iko.soy/rowtype-yoga/purescript-native
on e82e607 help sign in
64 lines 1.2 kB history raw
1module Main where
3import Prelude
4import Control.Monad.Eff
5import Control.Monad.ST
7test1 x = let
8 y :: Number
9 y = x + 1
10 in y
12test2 x y =
13 let x' = x + 1 in
14 let y' = y + 1 in
15 x' + y'
17test3 = let f x y z = x + y + z in
18 f 1 2 3
20test4 = let f x [y, z] = x y z in
21 f (+) [1, 2]
23test5 = let
24 f x | x > 0 = g (x / 2) + 1
25 f x = 0
26 g x = f (x - 1) + 1
27 in f 10
29test6 = runPure (runST (do
30 r <- newSTRef 0
31 (let
32 go [] = readSTRef r
33 go (n : ns) = do
34 modifySTRef r ((+) n)
35 go ns
36 in go [1, 2, 3, 4, 5])
37 ))
39test7 = let
40 f :: forall a. a -> a
41 f x = x
42 in if f true then f 1 else f 2
44test8 :: Number -> Number
45test8 x = let
46 go y | (x - 0.1 < y * y) && (y * y < x + 0.1) = y
47 go y = go $ (y + x / y) / 2
48 in go x
50test10 _ =
51 let
52 f x = g x * 3
53 g x = f x / 2
54 in f 10
56main = do
57 Debug.Trace.print (test1 1)
58 Debug.Trace.print (test2 1 2)
59 Debug.Trace.print test3
60 Debug.Trace.print test4
61 Debug.Trace.print test5
62 Debug.Trace.print test6
63 Debug.Trace.print test7
64 Debug.Trace.print (test8 100)