git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Tests for where clauses
e63c2f6Gary Burgess
examples/passing/Where.pursnew file+49
@@ -0,0 +1,49 @@
1+module Main where
2+
3+import Prelude
4+import Control.Monad.Eff
5+import Control.Monad.ST
6+
7+test1 x = y
8+ where
9+ y :: Number
10+ y = x + 1
11+
12+test2 x y = x' + y'
13+ where
14+ x' = x + 1
15+ y' = y + 1
16+
17+
18+test3 = f 1 2 3
19+ where f x y z = x + y + z
20+
21+
22+test4 = f (+) [1, 2]
23+ where f x [y, z] = x y z
24+
25+
26+test5 = g 10
27+ where
28+ f x | x > 0 = g (x / 2) + 1
29+ f x = 0
30+ g x = f (x - 1) + 1
31+
32+test6 = if f true then f 1 else f 2
33+ where f :: forall a. a -> a
34+ f x = x
35+
36+test7 :: Number -> Number
37+test7 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
41+
42+main = do
43+ Debug.Trace.print (test1 1)
44+ Debug.Trace.print (test2 1 2)
45+ Debug.Trace.print test3
46+ Debug.Trace.print test4
47+ Debug.Trace.print test5
48+ Debug.Trace.print test6
49+ Debug.Trace.print (test7 100)