git.iko.soy/rowtype-yoga/purescript-native
on 24fdff2 help sign in
49 lines 932 B history raw
1module Main where
3import Prelude
4import Control.Monad.Eff
5import Control.Monad.ST
7test1 x = y
8 where
9 y :: Number
10 y = x + 1.0
12test2 x y = x' + y'
13 where
14 x' = x + 1.0
15 y' = y + 1.0
18test3 = f 1.0 2.0 3.0
19 where f x y z = x + y + z
22test4 = f (+) [1.0, 2.0]
23 where f x [y, z] = x y z
26test5 = g 10.0
27 where
28 f x | x > 0.0 = g (x / 2.0) + 1.0
29 f x = 0.0
30 g x = f (x - 1.0) + 1.0
32test6 = if f true then f 1.0 else f 2.0
33 where f :: forall a. a -> a
34 f x = x
36test7 :: Number -> Number
37test7 x = go x
38 where
39 go y | (x - 0.1 < y * y) && (y * y < x + 0.1) = y
40 go y = go $ (y + x / y) / 2.0
42main = do
43 Control.Monad.Eff.Console.print (test1 1.0)
44 Control.Monad.Eff.Console.print (test2 1.0 2.0)
45 Control.Monad.Eff.Console.print test3
46 Control.Monad.Eff.Console.print test4
47 Control.Monad.Eff.Console.print test5
48 Control.Monad.Eff.Console.print test6
49 Control.Monad.Eff.Console.print (test7 100.0)