File tree Expand file tree Collapse file tree 7 files changed +23
-9
lines changed
Expand file tree Collapse file tree 7 files changed +23
-9
lines changed Original file line number Diff line number Diff line change 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" )
Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ module Prelude where
33 foreign import data String :: *
44 foreign import data Number :: *
55 foreign import data Boolean :: *
6- foreign import data [] :: * -> *
7- foreign import data ( -> ) :: * -> * -> *
6+ foreign import data Array :: * -> *
7+ foreign import data Function :: * -> * -> *
88
99 id :: forall a . a -> a
1010 id = \x -> x
Original file line number Diff line number Diff line change @@ -239,9 +239,6 @@ natural = PT.natural tokenParser
239239properName :: P. Parsec String u ProperName
240240properName = lexeme $ ProperName <$> P. try ((:) <$> P. upper <*> many (PT. identLetter langDef) P. <?> " name" )
241241
242- properNameOrExternalType :: P. Parsec String u ProperName
243- properNameOrExternalType = P. try properName <|> (ProperName <$> (P. try (lexeme $ P. string " []" ) <|> (lexeme $ P. string " (->)" )))
244-
245242-- |
246243-- Parse a qualified name, i.e. M.name or just name
247244--
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ parseValueDeclaration =
6464
6565parseExternDeclaration :: P. Parsec String ParseState Declaration
6666parseExternDeclaration = P. try (reserved " foreign" ) *> indented *> (reserved " import" ) *> indented *>
67- (ExternDataDeclaration <$> (P. try (reserved " data" ) *> indented *> properNameOrExternalType )
67+ (ExternDataDeclaration <$> (P. try (reserved " data" ) *> indented *> properName )
6868 <*> (lexeme (indented *> P. string " ::" ) *> parseKind)
6969 <|> do ident <- parseNonReservedIdent
7070 js <- P. optionMaybe (parseJSLiteral <$> stringLiteral)
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ typeLiterals = mkPattern match
3333 where
3434 match (Object row) = Just $ " { " ++ prettyPrintType row ++ " }"
3535 match (TypeVar var) = Just var
36+ match (TypeApp arr ty) | arr == tyArray = Just $ " [" ++ prettyPrintType ty ++ " ]"
3637 match (TypeConstructor ctor) = Just $ show ctor
3738 match (TUnknown (TypedUnknown (Unknown u))) = Just $ ' u' : show u
3839 match (Skolem s) = Just $ ' s' : show s
Original file line number Diff line number Diff line change @@ -922,7 +922,8 @@ checkFunctionApplication fn fnTy arg ret = rethrow errorMessage $ checkFunctionA
922922-- Check the type of a function application
923923--
924924checkFunctionApplication' :: 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
926927 arg' <- check arg argTy
927928 _ <- subsumes Nothing retTy ret
928929 return $ App fn arg'
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ data Type
7777-- Type constructor for functions
7878--
7979tyFunction :: Type
80- tyFunction = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName " Prelude" ) (ProperName " (->) " )
80+ tyFunction = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName " Prelude" ) (ProperName " Function " )
8181
8282-- |
8383-- Type constructor for strings
@@ -101,7 +101,7 @@ tyBoolean = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName "Prelu
101101-- Type constructor for arrays
102102--
103103tyArray :: Type
104- tyArray = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName " Prelude" ) (ProperName " [] " )
104+ tyArray = TypeConstructor $ (Qualified $ Just $ ModuleName $ ProperName " Prelude" ) (ProperName " Array " )
105105
106106-- |
107107-- Smart constructor for function types
You can’t perform that action at this time.
0 commit comments