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

Kind check constraint contexts, fix #1071

commit3d1c544173eb2498a002ef82bc094c933fbd3d31 authorPhil Freeman <paf31@cantab.net> dateSat 17 Oct 2015, 13:21 (11 years ago) parent2901b4024d5d0e
3 files changed+17−7
examples/failing/1071.purs+8 src/Language/PureScript/Pretty/Types.hs+7−5 src/Language/PureScript/TypeChecker/Kinds.hs+2−2
examples/failing/1071.pursnew file+8
@@ -0,0 +1,8 @@
1+-- @shouldFailWith KindsDoNotUnify
2+module Main where
3+
4+class Foo a b where
5+ foo :: a -> b
6+
7+bar :: forall a. (Foo a) => a -> a
8+bar a = a
src/Language/PureScript/Pretty/Types.hs+7−5
@@ -45,15 +45,17 @@ typeLiterals = mkPattern match
4545 match (TypeConstructor ctor) = Just $ text $ runProperName $ disqualify ctor
4646 match (TUnknown u) = Just $ text $ '_' : show u
4747 match (Skolem name s _) = Just $ text $ name ++ show s
48− match (ConstrainedType deps ty) = Just $ constraintsAsBox deps `before` (text ") => " <> typeAsBox ty)
48+ match (ConstrainedType deps ty) = Just $ constraintsAsBox deps ty
4949 match REmpty = Just $ text "()"
5050 match row@RCons{} = Just $ prettyPrintRowWith '(' ')' row
5151 match _ = Nothing
5252
53−constraintsAsBox :: [(Qualified ProperName, [Type])] -> Box
54−constraintsAsBox = vcat left . zipWith (\i (pn, tys) -> text (if i == 0 then "( " else ", ") <> constraintAsBox pn tys) [0 :: Int ..]
55− where
56− constraintAsBox pn tys = hsep 1 left (text (runProperName (disqualify pn)) : map typeAtomAsBox tys)
53+constraintsAsBox :: [(Qualified ProperName, [Type])] -> Type -> Box
54+constraintsAsBox [(pn, tys)] ty = text "(" <> constraintAsBox pn tys <> text ") => " <> typeAsBox ty
55+constraintsAsBox xs ty = vcat left (zipWith (\i (pn, tys) -> text (if i == 0 then "( " else ", ") <> constraintAsBox pn tys) [0 :: Int ..] xs) `before` (text ") => " <> typeAsBox ty)
56+
57+constraintAsBox :: Qualified ProperName -> [Type] -> Box
58+constraintAsBox pn tys = hsep 1 left (text (runProperName (disqualify pn)) : map typeAtomAsBox tys)
5759
5860-- |
5961-- Generate a pretty-printed string representing a Row
src/Language/PureScript/TypeChecker/Kinds.hs+2−2
@@ -215,8 +215,8 @@ infer' other = (, []) <$> go other
215215 return $ Row k1
216216 go (ConstrainedType deps ty) = do
217217 forM_ deps $ \(className, tys) -> do
218− _ <- go $ foldl TypeApp (TypeConstructor className) tys
219− return ()
218+ k <- go $ foldl TypeApp (TypeConstructor className) tys
219+ k =?= Star
220220 k <- go ty
221221 k =?= Star
222222 return Star