git.iko.soy/rowtype-yoga/purescript-native
on 1efe77b help sign in
90 lines 1.7 kB history raw
1module Operators1 where
3 import Prelude ((++))
5 (@@) :: forall a b. (a -> b) -> a -> b
6 (@@) = \f x -> f x
8 foo :: String -> String
9 foo = \s -> s
11 test8 = foo @@ "Hello World"
13 bar = \s1 s2 -> s1 ++ s2
15module Operators2 where
17 import Prelude
18 import Operators1 ((@@))
20 test1 :: forall n. (Num n) => n -> n -> (n -> n -> n) -> n
21 test1 x y z = x * y + z x y
23 test2 = (\x -> x.foo false) { foo : \_ -> 1 }
25 test3 = (\x y -> x)(1 + 2 * (1 + 2)) (true && (false || false))
27 k = \x -> \y -> x
29 test4 = 1 `k` 2
31 infixl 5 %%
33 (%%) :: Number -> Number -> Number
34 (%%) x y = x * y + y
36 test5 = 1 %% 2 %% 3
38 test6 = ((\x -> x) `k` 2) 3
40 (<>) = \s1 s2 -> s1 ++ s2
42 test7 = "Hello" <> "World!"
44 test9 = Operators1.foo @@ "Hello World"
46 test10 = "Hello" `Operators1.bar` "World"
48 (...) :: forall a. [a] -> [a] -> [a]
49 (...) = \as -> \bs -> as
51 test11 = [1, 2, 3] ... [4, 5, 6]
53 test12 (<%>) a b = a <%> b
55 test13 = \(<%>) a b -> a <%> b
57 test14 :: Number -> Number -> Boolean
58 test14 a b = a < b
60 test15 :: Number -> Number -> Boolean
61 test15 a b = const false $ a `test14` b
63module Main where
65import Operators1
66import Operators2
68import Prelude
69import Control.Monad.Eff
70import Debug.Trace
71import Global
72import Data.Array
74main =
75 print [ show $ test1 1 2 $ \x y -> x + y
76 , show test2
77 , show test3
78 , show test4
79 , show test5
80 , show test6
81 , show test7
82 , show test8
83 , show test9
84 , show test10
85 , show test11
86 , show (test12 k 1 2)
87 , show (test13 k 1 2)
88 , show (test14 1 2)
89 , show (test15 1 2)
90 ]