git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Update Prelude
8f956e0Phil Freeman
examples/passing/Operators.purs+2
@@ -3,6 +3,7 @@ module Main where
3 import Control.Monad.Eff
3 import Control.Monad.Eff
4 import Debug.Trace
4 import Debug.Trace
5
5
6+ bar :: String -> String -> String
6 bar = \s1 s2 -> s1 ++ s2
7 bar = \s1 s2 -> s1 ++ s2
7
8
8 test1 :: forall n. (Num n) => n -> n -> (n -> n -> n) -> n
9 test1 :: forall n. (Num n) => n -> n -> (n -> n -> n) -> n
@@ -25,6 +26,7 @@ module Main where
25
26
26 test6 = ((\x -> x) `k` 2) 3
27 test6 = ((\x -> x) `k` 2) 3
27
28
29+ (<>) :: String -> String -> String
28 (<>) = \s1 s2 -> s1 ++ s2
30 (<>) = \s1 s2 -> s1 ++ s2
29
31
30 test7 = "Hello" <> "World!"
32 test7 = "Hello" <> "World!"
prelude/prelude.purs+16−9
@@ -8,7 +8,7 @@ module Prelude where
8
8
9 on :: forall a b c. (b -> b -> c) -> (a -> b) -> a -> a -> c
9 on :: forall a b c. (b -> b -> c) -> (a -> b) -> a -> a -> c
10 on f g x y = g x `f` g y
10 on f g x y = g x `f` g y
11−
11+
12 asTypeOf :: forall a. a -> a -> a
12 asTypeOf :: forall a. a -> a -> a
13 asTypeOf x _ = x
13 asTypeOf x _ = x
14
14
@@ -59,7 +59,7 @@ module Prelude where
59
59
60 infixl 4 <*>
60 infixl 4 <*>
61
61
62− class Applicative f where
62+ class (Functor f) <= Applicative f where
63 pure :: forall a. a -> f a
63 pure :: forall a. a -> f a
64 (<*>) :: forall a b. f (a -> b) -> f a -> f b
64 (<*>) :: forall a b. f (a -> b) -> f a -> f b
65
65
@@ -74,7 +74,7 @@ module Prelude where
74
74
75 infixl 1 >>=
75 infixl 1 >>=
76
76
77− class Monad m where
77+ class (Applicative m) <= Monad m where
78 return :: forall a. a -> m a
78 return :: forall a. a -> m a
79 (>>=) :: forall a b. m a -> (a -> m b) -> m b
79 (>>=) :: forall a b. m a -> (a -> m b) -> m b
80
80
@@ -192,7 +192,7 @@ module Prelude where
192 show GT = "GT"
192 show GT = "GT"
193 show EQ = "EQ"
193 show EQ = "EQ"
194
194
195− class Ord a where
195+ class (Eq a) <= Ord a where
196 compare :: a -> a -> Ordering
196 compare :: a -> a -> Ordering
197
197
198 infixl 4 <
198 infixl 4 <
@@ -334,11 +334,18 @@ module Prelude where
334
334
335 infixr 5 ++
335 infixr 5 ++
336
336
337+ class Semigroup a where
338+ (++) :: a -> a -> a
339+
337− foreign import (++) "function $plus$plus(s1) {\
340+ foreign import concatString
341+ "function concatString(s1) {\
338− \ return function(s2) {\
342+ \ return function(s2) {\
339− \ return s1 + s2;\
343+ \ return s1 + s2;\
340− \ };\
344+ \ };\
341− \}" :: String -> String -> String
345+ \}" :: String -> String -> String
346+
347+ instance semigroupString :: Semigroup String where
348+ (++) = concatString
342
349
343module Data.Eq where
350module Data.Eq where
344
351
src/Language/PureScript/Constants.hs+3
@@ -167,6 +167,9 @@ bitsNumber = "bitsNumber"
167boolLikeBoolean :: String
167boolLikeBoolean :: String
168boolLikeBoolean = "boolLikeBoolean"
168boolLikeBoolean = "boolLikeBoolean"
169
169
170+semigroupString :: String
171+semigroupString = "semigroupString"
172+
170-- Main module
173-- Main module
171
174
172main :: String
175main :: String
src/Language/PureScript/Optimizer.hs−1
@@ -66,7 +66,6 @@ optimize opts | optionsNoOptimizations opts = id
66 , inlineOperator (C.$) $ \f x -> JSApp f [x]
66 , inlineOperator (C.$) $ \f x -> JSApp f [x]
67 , inlineOperator (C.#) $ \x f -> JSApp f [x]
67 , inlineOperator (C.#) $ \x f -> JSApp f [x]
68 , inlineOperator (C.!!) $ flip JSIndexer
68 , inlineOperator (C.!!) $ flip JSIndexer
69− , inlineOperator (C.++) $ JSBinary Add
70 , inlineCommonOperators ])
69 , inlineCommonOperators ])
71
70
72untilFixedPoint :: (Eq a) => (a -> a) -> a -> a
71untilFixedPoint :: (Eq a) => (a -> a) -> a -> a
src/Language/PureScript/Optimizer/Inliner.hs+2
@@ -110,6 +110,8 @@ inlineCommonOperators = applyAll
110 , binary C.eqBoolean (C.==) EqualTo
110 , binary C.eqBoolean (C.==) EqualTo
111 , binary C.eqBoolean (C./=) NotEqualTo
111 , binary C.eqBoolean (C./=) NotEqualTo
112
112
113+ , binary C.semigroupString (C.++) Add
114+
113 , binaryFunction C.bitsNumber C.shl ShiftLeft
115 , binaryFunction C.bitsNumber C.shl ShiftLeft
114 , binaryFunction C.bitsNumber C.shr ShiftRight
116 , binaryFunction C.bitsNumber C.shr ShiftRight
115 , binaryFunction C.bitsNumber C.zshr ZeroFillShiftRight
117 , binaryFunction C.bitsNumber C.zshr ZeroFillShiftRight