Skip to content

Commit

Permalink
Remove inferProperty judgment
Browse files Browse the repository at this point in the history
  • Loading branch information
paf31 committed Oct 11, 2015
1 parent 9345724 commit 1e3b1ec
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions src/Language/PureScript/TypeChecker/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,10 @@ infer' (ObjectUpdate o ps) = do
o' <- TypedValue True <$> check o oldTy <*> pure oldTy
return $ TypedValue True (ObjectUpdate o' newVals) $ TypeApp tyObject $ rowFromList (newTys, row)
infer' (Accessor prop val) = do
typed@(TypedValue _ _ objTy) <- infer val
propTy <- inferProperty objTy prop
case propTy of
Nothing -> do
field <- fresh
rest <- fresh
_ <- subsumes Nothing objTy (TypeApp tyObject (RCons prop field rest))
return $ TypedValue True (Accessor prop typed) field
Just ty -> return $ TypedValue True (Accessor prop typed) ty
field <- fresh
rest <- fresh
typed <- check val (TypeApp tyObject (RCons prop field rest))
return $ TypedValue True (Accessor prop typed) field
infer' (Abs (Left arg) ret) = do
ty <- fresh
Just moduleName <- checkCurrentModule <$> get
Expand Down Expand Up @@ -339,21 +334,6 @@ inferLetBinding seen (PositionedDeclaration pos com d : ds) ret j = warnAndRethr
return (PositionedDeclaration pos com d' : ds', val')
inferLetBinding _ _ _ _ = error "Invalid argument to inferLetBinding"

-- |
-- Infer the type of a property inside a record with a given type
--
inferProperty :: Type -> String -> UnifyT Type Check (Maybe Type)
inferProperty (TypeApp obj row) prop | obj == tyObject = do
let (props, _) = rowToList row
return $ lookup prop props
inferProperty (SaturatedTypeSynonym name args) prop = do
replaced <- introduceSkolemScope <=< expandTypeSynonym name $ args
inferProperty replaced prop
inferProperty (ForAll ident ty _) prop = do
replaced <- replaceVarWithUnknown ident ty
inferProperty replaced prop
inferProperty _ _ = return Nothing

-- |
-- Infer the types of variables brought into scope by a binder
--
Expand Down

0 comments on commit 1e3b1ec

Please sign in to comment.