Skip to content

Commit e11cff5

Browse files
committed
Rename Prim.Object to Prim.Record, fix purescript#1768 (purescript#2102)
* Rename Prim.Object to Prim.Record, fix purescript#1768 * Fix some comments
1 parent 10f76a7 commit e11cff5

File tree

12 files changed

+39
-39
lines changed

12 files changed

+39
-39
lines changed

examples/passing/LiberalTypeSynonyms.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ foo s = s
99

1010
type AndFoo r = (foo :: String | r)
1111

12-
getFoo :: forall r. Prim.Object (AndFoo r) -> String
12+
getFoo :: forall r. Prim.Record (AndFoo r) -> String
1313
getFoo o = o.foo
1414

1515
type F r = { | r } -> { | r }

examples/passing/NewtypeWithRecordUpdate.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ module Main where
55
import Prelude
66
import Control.Monad.Eff.Console
77

8-
newtype NewType a = NewType (Object a)
8+
newtype NewType a = NewType (Record a)
99

10-
rec1 :: Object (a :: Number, b :: Number, c:: Number)
10+
rec1 :: Record (a :: Number, b :: Number, c:: Number)
1111
rec1 = { a: 0.0, b: 0.0, c: 0.0 }
1212

1313
rec2 :: NewType (a :: Number, b :: Number, c :: Number)

examples/passing/RowConstructors.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ foo = { x: 0.0, y: 0.0, z: 0.0 }
1212
bar :: { | Bar }
1313
bar = { x: 0.0, y: 0.0, z: 0.0 }
1414

15-
id' :: Object Foo -> Object Bar
15+
id' :: Record Foo -> Record Bar
1616
id' = id
1717

1818
foo' :: { | Foo }

src/Language/PureScript/AST/Declarations.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ data Expr
351351
--
352352
| Parens Expr
353353
-- |
354-
-- An object property getter (e.g. `_.x`). This will be removed during
355-
-- desugaring and expanded into a lambda that reads a property from an object.
354+
-- A record property getter (e.g. `_.x`). This will be removed during
355+
-- desugaring and expanded into a lambda that reads a property from a record.
356356
--
357357
| ObjectGetter String
358358
-- |

src/Language/PureScript/Docs/RenderedCode/Render.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ dePrim other = other
159159

160160
convert :: RenderTypeOptions -> Type -> Type
161161
convert _ (TypeApp (TypeApp f arg) ret) | f == tyFunction = PrettyPrintFunction arg ret
162-
convert opts (TypeApp o r) | o == tyObject && prettyPrintObjects opts = PrettyPrintObject r
162+
convert opts (TypeApp o r) | o == tyRecord && prettyPrintObjects opts = PrettyPrintObject r
163163
convert _ other = other
164164

165165
convertForAlls :: Type -> Type

src/Language/PureScript/Environment.hs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,16 @@ tyArray :: Type
196196
tyArray = primTy "Array"
197197

198198
-- |
199-
-- Type constructor for objects
199+
-- Type constructor for records
200200
--
201-
tyObject :: Type
202-
tyObject = primTy "Object"
201+
tyRecord :: Type
202+
tyRecord = primTy "Record"
203203

204204
-- |
205-
-- Check whether a type is an object
205+
-- Check whether a type is a record
206206
--
207207
isObject :: Type -> Bool
208-
isObject = isTypeOrApplied tyObject
208+
isObject = isTypeOrApplied tyRecord
209209

