@@ -48,22 +48,13 @@ sourcePos = toSourcePos <$> P.getPosition
49parseDataDeclaration :: P.Parsec String ParseState Declaration
49parseDataDeclaration :: P.Parsec String ParseState Declaration
50parseDataDeclaration = do
50parseDataDeclaration = do
51− reserved "data"
51+ dtype <- (reserved "data" *> return Data) <|> (reserved "newtype" *> return Newtype)
52 name <- indented *> properName
52 name <- indented *> properName
53 tyArgs <- many (indented *> identifier)
53 tyArgs <- many (indented *> identifier)
54 ctors <- P.option [] $ do
54 ctors <- P.option [] $ do
55 _ <- lexeme $ indented *> P.char '='
55 _ <- lexeme $ indented *> P.char '='
56 sepBy1 ((,) <$> properName <*> P.many (indented *> parseTypeAtom)) pipe
56 sepBy1 ((,) <$> properName <*> P.many (indented *> parseTypeAtom)) pipe
57− return $ DataDeclaration Data name tyArgs ctors
57+ return $ DataDeclaration dtype name tyArgs ctors
59−parseNewtypeDeclaration :: P.Parsec String ParseState Declaration
60−parseNewtypeDeclaration = do
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]
68parseTypeDeclaration :: P.Parsec String ParseState Declaration
59parseTypeDeclaration :: P.Parsec String ParseState Declaration
69parseTypeDeclaration =
60parseTypeDeclaration =
@@ -190,7 +181,6 @@ positioned d = PositionedDeclaration <$> sourcePos <*> d
190parseDeclaration :: P.Parsec String ParseState Declaration
181parseDeclaration :: P.Parsec String ParseState Declaration
191parseDeclaration = positioned (P.choice
182parseDeclaration = positioned (P.choice
192 [ parseDataDeclaration
183 [ parseDataDeclaration
193− , parseNewtypeDeclaration
194 , parseTypeDeclaration
184 , parseTypeDeclaration
195 , parseTypeSynonymDeclaration
185 , parseTypeSynonymDeclaration
196 , parseValueDeclaration
186 , parseValueDeclaration