git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Change record field separator to a comma
b29be8ePhil Freeman
README.md+3−6
@@ -57,10 +57,7 @@ PureScript can also be seen as a trade-off between a theoretically ideal languag
57The following code defines a `Person` data type and a function to generate a string representation for a `Person`:
57The following code defines a `Person` data type and a function to generate a string representation for a `Person`:
58
58
59```haskell
59```haskell
60−data Person = Person
60+data Person = Person { name :: String, age :: Number }
61− { name :: String
62− ; age :: Number
63− }
64
61
65extern numberToString :: Number -> String
62extern numberToString :: Number -> String
66
63
@@ -104,7 +101,7 @@ The type system defines the following types:
104- Arrays
101- Arrays
105 - E.g. `[String]`, `[[Number]]`
102 - E.g. `[String]`, `[[Number]]`
106- Records
103- Records
107− - E.g. `{ foo :: String ; bar :: Number }`
104+ - E.g. `{ foo :: String, bar :: Number }`
108- Tagged Unions
105- Tagged Unions
109 - E.g. `data Foo a = Foo | Bar String`
106 - E.g. `data Foo a = Foo | Bar String`
110- Functions
107- Functions
@@ -237,7 +234,7 @@ Functions may also be polymorphic in row types or type variables with other kind
237addProps = \o -> o.foo + o.bar
234addProps = \o -> o.foo + o.bar
238```
235```
239
236
240−Here, `addProps` is inferred to have type `forall r. { foo :: Number; bar :: Number | r } -> Number`. That is, it can take any type which has properties `Foo` and `Bar`, and *any other record properties*.
237+Here, `addProps` is inferred to have type `forall r. { foo :: Number, bar :: Number | r } -> Number`. That is, it can take any type which has properties `Foo` and `Bar`, and *any other record properties*.
241
238
242So, the following compiles:
239So, the following compiles:
243
240
examples/passing/List.ps+1−1
@@ -2,7 +2,7 @@ data List a
2 = Nil
2 = Nil
3 | Cons
3 | Cons
4 { head :: a
4 { head :: a
5− ; tail :: List a
5+ , tail :: List a
6 }
6 }
7
7
8isNull = \l -> case l of
8isNull = \l -> case l of
examples/passing/Nested.ps+1−1
@@ -1,3 +1,3 @@
1−data Extend r a = Extend { prev :: r a; next :: a }
1+data Extend r a = Extend { prev :: r a, next :: a }
2
2
3data Matrix r a = Square (r (r a)) | Bigger (Matrix (Extend r) a)
3data Matrix r a = Square (r (r a)) | Bigger (Matrix (Extend r) a)
examples/passing/Person.ps+1−1
@@ -1,4 +1,4 @@
1−data Person = Person { name :: String; age :: Number }
1+data Person = Person { name :: String, age :: Number }
2
2
3extern itoa :: Number -> String
3extern itoa :: Number -> String
4
4
examples/passing/TypeSynonyms.ps+2−2
@@ -1,6 +1,6 @@
1type Lens a b =
1type Lens a b =
2 { get :: a -> b
2 { get :: a -> b
3− ; set :: a -> b -> a
3+ , set :: a -> b -> a
4 }
4 }
5
5
6composeLenses :: forall a b c. Lens a b -> Lens b c -> Lens a c
6composeLenses :: forall a b c. Lens a b -> Lens b c -> Lens a c
@@ -12,7 +12,7 @@ composeLenses = \l1 -> \l2 ->
12 return l1.set a b1
12 return l1.set a b1
13 }
13 }
14
14
15−type Pair a b = { fst :: a; snd :: b }
15+type Pair a b = { fst :: a, snd :: b }
16
16
17fst :: forall a b. Lens (Pair a b) a
17fst :: forall a b. Lens (Pair a b) a
18fst = {
18fst = {
libraries/prelude/prelude.ps+17−17
@@ -143,7 +143,7 @@ all = \p -> \as -> do
143
143
144-- Pairs
144-- Pairs
145
145
146−type Tuple a b = { fst :: a ; snd :: b }
146+type Tuple a b = { fst :: a, snd :: b }
147
147
148curry :: forall a b c. (Tuple a b -> c) -> a -> b -> c
148curry :: forall a b c. (Tuple a b -> c) -> a -> b -> c
149curry = \f -> \a -> \b -> f { fst: a, snd: b }
149curry = \f -> \a -> \b -> f { fst: a, snd: b }
@@ -239,22 +239,22 @@ extern decodeURI :: String -> String
239
239
240type Math =
240type Math =
241 { abs :: Number -> Number
241 { abs :: Number -> Number
242− ; acos :: Number -> Number
242+ , acos :: Number -> Number
243− ; asin :: Number -> Number
243+ , asin :: Number -> Number
244− ; atan :: Number -> Number
244+ , atan :: Number -> Number
245− ; atan2 :: (Number, Number) -> Number
245+ , atan2 :: (Number, Number) -> Number
246− ; aceil :: Number -> Number
246+ , aceil :: Number -> Number
247− ; cos :: Number -> Number
247+ , cos :: Number -> Number
248− ; exp :: Number -> Number
248+ , exp :: Number -> Number
249− ; floor :: Number -> Number
249+ , floor :: Number -> Number
250− ; log :: Number -> Number
250+ , log :: Number -> Number
251− ; max :: (Number, Number) -> Number
251+ , max :: (Number, Number) -> Number
252− ; pow :: (Number, Number) -> Number
252+ , pow :: (Number, Number) -> Number
253− ; random :: () -> Number
253+ , random :: () -> Number
254− ; round :: Number -> Number
254+ , round :: Number -> Number
255− ; sin :: Number -> Number
255+ , sin :: Number -> Number
256− ; sqrt :: Number -> Number
256+ , sqrt :: Number -> Number
257− ; tan :: Number -> Number
257+ , tan :: Number -> Number
258 }
258 }
259
259
260extern math :: Math
260extern math :: Math
src/Language/PureScript/Parser/Types.hs+1−1
@@ -84,7 +84,7 @@ parseRowEnding :: P.Parsec String ParseState Row
84parseRowEnding = P.option REmpty (RowVar <$> (lexeme (indented *> P.char '|') *> indented *> identifier))
84parseRowEnding = P.option REmpty (RowVar <$> (lexeme (indented *> P.char '|') *> indented *> identifier))
85
85
86parseRow :: P.Parsec String ParseState Row
86parseRow :: P.Parsec String ParseState Row
87−parseRow = (fromList <$> (parseNameAndType `P.sepBy` (indented *> semi)) <*> parseRowEnding) P.<?> "row"
87+parseRow = (fromList <$> (parseNameAndType `P.sepBy` (indented *> comma)) <*> parseRowEnding) P.<?> "row"
88 where
88 where
89 fromList :: [(String, Type)] -> Row -> Row
89 fromList :: [(String, Type)] -> Row -> Row
90 fromList [] r = r
90 fromList [] r = r
src/Language/PureScript/Pretty/Types.hs+1−1
@@ -47,7 +47,7 @@ typeLiterals = Pattern $ A.Kleisli match
47 match _ = Nothing
47 match _ = Nothing
48
48
49prettyPrintRow :: Row -> String
49prettyPrintRow :: Row -> String
50−prettyPrintRow = (\(tys, tail) -> intercalate "; " (map (uncurry nameAndTypeToPs) tys) ++ tailToPs tail) . toList []
50+prettyPrintRow = (\(tys, tail) -> intercalate ", " (map (uncurry nameAndTypeToPs) tys) ++ tailToPs tail) . toList []
51 where
51 where
52 nameAndTypeToPs :: String -> Type -> String
52 nameAndTypeToPs :: String -> Type -> String
53 nameAndTypeToPs name ty = name ++ " :: " ++ prettyPrintType ty
53 nameAndTypeToPs name ty = name ++ " :: " ++ prettyPrintType ty