free-theorems-0.3.2.1: Automatic generation of free theorems.
Safe HaskellSafe-Inferred
LanguageHaskell98

Language.Haskell.FreeTheorems.Parser.Haskell98

Description

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.

Synopsis

Documentation

parse :: String -> Parsed [Declaration] Source #

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 type, data, newtype, 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 a is not accepted.
  • Contexts and deriving parts in data and newtype declarations 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 empty list. 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 successfully.