Import kinds for basic types
A bit hacky I think, not familiar enough with Parsec to know the best
way to do this
commitcbb46de6c35b7237d6b3a19a75b617fdbcf45711
authorGary Burgess <garyb@users.noreply.github.com>
dateSun 2 Feb 2014, 10:51 (13 years ago)
parent9f939a6
libraries/prelude/prelude.purs+6
@@ -1,5 +1,11 @@
11module Prelude where
22
3+ foreign import data String :: *
4+ foreign import data Number :: *
5+ foreign import data Boolean :: *
6+ foreign import data [] :: * -> *
7+ foreign import data (->) :: * -> * -> *
8+
39 id :: forall a. a -> a
410 id = \x -> x
511
src/Language/PureScript/Parser/Common.hs+3
@@ -239,6 +239,9 @@ 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+
242245-- |
243246-- Parse a qualified name, i.e. M.name or just name
244247--
src/Language/PureScript/Parser/Declarations.hs+1−1
@@ -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 *> properName)
67+ (ExternDataDeclaration <$> (P.try (reserved "data") *> indented *> properNameOrExternalType)
6868 <*> (lexeme (indented *> P.string "::") *> parseKind)
6969 <|> do ident <- parseNonReservedIdent
7070 js <- P.optionMaybe (parseJSLiteral <$> stringLiteral)
src/Language/PureScript/TypeChecker/Kinds.hs−5
@@ -117,11 +117,6 @@ starIfUnknown k = k
117117-- Infer a kind for a type
118118--
119119infer :: Type -> UnifyT Check Kind
120−infer t | t == tyNumber = return Star
121−infer t | t == tyString = return Star
122−infer t | t == tyBoolean = return Star
123−infer t | t == tyArray = return $ FunKind Star Star
124−infer t | t == tyFunction = return $ FunKind Star $ FunKind Star Star
125120infer (Object row) = do
126121 k <- infer row
127122 k ?= Row Star