git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Rename Prim.Object to Prim.Record, fix #1768 (#2102)
e11cff5Phil Freeman
examples/passing/LiberalTypeSynonyms.purs+1−1
@@ -9,7 +9,7 @@ foo s = s
9
9
10type AndFoo r = (foo :: String | r)
10type AndFoo r = (foo :: String | r)
11
11
12−getFoo :: forall r. Prim.Object (AndFoo r) -> String
12+getFoo :: forall r. Prim.Record (AndFoo r) -> String
13getFoo o = o.foo
13getFoo o = o.foo
14
14
15type F r = { | r } -> { | r }
15type F r = { | r } -> { | r }
examples/passing/NewtypeWithRecordUpdate.purs+2−2
@@ -5,9 +5,9 @@ module Main where
5import Prelude
5import Prelude
6import Control.Monad.Eff.Console
6import Control.Monad.Eff.Console
7
7
8−newtype NewType a = NewType (Object a)
8+newtype NewType a = NewType (Record a)
9
9
10−rec1 :: Object (a :: Number, b :: Number, c:: Number)
10+rec1 :: Record (a :: Number, b :: Number, c:: Number)
11rec1 = { a: 0.0, b: 0.0, c: 0.0 }
11rec1 = { a: 0.0, b: 0.0, c: 0.0 }
12
12
13rec2 :: NewType (a :: Number, b :: Number, c :: Number)
13rec2 :: 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 }
12bar :: { | Bar }
12bar :: { | Bar }
13bar = { x: 0.0, y: 0.0, z: 0.0 }
13bar = { x: 0.0, y: 0.0, z: 0.0 }
14
14
15−id' :: Object Foo -> Object Bar
15+id' :: Record Foo -> Record Bar
16id' = id
16id' = id
17
17
18foo' :: { | Foo }
18foo' :: { | Foo }
src/Language/PureScript/AST/Declarations.hs+2−2
@@ -351,8 +351,8 @@ data Expr
351 --
351 --
352 | Parens Expr
352 | Parens Expr
353 -- |
353 -- |
354− -- An object property getter (e.g. `_.x`). This will be removed during
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 an object.
355+ -- desugaring and expanded into a lambda that reads a property from a record.
356 --
356 --
357 | ObjectGetter String
357 | ObjectGetter String
358 -- |
358 -- |
src/Language/PureScript/Docs/RenderedCode/Render.hs+1−1
@@ -159,7 +159,7 @@ dePrim other = other
159
159
160convert :: RenderTypeOptions -> Type -> Type
160convert :: RenderTypeOptions -> Type -> Type
161convert _ (TypeApp (TypeApp f arg) ret) | f == tyFunction = PrettyPrintFunction arg ret
161convert _ (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
163convert _ other = other
163convert _ other = other
164
164
165convertForAlls :: Type -> Type
165convertForAlls :: Type -> Type
src/Language/PureScript/Environment.hs+13−13
@@ -196,16 +196,16 @@ tyArray :: Type
196tyArray = primTy "Array"
196tyArray = primTy "Array"
197
197
198-- |
198-- |
199−-- Type constructor for objects
199+-- Type constructor for records
200--
200--
201−tyObject :: Type
201+tyRecord :: Type
202−tyObject = primTy "Object"
202+tyRecord = primTy "Record"
203
203
204-- |
204-- |
205−-- Check whether a type is an object
205+-- Check whether a type is a record
206--
206--
207isObject :: Type -> Bool
207isObject :: Type -> Bool
208−isObject = isTypeOrApplied tyObject
208+isObject = isTypeOrApplied tyRecord
209
209
210-- |
210-- |
211-- Check whether a type is a function
211-- Check whether a type is a function
@@ -232,14 +232,14 @@ primTypes :: M.Map (Qualified (ProperName 'TypeName)) (Kind, TypeKind)
232primTypes =
232primTypes =
233 M.fromList
233 M.fromList
234 [ (primName "Function", (FunKind Star (FunKind Star Star), ExternData))
234 [ (primName "Function", (FunKind Star (FunKind Star Star), ExternData))
235− , (primName "Array", (FunKind Star Star, ExternData))
235+ , (primName "Array", (FunKind Star Star, ExternData))
236− , (primName "Object", (FunKind (Row Star) Star, ExternData))
236+ , (primName "Record", (FunKind (Row Star) Star, ExternData))
237− , (primName "String", (Star, ExternData))
237+ , (primName "String", (Star, ExternData))
238− , (primName "Char", (Star, ExternData))
238+ , (primName "Char", (Star, ExternData))
239− , (primName "Number", (Star, ExternData))
239+ , (primName "Number", (Star, ExternData))
240− , (primName "Int", (Star, ExternData))
240+ , (primName "Int", (Star, ExternData))
241− , (primName "Boolean", (Star, ExternData))
241+ , (primName "Boolean", (Star, ExternData))
242− , (primName "Partial", (Star, ExternData))
242+ , (primName "Partial", (Star, ExternData))
243 ]
243 ]
244
244
245-- |
245-- |
src/Language/PureScript/Parser/Types.hs+1−1
@@ -25,7 +25,7 @@ parseFunction :: TokenParser Type
25parseFunction = parens rarrow >> return tyFunction
25parseFunction = parens rarrow >> return tyFunction
26
26
27parseObject :: TokenParser Type
27parseObject :: TokenParser Type
28−parseObject = braces $ TypeApp tyObject <$> parseRow
28+parseObject = braces $ TypeApp tyRecord <$> parseRow
29
29
30parseTypeWildcard :: TokenParser Type
30parseTypeWildcard :: TokenParser Type
31parseTypeWildcard = do
31parseTypeWildcard = do
src/Language/PureScript/Pretty/Types.hs+1−1
@@ -99,7 +99,7 @@ insertPlaceholders :: Type -> Type
99insertPlaceholders = everywhereOnTypesTopDown convertForAlls . everywhereOnTypes convert
99insertPlaceholders = everywhereOnTypesTopDown convertForAlls . everywhereOnTypes convert
100 where
100 where
101 convert (TypeApp (TypeApp f arg) ret) | f == tyFunction = PrettyPrintFunction arg ret
101 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
103 convert other = other
103 convert other = other
104 convertForAlls (ForAll ident ty _) = go [ident] ty
104 convertForAlls (ForAll ident ty _) = go [ident] ty
105 where
105 where
src/Language/PureScript/Sugar/TypeClasses.hs+4−4
@@ -233,7 +233,7 @@ typeClassDictionaryDeclaration name args implies members =
233 ]
233 ]
234 members' = map (first runIdent . memberToNameAndType) members
234 members' = map (first runIdent . memberToNameAndType) members
235 mtys = members' ++ superclassTypes
235 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))
237
237
238typeClassMemberToDictionaryAccessor
238typeClassMemberToDictionaryAccessor
239 :: ModuleName
239 :: ModuleName
@@ -251,7 +251,7 @@ typeClassMemberToDictionaryAccessor mn name args (PositionedDeclaration pos com
251typeClassMemberToDictionaryAccessor _ _ _ _ = internalError "Invalid declaration in type class definition"
251typeClassMemberToDictionaryAccessor _ _ _ _ = internalError "Invalid declaration in type class definition"
252
252
253unit :: Type
253unit :: Type
254−unit = TypeApp tyObject REmpty
254+unit = TypeApp tyRecord REmpty
255
255
256typeInstanceDictionaryDeclaration
256typeInstanceDictionaryDeclaration
257 :: forall m
257 :: forall m
@@ -285,8 +285,8 @@ typeInstanceDictionaryDeclaration name mn deps className tys decls =
285 members <- zip (map typeClassMemberName decls) <$> traverse (memberToValue memberTypes) decls
285 members <- zip (map typeClassMemberName decls) <$> traverse (memberToValue memberTypes) decls
286
286
287 -- Create the type of the dictionary
287 -- Create the type of the dictionary
288− -- The type is an object type, but depending on type instance dependencies, may be constrained.
288+ -- The type is a record type, but depending on type instance dependencies, may be constrained.
289− -- The dictionary itself is an object literal.
289+ -- The dictionary itself is a record literal.
290 let superclasses = superClassDictionaryNames implies `zip`
290 let superclasses = superClassDictionaryNames implies `zip`
291 [ Abs (Left (Ident C.__unused)) (SuperClassDictionary superclass tyArgs)
291 [ Abs (Left (Ident C.__unused)) (SuperClassDictionary superclass tyArgs)
292 | (Constraint superclass suTyArgs _) <- implies
292 | (Constraint superclass suTyArgs _) <- implies
src/Language/PureScript/Sugar/TypeClasses/Deriving.hs+1−1
@@ -410,7 +410,7 @@ mkVar :: Ident -> Expr
410mkVar = mkVarMn Nothing
410mkVar = mkVarMn Nothing
411
411
412objectType :: Type -> Maybe Type
412objectType :: 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
414objectType _ = Nothing
414objectType _ = Nothing
415
415
416decomposeRec :: Type -> [(String, Type)]
416decomposeRec :: Type -> [(String, Type)]
src/Language/PureScript/TypeChecker/Subsumption.hs+2−2
@@ -53,7 +53,7 @@ subsumes' val ty1 (KindedType ty2 _) =
53subsumes' (Just val) (ConstrainedType constraints ty1) ty2 = do
53subsumes' (Just val) (ConstrainedType constraints ty1) ty2 = do
54 dicts <- getTypeClassDictionaries
54 dicts <- getTypeClassDictionaries
55 subsumes' (Just $ foldl App val (map (flip TypeClassDictionary dicts) constraints)) ty1 ty2
55 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
57 let
57 let
58 (ts1, r1') = rowToList r1
58 (ts1, r1') = rowToList r1
59 (ts2, r2') = rowToList r2
59 (ts2, r2') = rowToList r2
@@ -80,7 +80,7 @@ subsumes' val (TypeApp f1 r1) (TypeApp f2 r2) | f1 == tyObject && f2 == tyObject
80 REmpty -> throwError . errorMessage $ PropertyIsMissing p2
80 REmpty -> throwError . errorMessage $ PropertyIsMissing p2
81 _ -> unifyTypes r1' (RCons p2 ty2 rest)
81 _ -> unifyTypes r1' (RCons p2 ty2 rest)
82 go ((p1, ty1) : ts1) ts2 rest r2'
82 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
84subsumes' val ty1 ty2 = do
84subsumes' val ty1 ty2 = do
85 unifyTypes ty1 ty2
85 unifyTypes ty1 ty2
86 return val
86 return val
src/Language/PureScript/TypeChecker/Types.hs+10−10
@@ -254,7 +254,7 @@ infer' (Literal (ObjectLiteral ps)) = do
254 ensureNoDuplicateProperties ps
254 ensureNoDuplicateProperties ps
255 ts <- traverse (infer . snd) ps
255 ts <- traverse (infer . snd) ps
256 let fields = zipWith (\name (TypedValue _ _ t) -> (name, t)) (map fst ps) ts
256 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)
258 return $ TypedValue True (Literal (ObjectLiteral (zip (map fst ps) ts))) ty
258 return $ TypedValue True (Literal (ObjectLiteral (zip (map fst ps) ts))) ty
259infer' (ObjectUpdate o ps) = do
259infer' (ObjectUpdate o ps) = do
260 ensureNoDuplicateProperties ps
260 ensureNoDuplicateProperties ps
@@ -262,13 +262,13 @@ infer' (ObjectUpdate o ps) = do
262 newVals <- zipWith (\(name, _) t -> (name, t)) ps <$> traverse (infer . snd) ps
262 newVals <- zipWith (\(name, _) t -> (name, t)) ps <$> traverse (infer . snd) ps
263 let newTys = map (\(name, TypedValue _ _ ty) -> (name, ty)) newVals
263 let newTys = map (\(name, TypedValue _ _ ty) -> (name, ty)) newVals
264 oldTys <- zip (map fst ps) <$> replicateM (length ps) freshType
264 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)
266 o' <- TypedValue True <$> check o oldTy <*> pure oldTy
266 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)
268infer' (Accessor prop val) = rethrow (addHint (ErrorCheckingAccessor val prop)) $ do
268infer' (Accessor prop val) = rethrow (addHint (ErrorCheckingAccessor val prop)) $ do
269 field <- freshType
269 field <- freshType
270 rest <- freshType
270 rest <- freshType
271− typed <- check val (TypeApp tyObject (RCons prop field rest))
271+ typed <- check val (TypeApp tyRecord (RCons prop field rest))
272 return $ TypedValue True (Accessor prop typed) field
272 return $ TypedValue True (Accessor prop typed) field
273infer' (Abs (Left arg) ret) = do
273infer' (Abs (Left arg) ret) = do
274 ty <- freshType
274 ty <- freshType
@@ -402,7 +402,7 @@ inferBinder val (LiteralBinder (ObjectLiteral props)) = do
402 row <- freshType
402 row <- freshType
403 rest <- freshType
403 rest <- freshType
404 m1 <- inferRowProperties row rest props
404 m1 <- inferRowProperties row rest props
405− unifyTypes val (TypeApp tyObject row)
405+ unifyTypes val (TypeApp tyRecord row)
406 return m1
406 return m1
407 where
407 where
408 inferRowProperties :: Type -> Type -> [(String, Binder)] -> m (M.Map Ident Type)
408 inferRowProperties :: Type -> Type -> [(String, Binder)] -> m (M.Map Ident Type)
@@ -616,26 +616,26 @@ check' (IfThenElse cond th el) ty = do
616 th' <- check th ty
616 th' <- check th ty
617 el' <- check el ty
617 el' <- check el ty
618 return $ TypedValue True (IfThenElse cond' th' el') ty
618 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
620 ensureNoDuplicateProperties ps
620 ensureNoDuplicateProperties ps
621 ps' <- checkProperties e ps row False
621 ps' <- checkProperties e ps row False
622 return $ TypedValue True (Literal (ObjectLiteral ps')) t
622 return $ TypedValue True (Literal (ObjectLiteral ps')) t
623check' (TypeClassDictionaryConstructorApp name ps) t = do
623check' (TypeClassDictionaryConstructorApp name ps) t = do
624 ps' <- check' ps t
624 ps' <- check' ps t
625 return $ TypedValue True (TypeClassDictionaryConstructorApp name ps') t
625 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
627 ensureNoDuplicateProperties ps
627 ensureNoDuplicateProperties ps
628 -- We need to be careful to avoid duplicate labels here.
628 -- We need to be careful to avoid duplicate labels here.
629 -- We check _obj_ against the type _t_ with the types in _ps_ replaced with unknowns.
629 -- We check _obj_ against the type _t_ with the types in _ps_ replaced with unknowns.
630 let (propsToCheck, rest) = rowToList row
630 let (propsToCheck, rest) = rowToList row
631 (removedProps, remainingProps) = partition (\(p, _) -> p `elem` map fst ps) propsToCheck
631 (removedProps, remainingProps) = partition (\(p, _) -> p `elem` map fst ps) propsToCheck
632 us <- zip (map fst removedProps) <$> replicateM (length ps) freshType
632 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)))
634 ps' <- checkProperties e ps row True
634 ps' <- checkProperties e ps row True
635 return $ TypedValue True (ObjectUpdate obj' ps') t
635 return $ TypedValue True (ObjectUpdate obj' ps') t
636check' (Accessor prop val) ty = rethrow (addHint (ErrorCheckingAccessor val prop)) $ do
636check' (Accessor prop val) ty = rethrow (addHint (ErrorCheckingAccessor val prop)) $ do
637 rest <- freshType
637 rest <- freshType
638− val' <- check val (TypeApp tyObject (RCons prop ty rest))
638+ val' <- check val (TypeApp tyRecord (RCons prop ty rest))
639 return $ TypedValue True (Accessor prop val') ty
639 return $ TypedValue True (Accessor prop val') ty
640check' v@(Constructor c) ty = do
640check' v@(Constructor c) ty = do
641 env <- getEnv
641 env <- getEnv
@@ -698,7 +698,7 @@ checkProperties expr ps row lax = let (ts, r') = rowToList row in go ps ts r' wh
698 v' <- check v ty
698 v' <- check v ty
699 ps'' <- go ps' (delete (p, ty) ts) r
699 ps'' <- go ps' (delete (p, ty) ts) r
700 return $ (p, v') : ps''
700 return $ (p, v') : ps''
701− go _ _ _ = throwError . errorMessage $ ExprDoesNotHaveType expr (TypeApp tyObject row)
701+ go _ _ _ = throwError . errorMessage $ ExprDoesNotHaveType expr (TypeApp tyRecord row)
702
702
703-- | Check the type of a function application, rethrowing errors to provide a better error message
703-- | Check the type of a function application, rethrowing errors to provide a better error message
704checkFunctionApplication ::
704checkFunctionApplication ::