git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Rename Prim.Object to Prim.Record, fix #1768 (#2102)

* Rename Prim.Object to Prim.Record, fix #1768 * Fix some comments

commite11cff57bf0f9418db673a3047fbdf89613400f8 authorPhil Freeman <paf31@cantab.net> dateTue 10 May 2016, 09:39 (10 years ago) parent10f76a7
12 files changed+39−39
examples/passing/LiberalTypeSynonyms.purs+1−1 examples/passing/NewtypeWithRecordUpdate.purs+2−2 examples/passing/RowConstructors.purs+1−1 src/Language/PureScript/AST/Declarations.hs+2−2 src/Language/PureScript/Docs/RenderedCode/Render.hs+1−1 src/Language/PureScript/Environment.hs+13−13 src/Language/PureScript/Parser/Types.hs+1−1 src/Language/PureScript/Pretty/Types.hs+1−1 src/Language/PureScript/Sugar/TypeClasses.hs+4−4 src/Language/PureScript/Sugar/TypeClasses/Deriving.hs+1−1 src/Language/PureScript/TypeChecker/Subsumption.hs+2−2 src/Language/PureScript/TypeChecker/Types.hs+10−10
examples/passing/LiberalTypeSynonyms.purs+1−1
@@ -9,7 +9,7 @@ foo s = s
99
1010type AndFoo r = (foo :: String | r)
1111
12−getFoo :: forall r. Prim.Object (AndFoo r) -> String
12+getFoo :: forall r. Prim.Record (AndFoo r) -> String
1313getFoo o = o.foo
1414
1515type F r = { | r } -> { | r }
examples/passing/NewtypeWithRecordUpdate.purs+2−2
@@ -5,9 +5,9 @@ module Main where
55import Prelude
66import 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)
1111rec1 = { a: 0.0, b: 0.0, c: 0.0 }
1212
1313rec2 :: NewType (a :: Number, b :: Number, c :: Number)
examples/passing/RowConstructors.purs+1−1
@@ -12,7 +12,7 @@ foo = { x: 0.0, y: 0.0, z: 0.0 }
1212bar :: { | Bar }
1313bar = { x: 0.0, y: 0.0, z: 0.0 }
1414
15−id' :: Object Foo -> Object Bar
15+id' :: Record Foo -> Record Bar
1616id' = id
1717
1818foo' :: { | Foo }
src/Language/PureScript/AST/Declarations.hs+2−2
@@ -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+1−1
@@ -159,7 +159,7 @@ dePrim other = other
159159
160160convert :: RenderTypeOptions -> Type -> Type
161161convert _ (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
163163convert _ other = other
164164
165165convertForAlls :: Type -> Type
src/Language/PureScript/Environment.hs+13−13
@@ -196,16 +196,16 @@ tyArray :: Type
196196tyArray = 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--
207207isObject :: 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)
232232primTypes =
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+1−1
@@ -25,7 +25,7 @@ parseFunction :: TokenParser Type
2525parseFunction = parens rarrow >> return tyFunction
2626
2727parseObject :: TokenParser Type
28−parseObject = braces $ TypeApp tyObject <$> parseRow
28+parseObject = braces $ TypeApp tyRecord <$> parseRow
2929
3030parseTypeWildcard :: TokenParser Type
3131parseTypeWildcard = do
src/Language/PureScript/Pretty/Types.hs+1−1
@@ -99,7 +99,7 @@ insertPlaceholders :: Type -> Type
9999insertPlaceholders = 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+4−4
@@ -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
238238typeClassMemberToDictionaryAccessor
239239 :: ModuleName
@@ -251,7 +251,7 @@ typeClassMemberToDictionaryAccessor mn name args (PositionedDeclaration pos com
251251typeClassMemberToDictionaryAccessor _ _ _ _ = internalError "Invalid declaration in type class definition"
252252
253253unit :: Type
254−unit = TypeApp tyObject REmpty
254+unit = TypeApp tyRecord REmpty
255255
256256typeInstanceDictionaryDeclaration
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+1−1
@@ -410,7 +410,7 @@ mkVar :: Ident -> Expr
410410mkVar = mkVarMn Nothing
411411
412412objectType :: 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
414414objectType _ = Nothing
415415
416416decomposeRec :: Type -> [(String, Type)]
src/Language/PureScript/TypeChecker/Subsumption.hs+2−2
@@ -53,7 +53,7 @@ subsumes' val ty1 (KindedType ty2 _) =
5353subsumes' (Just val) (ConstrainedType constraints ty1) ty2 = do
5454 dicts <- getTypeClassDictionaries
5555 subsumes' (Just $ foldl App val (map (flip TypeClassDictionary dicts) constraints)) ty1 ty2
56−subsumes' val (TypeApp f1 r1) (TypeApp f2 r2) | f1 == tyObject && f2 == tyObject = do
56+subsumes' val (TypeApp f1 r1) (TypeApp f2 r2) | f1 == tyRecord && f2 == tyRecord = do
5757 let
5858 (ts1, r1') = rowToList r1
5959 (ts2, r2') = rowToList r2
@@ -80,7 +80,7 @@ subsumes' val (TypeApp f1 r1) (TypeApp f2 r2) | f1 == tyObject && f2 == tyObject
8080 REmpty -> throwError . errorMessage $ PropertyIsMissing p2
8181 _ -> unifyTypes r1' (RCons p2 ty2 rest)
8282 go ((p1, ty1) : ts1) ts2 rest r2'
83−subsumes' val ty1 ty2@(TypeApp obj _) | obj == tyObject = subsumes val ty2 ty1
83+subsumes' val ty1 ty2@(TypeApp obj _) | obj == tyRecord = subsumes val ty2 ty1
8484subsumes' val ty1 ty2 = do
8585 unifyTypes ty1 ty2
8686 return val
src/Language/PureScript/TypeChecker/Types.hs+10−10
@@ -254,7 +254,7 @@ infer' (Literal (ObjectLiteral ps)) = do
254254 ensureNoDuplicateProperties ps
255255 ts <- traverse (infer . snd) ps
256256 let fields = zipWith (\name (TypedValue _ _ t) -> (name, t)) (map fst ps) ts
257− ty = TypeApp tyObject $ rowFromList (fields, REmpty)
257+ ty = TypeApp tyRecord $ rowFromList (fields, REmpty)
258258 return $ TypedValue True (Literal (ObjectLiteral (zip (map fst ps) ts))) ty
259259infer' (ObjectUpdate o ps) = do
260260 ensureNoDuplicateProperties ps
@@ -262,13 +262,13 @@ infer' (ObjectUpdate o ps) = do
262262 newVals <- zipWith (\(name, _) t -> (name, t)) ps <$> traverse (infer . snd) ps
263263 let newTys = map (\(name, TypedValue _ _ ty) -> (name, ty)) newVals
264264 oldTys <- zip (map fst ps) <$> replicateM (length ps) freshType
265− let oldTy = TypeApp tyObject $ rowFromList (oldTys, row)
265+ let oldTy = TypeApp tyRecord $ rowFromList (oldTys, row)
266266 o' <- TypedValue True <$> check o oldTy <*> pure oldTy
267− return $ TypedValue True (ObjectUpdate o' newVals) $ TypeApp tyObject $ rowFromList (newTys, row)
267+ return $ TypedValue True (ObjectUpdate o' newVals) $ TypeApp tyRecord $ rowFromList (newTys, row)
268268infer' (Accessor prop val) = rethrow (addHint (ErrorCheckingAccessor val prop)) $ do
269269 field <- freshType
270270 rest <- freshType
271− typed <- check val (TypeApp tyObject (RCons prop field rest))
271+ typed <- check val (TypeApp tyRecord (RCons prop field rest))
272272 return $ TypedValue True (Accessor prop typed) field
273273infer' (Abs (Left arg) ret) = do
274274 ty <- freshType
@@ -402,7 +402,7 @@ inferBinder val (LiteralBinder (ObjectLiteral props)) = do
402402 row <- freshType
403403 rest <- freshType
404404 m1 <- inferRowProperties row rest props
405− unifyTypes val (TypeApp tyObject row)
405+ unifyTypes val (TypeApp tyRecord row)
406406 return m1
407407 where
408408 inferRowProperties :: Type -> Type -> [(String, Binder)] -> m (M.Map Ident Type)
@@ -616,26 +616,26 @@ check' (IfThenElse cond th el) ty = do
616616 th' <- check th ty
617617 el' <- check el ty
618618 return $ TypedValue True (IfThenElse cond' th' el') ty
619−check' e@(Literal (ObjectLiteral ps)) t@(TypeApp obj row) | obj == tyObject = do
619+check' e@(Literal (ObjectLiteral ps)) t@(TypeApp obj row) | obj == tyRecord = do
620620 ensureNoDuplicateProperties ps
621621 ps' <- checkProperties e ps row False
622622 return $ TypedValue True (Literal (ObjectLiteral ps')) t
623623check' (TypeClassDictionaryConstructorApp name ps) t = do
624624 ps' <- check' ps t
625625 return $ TypedValue True (TypeClassDictionaryConstructorApp name ps') t
626−check' e@(ObjectUpdate obj ps) t@(TypeApp o row) | o == tyObject = do
626+check' e@(ObjectUpdate obj ps) t@(TypeApp o row) | o == tyRecord = do
627627 ensureNoDuplicateProperties ps
628628 -- We need to be careful to avoid duplicate labels here.
629629 -- We check _obj_ against the type _t_ with the types in _ps_ replaced with unknowns.
630630 let (propsToCheck, rest) = rowToList row
631631 (removedProps, remainingProps) = partition (\(p, _) -> p `elem` map fst ps) propsToCheck
632632 us <- zip (map fst removedProps) <$> replicateM (length ps) freshType
633− obj' <- check obj (TypeApp tyObject (rowFromList (us ++ remainingProps, rest)))
633+ obj' <- check obj (TypeApp tyRecord (rowFromList (us ++ remainingProps, rest)))
634634 ps' <- checkProperties e ps row True
635635 return $ TypedValue True (ObjectUpdate obj' ps') t
636636check' (Accessor prop val) ty = rethrow (addHint (ErrorCheckingAccessor val prop)) $ do
637637 rest <- freshType
638− val' <- check val (TypeApp tyObject (RCons prop ty rest))
638+ val' <- check val (TypeApp tyRecord (RCons prop ty rest))
639639 return $ TypedValue True (Accessor prop val') ty
640640check' v@(Constructor c) ty = do
641641 env <- getEnv
@@ -698,7 +698,7 @@ checkProperties expr ps row lax = let (ts, r') = rowToList row in go ps ts r' wh
698698 v' <- check v ty
699699 ps'' <- go ps' (delete (p, ty) ts) r
700700 return $ (p, v') : ps''
701− go _ _ _ = throwError . errorMessage $ ExprDoesNotHaveType expr (TypeApp tyObject row)
701+ go _ _ _ = throwError . errorMessage $ ExprDoesNotHaveType expr (TypeApp tyRecord row)
702702
703703-- | Check the type of a function application, rethrowing errors to provide a better error message
704704checkFunctionApplication ::