git.iko.soy/rowtype-yoga/purescript-native
on 4e326f9 help sign in
95 lines 1.7 kB history raw
1module Main where
3import Prelude
4import Control.Monad.Eff
5import Control.Monad.Eff.Console
7op1 :: forall a. a -> a -> a
8op1 x _ = x
10infix 4 op1 as ?!
12bar :: String -> String -> String
13bar = \s1 s2 -> s1 <> s2
15test1 :: forall n. (Semiring n) => n -> n -> (n -> n -> n) -> n
16test1 x y z = x * y + z x y
18test2 = (\x -> x.foo false) { foo : \_ -> 1.0 }
20test3 = (\x y -> x)(1.0 + 2.0 * (1.0 + 2.0)) (true && (false || false))
22k = \x -> \y -> x
24test4 = 1 `k` 2
26op2 :: Number -> Number -> Number
27op2 x y = x * y + y
29infixl 5 op2 as %%
31test5 = 1.0 %% 2.0 %% 3.0
33test6 = ((\x -> x) `k` 2.0) 3.0
35op3 :: String -> String -> String
36op3 = \s1 s2 -> s1 <> s2
38infix 4 op3 as <+>
40test7 = "Hello" <+> "World!"
42op4 :: forall a b. (a -> b) -> a -> b
43op4 = \f x -> f x
45infix 4 op4 as @@
47foo :: String -> String
48foo = \s -> s
50test8 = foo @@ "Hello World"
52test9 = Main.foo @@ "Hello World"
54test10 = "Hello" `Main.bar` "World"
56op5 :: forall a. Array a -> Array a -> Array a
57op5 = \as -> \bs -> as
59infix 4 op5 as ...
61test11 = [1.0, 2.0, 0.0] ... [4.0, 5.0, 6.0]
63test14 :: Number -> Number -> Boolean
64test14 a b = a < b
66test15 :: Number -> Number -> Boolean
67test15 a b = const false $ a `test14` b
69test17 :: Number
70test17 = negate (-1.0)
72test18 :: Number
73test18 = negate $ negate 1.0
75test19 :: Number
76test19 = negate $ negate (-1.0)
78main = do
79 let t1 = test1 1.0 2.0 (\x y -> x + y)
80 let t2 = test2
81 let t3 = test3
82 let t4 = test4
83 let t5 = test5
84 let t6 = test6
85 let t7 = test7
86 let t8 = test8
87 let t9 = test9
88 let t10 = test10
89 let t11 = test11
90 let t14 = test14 1.0 2.0
91 let t15 = test15 1.0 2.0
92 let t17 = test17
93 let t18 = test18
94 let t19 = test19
95 log "Done"