git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Kind check constraint contexts, fix #1071
24d5d0ePhil Freeman
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
45 match (TypeConstructor ctor) = Just $ text $ runProperName $ disqualify ctor
45 match (TypeConstructor ctor) = Just $ text $ runProperName $ disqualify ctor
46 match (TUnknown u) = Just $ text $ '_' : show u
46 match (TUnknown u) = Just $ text $ '_' : show u
47 match (Skolem name s _) = Just $ text $ name ++ show s
47 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
49 match REmpty = Just $ text "()"
49 match REmpty = Just $ text "()"
50 match row@RCons{} = Just $ prettyPrintRowWith '(' ')' row
50 match row@RCons{} = Just $ prettyPrintRowWith '(' ')' row
51 match _ = Nothing
51 match _ = Nothing
52
52
53−constraintsAsBox :: [(Qualified ProperName, [Type])] -> Box
53+constraintsAsBox :: [(Qualified ProperName, [Type])] -> Type -> Box
54+constraintsAsBox [(pn, tys)] ty = text "(" <> constraintAsBox pn tys <> text ") => " <> typeAsBox ty
54−constraintsAsBox = vcat left . zipWith (\i (pn, tys) -> text (if i == 0 then "( " else ", ") <> constraintAsBox pn tys) [0 :: Int ..]
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)
55− where
56+
57+constraintAsBox :: Qualified ProperName -> [Type] -> Box
56− constraintAsBox pn tys = hsep 1 left (text (runProperName (disqualify pn)) : map typeAtomAsBox tys)
58+constraintAsBox pn tys = hsep 1 left (text (runProperName (disqualify pn)) : map typeAtomAsBox tys)
57
59
58-- |
60-- |
59-- Generate a pretty-printed string representing a Row
61-- Generate a pretty-printed string representing a Row
src/Language/PureScript/TypeChecker/Kinds.hs+2−2
@@ -215,8 +215,8 @@ infer' other = (, []) <$> go other
215 return $ Row k1
215 return $ Row k1
216 go (ConstrainedType deps ty) = do
216 go (ConstrainedType deps ty) = do
217 forM_ deps $ \(className, tys) -> do
217 forM_ deps $ \(className, tys) -> do
218− _ <- go $ foldl TypeApp (TypeConstructor className) tys
218+ k <- go $ foldl TypeApp (TypeConstructor className) tys
219− return ()
219+ k =?= Star
220 k <- go ty
220 k <- go ty
221 k =?= Star
221 k =?= Star
222 return Star
222 return Star