@@ -48,22 +48,13 @@ sourcePos = toSourcePos <$> P.getPosition
4848
4949parseDataDeclaration :: P.Parsec String ParseState Declaration
5050parseDataDeclaration = do
51− reserved "data"
51+ dtype <- (reserved "data" *> return Data) <|> (reserved "newtype" *> return Newtype)
5252 name <- indented *> properName
5353 tyArgs <- many (indented *> identifier)
5454 ctors <- P.option [] $ do
5555 _ <- lexeme $ indented *> P.char '='
5656 sepBy1 ((,) <$> properName <*> P.many (indented *> parseTypeAtom)) pipe
57− return $ DataDeclaration Data name tyArgs ctors
58−
59−parseNewtypeDeclaration :: P.Parsec String ParseState Declaration
60−parseNewtypeDeclaration = do
61− reserved "newtype"
62− name <- indented *> properName
63− tyArg <- P.option [] $ return <$> (indented *> identifier)
64− _ <- lexeme $ indented *> P.char '='
65− ctor <- (,) <$> properName <*> (return <$> (indented *> parseTypeAtom))
66− return $ DataDeclaration Newtype name tyArg [ctor]
57+ return $ DataDeclaration dtype name tyArgs ctors
6758
6859parseTypeDeclaration :: P.Parsec String ParseState Declaration
6960parseTypeDeclaration =
@@ -190,7 +181,6 @@ positioned d = PositionedDeclaration <$> sourcePos <*> d
190181parseDeclaration :: P.Parsec String ParseState Declaration
191182parseDeclaration = positioned (P.choice
192183 [ parseDataDeclaration
193− , parseNewtypeDeclaration
194184 , parseTypeDeclaration
195185 , parseTypeSynonymDeclaration
196186 , parseValueDeclaration