git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix Category bug #158
e7d219ePhil Freeman
examples/passing/Category.pursnew file+15
@@ -0,0 +1,15 @@
1+module Category where
2+
3+class Category c where
4+ id :: forall x. c x x
5+ (<|) :: forall x y z. c y z -> c x y -> c x z
6+
7+instance Category (->) where
8+ id = Prelude.id
9+ (<|) = Prelude.(<|)
10+
11+module Main where
12+
13+import Category
14+
15+main = Trace.trace (id "Done")
libraries/prelude/prelude.purs+2−2
@@ -3,8 +3,8 @@ module Prelude where
3 foreign import data String :: *
3 foreign import data String :: *
4 foreign import data Number :: *
4 foreign import data Number :: *
5 foreign import data Boolean :: *
5 foreign import data Boolean :: *
6− foreign import data [] :: * -> *
6+ foreign import data Array :: * -> *
7− foreign import data (->) :: * -> * -> *
7+ foreign import data Function :: * -> * -> *
8
8
9 id :: forall a. a -> a
9 id :: forall a. a -> a
10 id = \x -> x
10 id = \x -> x
src/Language/PureScript/Parser/Common.hs−3
@@ -239,9 +239,6 @@ natural = PT.natural tokenParser
239properName :: P.Parsec String u ProperName
239properName :: P.Parsec String u ProperName
240properName = lexeme $ ProperName <$> P.try ((:) <$> P.upper <*> many (PT.identLetter langDef) P.<?> "name")
240properName = lexeme $ ProperName <$> P.try ((:) <$> P.upper <*> many (PT.identLetter langDef) P.<?> "name")
241
241
242−properNameOrExternalType :: P.Parsec String u ProperName
243−properNameOrExternalType = P.try properName <|> (ProperName <$> (P.try (lexeme $ P.string "[]") <|> (lexeme $ P.string "(->)")))
244−
245-- |
242-- |
246-- Parse a qualified name, i.e. M.name or just name
243-- Parse a qualified name, i.e. M.name or just name
247--
244--
src/Language/PureScript/Parser/Declarations.hs+1−1
@@ -64,7 +64,7 @@ parseValueDeclaration =
64
64
65parseExternDeclaration :: P.Parsec String ParseState Declaration
65parseExternDeclaration :: P.Parsec String ParseState Declaration
66parseExternDeclaration = P.try (reserved "foreign") *> indented *> (reserved "import") *> indented *>
66parseExternDeclaration = P.try (reserved "foreign") *> indented *> (reserved "import") *> indented *>
67− (ExternDataDeclaration <$> (P.try (reserved "data") *> indented *> properNameOrExternalType)
67+ (ExternDataDeclaration <$> (P.try (reserved "data") *> indented *> properName)
68 <*> (lexeme (indented *> P.string "::") *> parseKind)
68 <*> (lexeme (indented *> P.string "::") *> parseKind)
69 <|> do ident <- parseNonReservedIdent
69 <|> do ident <- parseNonReservedIdent
70 js <- P.optionMaybe (parseJSLiteral <$> stringLiteral)
70 js <- P.optionMaybe (parseJSLiteral <$> stringLiteral)
src/Language/PureScript/Pretty/Types.hs+1
@@ -33,6 +33,7 @@ typeLiterals = mkPattern match
33 where
33 where
34 match (Object row) = Just $ "{ " ++ prettyPrintType row ++ " }"
34 match (Object row) = Just $ "{ " ++ prettyPrintType row ++ " }"
35 match (TypeVar var) = Just var
35 match (TypeVar var) = Just var
36+ match (TypeApp arr ty) | arr == tyArray = Just $ "[" ++ prettyPrintType ty ++ "]"
36 match (TypeConstructor ctor) = Just $ show ctor
37 match (TypeConstructor ctor) = Just $ show ctor
37 match (TUnknown (TypedUnknown (Unknown u))) = Just $ 'u' : show u
38 match (TUnknown (TypedUnknown (Unknown u))) = Just $ 'u' : show u
38 match (Skolem s) = Just $ 's' : show s
39 match (Skolem s) = Just $ 's' : show s
src/Language/PureScript/TypeChecker/Types.hs+2−1
@@ -922,7 +922,8 @@ checkFunctionApplication fn fnTy arg ret = rethrow errorMessage $ checkFunctionA
922-- Check the type of a function application
922-- Check the type of a function application
923--
923--
924checkFunctionApplication' :: Value -> Type -> Value -> Type -> UnifyT Check Value
924checkFunctionApplication' :: Value -> Type -> Value -> Type -> UnifyT Check Value
925−checkFunctionApplication' fn (TypeApp (TypeApp t argTy) retTy) arg ret | t == tyFunction = do
925+checkFunctionApplication' fn (TypeApp (TypeApp tyFunction' argTy) retTy) arg ret = do
926+ tyFunction' ?= tyFunction
926 arg' <- check arg argTy
927 arg' <- check arg argTy
927 _ <- subsumes Nothing retTy ret
928 _ <- subsumes Nothing retTy ret
928 return $ App fn arg'
929 return $ App fn arg'
src/Language/PureScript/Types.hs+2−2
@@ -77,7 +77,7 @@ data Type
77-- Type constructor for functions
77-- Type constructor for functions
78--
78--
79tyFunction :: Type
79tyFunction :: Type
80−tyFunction = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prelude") (ProperName "(->)")
80+tyFunction = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prelude") (ProperName "Function")
81
81
82-- |
82-- |
83-- Type constructor for strings
83-- Type constructor for strings
@@ -101,7 +101,7 @@ tyBoolean = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prelu
101-- Type constructor for arrays
101-- Type constructor for arrays
102--
102--
103tyArray :: Type
103tyArray :: Type
104−tyArray = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prelude") (ProperName "[]")
104+tyArray = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prelude") (ProperName "Array")
105
105
106-- |
106-- |
107-- Smart constructor for function types
107-- Smart constructor for function types