1module Main where
2
3import Prelude
4import Partial.Unsafe (unsafePartial)
5import Effect
6import Effect.Console (logShow, log)
7
8test1 x = y
9  where
10  y :: Number
11  y = x + 1.0
12
13test2 x y = x' + y'
14  where
15  x' = x + 1.0
16  y' = y + 1.0
17
18test3 = f 1.0 2.0 3.0
19  where f x y z = x + y + z
20
21test4 = f (+) [1.0, 2.0]
22  where f x [y, z] = x y z
23
24test5 = g 10.0
25  where
26  f x | x > 0.0 = g (x / 2.0) + 1.0
27  f x = 0.0
28  g x = f (x - 1.0) + 1.0
29
30test6 = if f true then f 1.0 else f 2.0
31  where f :: forall a. a -> a
32        f x = x
33
34test7 :: Number -> Number
35test7 x = go x
36  where
37  go y | (x - 0.1 < y * y) && (y * y < x + 0.1) = y
38  go y = go $ (y + x / y) / 2.0
39
40main :: Effect _
41main = do
42  logShow (test1 1.0)
43  logShow (test2 1.0 2.0)
44  logShow test3
45  unsafePartial (logShow test4)
46  logShow test5
47  logShow test6
48  logShow (test7 100.0)
49  log "Done"
50