@@ -20,6 +20,7 @@ module Language.PureScript.Parser.Declarations (
2020) where
2121
2222import Data.Maybe (isJust, fromMaybe)
23+import Control.Monad (when)
2324import Control.Applicative
2425import qualified Text.Parsec as P
2526
@@ -45,7 +46,7 @@ parseDataDeclaration = do
4546
4647parseTypeDeclaration :: P.Parsec String ParseState Declaration
4748parseTypeDeclaration =
48− TypeDeclaration <$> P.try (parseIdent <* lexeme (indented *> P.string "::"))
49+ TypeDeclaration <$> P.try (parseNonReservedIdent <* lexeme (indented *> P.string "::"))
4950 <*> parsePolyType
5051
5152parseTypeSynonymDeclaration :: P.Parsec String ParseState Declaration
@@ -56,7 +57,7 @@ parseTypeSynonymDeclaration =
5657
5758parseValueDeclaration :: P.Parsec String ParseState Declaration
5859parseValueDeclaration =
59− ValueDeclaration <$> parseIdent
60+ ValueDeclaration <$> parseNonReservedIdent
6061 <*> P.many parseTopLevelBinder
6162 <*> P.optionMaybe parseGuard
6263 <*> ((lexeme (indented *> P.char '=')) *> parseValue)
@@ -68,7 +69,7 @@ parseExternDeclaration :: P.Parsec String ParseState Declaration
6869parseExternDeclaration = P.try (reserved "foreign") *> indented *> (reserved "import") *> indented *>
6970 (ExternDataDeclaration <$> (P.try (reserved "data") *> indented *> properName)
7071 <*> (lexeme (indented *> P.string "::") *> parseKind)
71− <|> do ident <- parseIdent
72+ <|> do ident <- parseNonReservedIdent
7273 js <- P.optionMaybe (parseJSLiteral <$> stringLiteral)
7374 ty <- (lexeme (indented *> P.string "::") *> parsePolyType)
7475 return $ ExternDeclaration (if isJust js then InlineJavascript else ForeignImport) ident js ty)