summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilFreeman <>2013-11-28 01:56:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2013-11-28 01:56:00 (GMT)
commit93dfbdb3779ebcf9961a0402f46c297c3903a6fa (patch)
tree10386ac30c321dfe58bcc167270feae523e1cd84
parente6d0781a40183b957bf09d0ae5493bfc27be72af (diff)
version 0.1.120.1.12
-rw-r--r--purescript.cabal2
-rw-r--r--src/Language/PureScript/TypeChecker/Types.hs19
-rw-r--r--src/Language/PureScript/Types.hs4
3 files changed, 12 insertions, 13 deletions
diff --git a/purescript.cabal b/purescript.cabal
index c36b879..d085cc2 100644
--- a/purescript.cabal
+++ b/purescript.cabal
@@ -1,5 +1,5 @@
name: purescript
-version: 0.1.11
+version: 0.1.12
cabal-version: >=1.8
build-type: Simple
license: MIT
diff --git a/src/Language/PureScript/TypeChecker/Types.hs b/src/Language/PureScript/TypeChecker/Types.hs
index 02ba0c3..8f5b2f2 100644
--- a/src/Language/PureScript/TypeChecker/Types.hs
+++ b/src/Language/PureScript/TypeChecker/Types.hs
@@ -295,15 +295,14 @@ infer' m (ObjectLiteral ps) = do
lift $ ensureNoDuplicateProperties ps
ts <- mapM (infer m . snd) ps
let fields = zipWith (\(name, _) t -> (name, t)) ps ts
- return $ Object $ typesToRow fields
+ return $ Object $ rowFromList (fields, REmpty)
infer' m (ObjectUpdate o ps) = do
lift $ ensureNoDuplicateProperties ps
- obj <- infer m o
row <- fresh
- ts <- mapM (infer m . snd) ps
- let tys = zipWith (\(name, _) t -> (name, t)) ps ts
- obj ~~ Object (rowFromList (tys, row))
- return obj
+ newTys <- zipWith (\(name, _) t -> (name, t)) ps <$> mapM (infer m . snd) ps
+ oldTys <- zip (map fst ps) <$> replicateM (length ps) fresh
+ check m o $ Object $ rowFromList (oldTys, row)
+ return $ Object $ rowFromList (newTys, row)
infer' m (Indexer index val) = do
el <- fresh
check m index Number
@@ -662,9 +661,13 @@ check' m (IfThenElse cond th el) ty = do
check' m (ObjectLiteral ps) (Object row) = do
lift $ ensureNoDuplicateProperties ps
checkProperties m ps row False
-check' m (ObjectUpdate obj ps) objTy@(Object row) = do
+check' m (ObjectUpdate obj ps) (Object row) = do
lift $ ensureNoDuplicateProperties ps
- check m obj objTy
+ us <- zip (map fst ps) <$> replicateM (length ps) fresh
+ let (propsToCheck, rest) = rowToList row
+ propsToRemove = map fst ps
+ remainingProps = filter (\(p, _) -> p `notElem` propsToRemove) propsToCheck
+ check m obj (Object (rowFromList (us ++ remainingProps, rest)))
checkProperties m ps row True
check' m (Accessor prop val) ty = do
rest <- fresh
diff --git a/src/Language/PureScript/Types.hs b/src/Language/PureScript/Types.hs
index f7d57f4..d3af5f1 100644
--- a/src/Language/PureScript/Types.hs
+++ b/src/Language/PureScript/Types.hs
@@ -44,10 +44,6 @@ data Row
| RCons String Type Row
| RSkolem Int deriving (Show, Eq, Data, Typeable)
-typesToRow :: [(String, Type)] -> Row
-typesToRow [] = REmpty
-typesToRow ((name, ty):tys) = RCons name ty (typesToRow tys)
-
rowToList :: Row -> ([(String, Type)], Row)
rowToList (RCons name ty row) = let (tys, rest) = rowToList row
in ((name, ty):tys, rest)