@@ -96,6 +96,24 @@ parseImportDeclaration = do
96 idents <- P.optionMaybe $ parens $ commaSep1 (Left <$> parseIdent <|> Right <$> properName)
96 idents <- P.optionMaybe $ parens $ commaSep1 (Left <$> parseIdent <|> Right <$> properName)
97 return $ ImportDeclaration moduleName idents
97 return $ ImportDeclaration moduleName idents
99+parseTypeClassDeclaration :: P.Parsec String ParseState Declaration
100+parseTypeClassDeclaration = do
102+ className <- indented *> properName
103+ ident <- indented *> parseIdent
104+ indented *> reserved "where"
105+ members <- mark (P.many (same *> parseTypeDeclaration))
106+ return $ TypeClassDeclaration className ident members
108+parseTypeInstanceDeclaration :: P.Parsec String ParseState Declaration
109+parseTypeInstanceDeclaration = do
111+ className <- indented *> properName
112+ ty <- indented *> parseType
113+ indented *> reserved "where"
114+ members <- mark (P.many (same *> parseValueDeclaration))
115+ return $ TypeInstanceDeclaration className ty members
99parseDeclaration :: P.Parsec String ParseState Declaration
117parseDeclaration :: P.Parsec String ParseState Declaration
100parseDeclaration = P.choice
118parseDeclaration = P.choice
101 [ parseDataDeclaration
119 [ parseDataDeclaration
@@ -104,7 +122,9 @@ parseDeclaration = P.choice
104 , parseValueDeclaration
122 , parseValueDeclaration
105 , parseExternDeclaration
123 , parseExternDeclaration
106 , parseFixityDeclaration
124 , parseFixityDeclaration
107− , parseImportDeclaration ] P.<?> "declaration"
125+ , parseImportDeclaration
126+ , parseTypeClassDeclaration
127+ , parseTypeInstanceDeclaration ] P.<?> "declaration"
109parseModule :: P.Parsec String ParseState Module
129parseModule :: P.Parsec String ParseState Module
110parseModule = do
130parseModule = do