git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Move `Read` into its own module
b8a6b4cGary Burgess
prelude/prelude.purs+17−17
@@ -45,23 +45,6 @@ module Prelude where
45 instance showNumber :: Show Number where
45 instance showNumber :: Show Number where
46 show = showNumberImpl
46 show = showNumberImpl
47
47
48− class Read a where
49− read :: String -> a
50−
51− instance readString :: Read String where
52− read s = s
53−
54− instance readBoolean :: Read Boolean where
55− read "true" = true
56− read _ = false
57−
58− foreign import readNumberImpl "function readNumberImpl(n) {\
59− \ return parseFloat(n);\
60− \}" :: String -> Number
61−
62− instance readNumber :: Read Number where
63− read = readNumberImpl
64−
65 infixl 4 <$>
48 infixl 4 <$>
66
49
67 class Functor f where
50 class Functor f where
@@ -1207,3 +1190,20 @@ module Data.Enum where
1207 class Enum a where
1190 class Enum a where
1208 toEnum :: Number -> Maybe a
1191 toEnum :: Number -> Maybe a
1209 fromEnum :: a -> Number
1192 fromEnum :: a -> Number
1193+
1194+module Text.Parsing.Read where
1195+
1196+ class Read a where
1197+ read :: String -> a
1198+
1199+ instance readString :: Read String where
1200+ read s = s
1201+
1202+ instance readBoolean :: Read Boolean where
1203+ read "true" = true
1204+ read _ = false
1205+
1206+ foreign import readNumberImpl "var readNumberImpl = parseFloat;" :: String -> Number
1207+
1208+ instance readNumber :: Read Number where
1209+ read = readNumberImpl