Defines a function to parse a string into a list of declarations. This module is based on the 'haskell-src' package most probably included with every Haskell compiler.
Parses a string to a list of declarations. The string should contain a Haskell module.
This function is based on the Haskell98 parser of the 'haskell-src' package, i.e. the module 'Language.Haskell.Parser'. That parser supports only Haskell98 and a few extensions. Especially, it does not support explicit quantification of type variables and thus no higher-rank functions.
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.
- 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.
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