Parses a string to a list of declarations. The string should contain a Haskell module.
This function is based on the extended Haskell parser of the 'haskell-src-exts' package.
The declarations returned by
parse include only
class and type signature declarations.
All other declarations and syntactical elements in the input are ignored.
Furthermore, the following restrictions apply:
- Multi-parameter type classes are not allowed and therefore ignored. When declaring a type class, the argument to the type class name must be a single type variable.
- Only type variables can be constrained by type classes. That means, for
example, the type
Eq [a] => [a]is not accepted.
- A type variable must not be applied to any type. That means, for
example, that the type
m ais not accepted.
- Contexts and
newtypedeclarations are ignored.
- The module names are ignored. If any identifier was given qualified, the module part of a qualified name is ignored.
- Special Haskell constructors (unit, list function) are not allowed as identifiers.
- Further extensions over Haskell98 allowed by the underlying parser are also forbidden, namely generalised algebraic data types and unboxed tuples.
If a parser error occurs, as suitable error message is returned in the
second component of the returned tuple and the first component will be the
However, if parsing was successful, but the parsed structures could not
be completely transformed into
Declarations, suitable transformation
error messages are returned in the second component while the first
components contains all declarations which could be transformed