git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1520 from purescript/inferProperty

Remove inferProperty judgment

commita12ab16028080ad172ec4594d885b54764f3af6d authorPhil Freeman <paf31@cantab.net> dateMon 12 Oct 2015, 09:17 (11 years ago) parent93457241e3b1ec
1 file changed+4−24
src/Language/PureScript/TypeChecker/Types.hs+4−24
src/Language/PureScript/TypeChecker/Types.hs+4−24
@@ -246,15 +246,10 @@ infer' (ObjectUpdate o ps) = do
246246 o' <- TypedValue True <$> check o oldTy <*> pure oldTy
247247 return $ TypedValue True (ObjectUpdate o' newVals) $ TypeApp tyObject $ rowFromList (newTys, row)
248248infer' (Accessor prop val) = do
249− typed@(TypedValue _ _ objTy) <- infer val
250− propTy <- inferProperty objTy prop
251− case propTy of
252− Nothing -> do
253− field <- fresh
254− rest <- fresh
255− _ <- subsumes Nothing objTy (TypeApp tyObject (RCons prop field rest))
256− return $ TypedValue True (Accessor prop typed) field
257− Just ty -> return $ TypedValue True (Accessor prop typed) ty
249+ field <- fresh
250+ rest <- fresh
251+ typed <- check val (TypeApp tyObject (RCons prop field rest))
252+ return $ TypedValue True (Accessor prop typed) field
258253infer' (Abs (Left arg) ret) = do
259254 ty <- fresh
260255 Just moduleName <- checkCurrentModule <$> get
@@ -339,21 +334,6 @@ inferLetBinding seen (PositionedDeclaration pos com d : ds) ret j = warnAndRethr
339334 return (PositionedDeclaration pos com d' : ds', val')
340335inferLetBinding _ _ _ _ = error "Invalid argument to inferLetBinding"
341336
342−-- |
343−-- Infer the type of a property inside a record with a given type
344−--
345−inferProperty :: Type -> String -> UnifyT Type Check (Maybe Type)
346−inferProperty (TypeApp obj row) prop | obj == tyObject = do
347− let (props, _) = rowToList row
348− return $ lookup prop props
349−inferProperty (SaturatedTypeSynonym name args) prop = do
350− replaced <- introduceSkolemScope <=< expandTypeSynonym name $ args
351− inferProperty replaced prop
352−inferProperty (ForAll ident ty _) prop = do
353− replaced <- replaceVarWithUnknown ident ty
354− inferProperty replaced prop
355−inferProperty _ _ = return Nothing
356−
357337-- |
358338-- Infer the types of variables brought into scope by a binder
359339--