210210
-- |
211211
-- Check whether a type is a function
@@ -232,14 +232,14 @@ primTypes :: M.Map (Qualified (ProperName 'TypeName)) (Kind, TypeKind)
232232
primTypes =
233233
M.fromList
234234
[ (primName "Function", (FunKind Star (FunKind Star Star), ExternData))
235-
, (primName "Array", (FunKind Star Star, ExternData))
236-
, (primName "Object", (FunKind (Row Star) Star, ExternData))
237-
, (primName "String", (Star, ExternData))
238-
, (primName "Char", (Star, ExternData))
239-
, (primName "Number", (Star, ExternData))
240-
, (primName "Int", (Star, ExternData))
241-
, (primName "Boolean", (Star, ExternData))
242-
, (primName "Partial", (Star, ExternData))
235+
, (primName "Array", (FunKind Star Star, ExternData))
236+
, (primName "Record", (FunKind (Row Star) Star, ExternData))
237+
, (primName "String", (Star, ExternData))
238+
, (primName "Char", (Star, ExternData))
239+
, (primName "Number", (Star, ExternData))
240+
, (primName "Int", (Star, ExternData))
241+
, (primName "Boolean", (Star, ExternData))
242+
, (primName "Partial", (Star, ExternData))
243243
]
244244

245245
-- |

src/Language/PureScript/Parser/Types.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ parseFunction :: TokenParser Type
2525
parseFunction = parens rarrow >> return tyFunction
2626

2727
parseObject :: TokenParser Type
28-
parseObject = braces $ TypeApp tyObject <$> parseRow
28+
parseObject = braces $ TypeApp tyRecord <$> parseRow
2929

3030
parseTypeWildcard :: TokenParser Type
3131
parseTypeWildcard = do

src/Language/PureScript/Pretty/Types.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ insertPlaceholders :: Type -> Type
9999
insertPlaceholders = everywhereOnTypesTopDown convertForAlls . everywhereOnTypes convert
100100
where
101101
convert (TypeApp (TypeApp f arg) ret) | f == tyFunction = PrettyPrintFunction arg ret
102-
convert (TypeApp o r) | o == tyObject = PrettyPrintObject r
102+
convert (TypeApp o r) | o == tyRecord = PrettyPrintObject r
103103
convert other = other
104104
convertForAlls (ForAll ident ty _) = go [ident] ty
105105
where

src/Language/PureScript/Sugar/TypeClasses.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ typeClassDictionaryDeclaration name args implies members =
233233
]
234234
members' = map (first runIdent . memberToNameAndType) members
235235
mtys = members' ++ superclassTypes
236-
in TypeSynonymDeclaration (coerceProperName name) args (TypeApp tyObject $ rowFromList (mtys, REmpty))
236+
in TypeSynonymDeclaration (coerceProperName name) args (TypeApp tyRecord $ rowFromList (mtys, REmpty))
237237

238238
typeClassMemberToDictionaryAccessor
239239
:: ModuleName
@@ -251,7 +251,7 @@ typeClassMemberToDictionaryAccessor mn name args (PositionedDeclaration pos com
251251
typeClassMemberToDictionaryAccessor _ _ _ _ = internalError "Invalid declaration in type class definition"
252252

253253
unit :: Type
254-
unit = TypeApp tyObject REmpty
254+
unit = TypeApp tyRecord REmpty
255255

256256
typeInstanceDictionaryDeclaration
257257
:: forall m
@@ -285,8 +285,8 @@ typeInstanceDictionaryDeclaration name mn deps className tys decls =
285285
members <- zip (map typeClassMemberName decls) <$> traverse (memberToValue memberTypes) decls
286286

287287
-- Create the type of the dictionary
288-
-- The type is an object type, but depending on type instance dependencies, may be constrained.
289-
-- The dictionary itself is an object literal.
288+
-- The type is a record type, but depending on type instance dependencies, may be constrained.
289+
-- The dictionary itself is a record literal.
290290
let superclasses = superClassDictionaryNames implies `zip`
291291
[ Abs (Left (Ident C.__unused)) (SuperClassDictionary superclass tyArgs)
292292
| (Constraint superclass suTyArgs _) <- implies

src/Language/PureScript/Sugar/TypeClasses/Deriving.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ mkVar :: Ident -> Expr
410410
mkVar = mkVarMn Nothing
411411

412412
objectType :: Type -> Maybe Type
413-
objectType (TypeApp (TypeConstructor (Qualified (Just (ModuleName [ProperName "Prim"])) (ProperName "Object"))) rec) = Just rec
413+
objectType (TypeApp (TypeConstructor (Qualified (Just (ModuleName [ProperName "Prim"])) (ProperName "Record"))) rec) = Just rec
414414
objectType _ = Nothing
415415

416416
decomposeRec :: Type -> [(String, Type)]

0 commit comments

Comments
 (0)