git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Add show instance for Array to prelude
b5d15c0Gary Burgess
prelude/prelude.purs+17−3
@@ -38,9 +38,9 @@ module Prelude where
38
38
39 (#) :: forall a b. a -> (a -> b) -> b
39 (#) :: forall a b. a -> (a -> b) -> b
40 (#) x f = f x
40 (#) x f = f x
41−
41+
42 infixr 6 :
42 infixr 6 :
43−
43+
44 (:) :: forall a. a -> [a] -> [a]
44 (:) :: forall a. a -> [a] -> [a]
45 (:) = cons
45 (:) = cons
46
46
@@ -73,6 +73,20 @@ module Prelude where
73 instance showNumber :: Show Number where
73 instance showNumber :: Show Number where
74 show = showNumberImpl
74 show = showNumberImpl
75
75
76+ foreign import showArrayImpl
77+ "function showArrayImpl (f) {\
78+ \ return function (xs) {\
79+ \ var ss = [];\
80+ \ for (var i = 0, l = xs.length; i < l; i++) {\
81+ \ ss[i] = f(xs[i]);\
82+ \ }\
83+ \ return '[' + ss.join(',') + ']';\
84+ \ };\
85+ \}" :: forall a. (a -> String) -> [a] -> String
86+
87+ instance showArray :: (Show a) => Show [a] where
88+ show = showArrayImpl show
89+
76 infixl 4 <$>
90 infixl 4 <$>
77
91
78 class Functor f where
92 class Functor f where
@@ -388,7 +402,7 @@ module Data.Eq where
388 instance eqRef :: Eq (Ref a) where
402 instance eqRef :: Eq (Ref a) where
389 (==) = liftRef refEq
403 (==) = liftRef refEq
390 (/=) = liftRef refIneq
404 (/=) = liftRef refIneq
391−
405+
392module Prelude.Unsafe where
406module Prelude.Unsafe where
393
407
394 foreign import unsafeIndex
408 foreign import unsafeIndex