-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Support for manipulating Haskell source code -- -- The 'haskell-src' package provides support for manipulating Haskell -- source code. The package provides a lexer, parser and pretty-printer, -- and a definition of a Haskell abstract syntax tree (AST). Common uses -- of this package are to parse or generate Haskell 98 code. @package haskell-src @version 1.0.1.4 -- | A suite of datatypes describing the abstract syntax of Haskell 98 -- http://www.haskell.org/onlinereport/ plus a few extensions: -- -- -- -- This module has been changed so that show is a real show. For GHC, we -- also derive Typeable and Data for all types. module Language.Haskell.Syntax -- | A Haskell source module. data HsModule HsModule :: SrcLoc -> Module -> (Maybe [HsExportSpec]) -> [HsImportDecl] -> [HsDecl] -> HsModule -- | Export specification. data HsExportSpec -- | variable HsEVar :: HsQName -> HsExportSpec -- | T: a class or datatype exported abstractly, or a type -- synonym. HsEAbs :: HsQName -> HsExportSpec -- | T(..): a class exported with all of its methods, or a -- datatype exported with all of its constructors. HsEThingAll :: HsQName -> HsExportSpec -- | T(C_1,...,C_n): a class exported with some of its methods, or -- a datatype exported with some of its constructors. HsEThingWith :: HsQName -> [HsCName] -> HsExportSpec -- | module M: re-export a module. HsEModuleContents :: Module -> HsExportSpec -- | Import declaration. data HsImportDecl HsImportDecl :: SrcLoc -> Module -> Bool -> Maybe Module -> Maybe (Bool, [HsImportSpec]) -> HsImportDecl -- | position of the import keyword. importLoc :: HsImportDecl -> SrcLoc -- | name of the module imported. importModule :: HsImportDecl -> Module -- | imported qualified? importQualified :: HsImportDecl -> Bool -- | optional alias name in an as clause. importAs :: HsImportDecl -> Maybe Module -- | optional list of import specifications. The Bool is True -- if the names are excluded by hiding. importSpecs :: HsImportDecl -> Maybe (Bool, [HsImportSpec]) -- | Import specification. data HsImportSpec -- | variable HsIVar :: HsName -> HsImportSpec -- | T: the name of a class, datatype or type synonym. HsIAbs :: HsName -> HsImportSpec -- | T(..): a class imported with all of its methods, or a -- datatype imported with all of its constructors. HsIThingAll :: HsName -> HsImportSpec -- | T(C_1,...,C_n): a class imported with some of its methods, or -- a datatype imported with some of its constructors. HsIThingWith :: HsName -> [HsCName] -> HsImportSpec -- | Associativity of an operator. data HsAssoc -- | non-associative operator (declared with infix) HsAssocNone :: HsAssoc -- | left-associative operator (declared with infixl). HsAssocLeft :: HsAssoc -- | right-associative operator (declared with infixr) HsAssocRight :: HsAssoc data HsDecl HsTypeDecl :: SrcLoc -> HsName -> [HsName] -> HsType -> HsDecl HsDataDecl :: SrcLoc -> HsContext -> HsName -> [HsName] -> [HsConDecl] -> [HsQName] -> HsDecl HsInfixDecl :: SrcLoc -> HsAssoc -> Int -> [HsOp] -> HsDecl HsNewTypeDecl :: SrcLoc -> HsContext -> HsName -> [HsName] -> HsConDecl -> [HsQName] -> HsDecl HsClassDecl :: SrcLoc -> HsContext -> HsName -> [HsName] -> [HsDecl] -> HsDecl HsInstDecl :: SrcLoc -> HsContext -> HsQName -> [HsType] -> [HsDecl] -> HsDecl HsDefaultDecl :: SrcLoc -> [HsType] -> HsDecl HsTypeSig :: SrcLoc -> [HsName] -> HsQualType -> HsDecl HsFunBind :: [HsMatch] -> HsDecl HsPatBind :: SrcLoc -> HsPat -> HsRhs -> [HsDecl] -> HsDecl HsForeignImport :: SrcLoc -> String -> HsSafety -> String -> HsName -> HsType -> HsDecl HsForeignExport :: SrcLoc -> String -> String -> HsName -> HsType -> HsDecl -- | Declaration of a data constructor. data HsConDecl -- | ordinary data constructor HsConDecl :: SrcLoc -> HsName -> [HsBangType] -> HsConDecl -- | record constructor HsRecDecl :: SrcLoc -> HsName -> [([HsName], HsBangType)] -> HsConDecl -- | The type of a constructor argument or field, optionally including a -- strictness annotation. data HsBangType -- | strict component, marked with "!" HsBangedTy :: HsType -> HsBangType -- | non-strict component HsUnBangedTy :: HsType -> HsBangType -- | Clauses of a function binding. data HsMatch HsMatch :: SrcLoc -> HsName -> [HsPat] -> HsRhs -> [HsDecl] -> HsMatch -- | The right hand side of a function or pattern binding. data HsRhs -- | unguarded right hand side (exp) HsUnGuardedRhs :: HsExp -> HsRhs -- | guarded right hand side (gdrhs) HsGuardedRhss :: [HsGuardedRhs] -> HsRhs -- | A guarded right hand side | exp = exp. -- The first expression will be Boolean-valued. data HsGuardedRhs HsGuardedRhs :: SrcLoc -> HsExp -> HsExp -> HsGuardedRhs -- | Safety level for invoking a foreign entity data HsSafety -- | call may generate callbacks HsSafe :: HsSafety -- | call will not generate callbacks HsUnsafe :: HsSafety -- | A type qualified with a context. An unqualified type has an empty -- context. data HsQualType HsQualType :: HsContext -> HsType -> HsQualType type HsContext = [HsAsst] -- | Class assertions. In Haskell 98, the argument would be a tyvar, -- but this definition allows multiple parameters, and allows them to be -- types. type HsAsst = (HsQName, [HsType]) -- | Haskell types and type constructors. data HsType -- | function type HsTyFun :: HsType -> HsType -> HsType -- | tuple type HsTyTuple :: [HsType] -> HsType -- | application of a type constructor HsTyApp :: HsType -> HsType -> HsType -- | type variable HsTyVar :: HsName -> HsType -- | named type or type constructor HsTyCon :: HsQName -> HsType -- | Haskell expressions. -- -- Notes: -- -- data HsExp -- | variable HsVar :: HsQName -> HsExp -- | data constructor HsCon :: HsQName -> HsExp -- | literal constant HsLit :: HsLiteral -> HsExp -- | infix application HsInfixApp :: HsExp -> HsQOp -> HsExp -> HsExp -- | ordinary application HsApp :: HsExp -> HsExp -> HsExp -- | negation expression - exp HsNegApp :: HsExp -> HsExp -- | lambda expression HsLambda :: SrcLoc -> [HsPat] -> HsExp -> HsExp -- | local declarations with let HsLet :: [HsDecl] -> HsExp -> HsExp -- | if exp then exp else -- exp HsIf :: HsExp -> HsExp -> HsExp -> HsExp -- | case exp of alts HsCase :: HsExp -> [HsAlt] -> HsExp -- | do-expression: the last statement in the list should be an -- expression. HsDo :: [HsStmt] -> HsExp -- | tuple expression HsTuple :: [HsExp] -> HsExp -- | list expression HsList :: [HsExp] -> HsExp -- | parenthesized expression HsParen :: HsExp -> HsExp -- | left section (exp qop) HsLeftSection :: HsExp -> HsQOp -> HsExp -- | right section (qop exp) HsRightSection :: HsQOp -> HsExp -> HsExp -- | record construction expression HsRecConstr :: HsQName -> [HsFieldUpdate] -> HsExp -- | record update expression HsRecUpdate :: HsExp -> [HsFieldUpdate] -> HsExp -- | unbounded arithmetic sequence, incrementing by 1 HsEnumFrom :: HsExp -> HsExp -- | bounded arithmetic sequence, incrementing by 1 HsEnumFromTo :: HsExp -> HsExp -> HsExp -- | unbounded arithmetic sequence, with first two elements given HsEnumFromThen :: HsExp -> HsExp -> HsExp -- | bounded arithmetic sequence, with first two elements given HsEnumFromThenTo :: HsExp -> HsExp -> HsExp -> HsExp -- | list comprehension HsListComp :: HsExp -> [HsStmt] -> HsExp -- | expression type signature HsExpTypeSig :: SrcLoc -> HsExp -> HsQualType -> HsExp -- | patterns only HsAsPat :: HsName -> HsExp -> HsExp -- | patterns only HsWildCard :: HsExp -- | patterns only HsIrrPat :: HsExp -> HsExp -- | This type represents both stmt in a do-expression, and -- qual in a list comprehension. data HsStmt -- | a generator pat <- exp HsGenerator :: SrcLoc -> HsPat -> HsExp -> HsStmt -- | an exp by itself: in a do-expression, an action whose -- result is discarded; in a list comprehension, a guard expression HsQualifier :: HsExp -> HsStmt -- | local bindings HsLetStmt :: [HsDecl] -> HsStmt -- | An fbind in a labeled record construction or update expression. data HsFieldUpdate HsFieldUpdate :: HsQName -> HsExp -> HsFieldUpdate -- | An alt in a case expression. data HsAlt HsAlt :: SrcLoc -> HsPat -> HsGuardedAlts -> [HsDecl] -> HsAlt data HsGuardedAlts -- | -> exp HsUnGuardedAlt :: HsExp -> HsGuardedAlts -- | gdpat HsGuardedAlts :: [HsGuardedAlt] -> HsGuardedAlts -- | A guarded alternative | exp -> exp. -- The first expression will be Boolean-valued. data HsGuardedAlt HsGuardedAlt :: SrcLoc -> HsExp -> HsExp -> HsGuardedAlt -- | A pattern, to be matched against a value. data HsPat -- | variable HsPVar :: HsName -> HsPat -- | literal constant HsPLit :: HsLiteral -> HsPat -- | negated pattern HsPNeg :: HsPat -> HsPat -- | pattern with infix data constructor HsPInfixApp :: HsPat -> HsQName -> HsPat -> HsPat -- | data constructor and argument patterns HsPApp :: HsQName -> [HsPat] -> HsPat -- | tuple pattern HsPTuple :: [HsPat] -> HsPat -- | list pattern HsPList :: [HsPat] -> HsPat -- | parenthesized pattern HsPParen :: HsPat -> HsPat -- | labelled pattern HsPRec :: HsQName -> [HsPatField] -> HsPat -- | @-pattern HsPAsPat :: HsName -> HsPat -> HsPat -- | wildcard pattern (_) HsPWildCard :: HsPat -- | irrefutable pattern (~) HsPIrrPat :: HsPat -> HsPat -- | An fpat in a labeled record pattern. data HsPatField HsPFieldPat :: HsQName -> HsPat -> HsPatField -- | literal. Values of this type hold the abstract value of the -- literal, not the precise string representation used. For example, -- 10, 0o12 and 0xa have the same -- representation. data HsLiteral -- | character literal HsChar :: Char -> HsLiteral -- | string literal HsString :: String -> HsLiteral -- | integer literal HsInt :: Integer -> HsLiteral -- | floating point literal HsFrac :: Rational -> HsLiteral -- | GHC unboxed character literal HsCharPrim :: Char -> HsLiteral -- | GHC unboxed string literal HsStringPrim :: String -> HsLiteral -- | GHC unboxed integer literal HsIntPrim :: Integer -> HsLiteral -- | GHC unboxed float literal HsFloatPrim :: Rational -> HsLiteral -- | GHC unboxed double literal HsDoublePrim :: Rational -> HsLiteral -- | The name of a Haskell module. newtype Module Module :: String -> Module -- | This type is used to represent qualified variables, and also qualified -- constructors. data HsQName -- | name qualified with a module name Qual :: Module -> HsName -> HsQName -- | unqualified name UnQual :: HsName -> HsQName -- | built-in constructor with special syntax Special :: HsSpecialCon -> HsQName -- | This type is used to represent variables, and also constructors. data HsName -- | varid or conid HsIdent :: String -> HsName -- | varsym or consym HsSymbol :: String -> HsName -- | Possibly qualified infix operators (qop), appearing in -- expressions. data HsQOp -- | variable operator (qvarop) HsQVarOp :: HsQName -> HsQOp -- | constructor operator (qconop) HsQConOp :: HsQName -> HsQOp -- | Operators, appearing in infix declarations. data HsOp -- | variable operator (varop) HsVarOp :: HsName -> HsOp -- | constructor operator (conop) HsConOp :: HsName -> HsOp -- | Constructors with special syntax. These names are never qualified, and -- always refer to builtin type or data constructors. data HsSpecialCon -- | unit type and data constructor () HsUnitCon :: HsSpecialCon -- | list type constructor [] HsListCon :: HsSpecialCon -- | function type constructor -> HsFunCon :: HsSpecialCon -- | n-ary tuple type and data constructors (,) etc HsTupleCon :: Int -> HsSpecialCon -- | list data constructor (:) HsCons :: HsSpecialCon -- | A name (cname) of a component of a class or data type in an -- import or export specification. data HsCName -- | name of a method or field HsVarName :: HsName -> HsCName -- | name of a data constructor HsConName :: HsName -> HsCName prelude_mod :: Module main_mod :: Module main_name :: HsName unit_con_name :: HsQName tuple_con_name :: Int -> HsQName list_cons_name :: HsQName unit_con :: HsExp tuple_con :: Int -> HsExp unit_tycon_name :: HsQName fun_tycon_name :: HsQName list_tycon_name :: HsQName tuple_tycon_name :: Int -> HsQName unit_tycon :: HsType fun_tycon :: HsType list_tycon :: HsType tuple_tycon :: Int -> HsType -- | A position in the source. data SrcLoc SrcLoc :: String -> Int -> Int -> SrcLoc srcFilename :: SrcLoc -> String srcLine :: SrcLoc -> Int srcColumn :: SrcLoc -> Int instance Typeable SrcLoc instance Typeable Module instance Typeable HsSpecialCon instance Typeable HsName instance Typeable HsQName instance Typeable HsQOp instance Typeable HsOp instance Typeable HsCName instance Typeable HsExportSpec instance Typeable HsImportSpec instance Typeable HsImportDecl instance Typeable HsAssoc instance Typeable HsSafety instance Typeable HsType instance Typeable HsBangType instance Typeable HsConDecl instance Typeable HsQualType instance Typeable HsLiteral instance Typeable HsPatField instance Typeable HsPat instance Typeable HsGuardedAlt instance Typeable HsExp instance Typeable HsAlt instance Typeable HsGuardedAlts instance Typeable HsDecl instance Typeable HsRhs instance Typeable HsGuardedRhs instance Typeable HsMatch instance Typeable HsFieldUpdate instance Typeable HsStmt instance Typeable HsModule instance Eq SrcLoc instance Ord SrcLoc instance Show SrcLoc instance Data SrcLoc instance Eq Module instance Ord Module instance Show Module instance Data Module instance Eq HsSpecialCon instance Ord HsSpecialCon instance Show HsSpecialCon instance Data HsSpecialCon instance Eq HsName instance Ord HsName instance Show HsName instance Data HsName instance Eq HsQName instance Ord HsQName instance Show HsQName instance Data HsQName instance Eq HsQOp instance Ord HsQOp instance Show HsQOp instance Data HsQOp instance Eq HsOp instance Ord HsOp instance Show HsOp instance Data HsOp instance Eq HsCName instance Ord HsCName instance Show HsCName instance Data HsCName instance Eq HsExportSpec instance Show HsExportSpec instance Data HsExportSpec instance Eq HsImportSpec instance Show HsImportSpec instance Data HsImportSpec instance Eq HsImportDecl instance Show HsImportDecl instance Data HsImportDecl instance Eq HsAssoc instance Show HsAssoc instance Data HsAssoc instance Eq HsSafety instance Ord HsSafety instance Show HsSafety instance Data HsSafety instance Eq HsType instance Show HsType instance Data HsType instance Eq HsBangType instance Show HsBangType instance Data HsBangType instance Eq HsConDecl instance Show HsConDecl instance Data HsConDecl instance Eq HsQualType instance Show HsQualType instance Data HsQualType instance Eq HsLiteral instance Show HsLiteral instance Data HsLiteral instance Eq HsPatField instance Show HsPatField instance Data HsPatField instance Eq HsPat instance Show HsPat instance Data HsPat instance Eq HsGuardedAlt instance Show HsGuardedAlt instance Data HsGuardedAlt instance Eq HsExp instance Show HsExp instance Data HsExp instance Eq HsAlt instance Show HsAlt instance Data HsAlt instance Eq HsGuardedAlts instance Show HsGuardedAlts instance Data HsGuardedAlts instance Eq HsDecl instance Show HsDecl instance Data HsDecl instance Eq HsRhs instance Show HsRhs instance Data HsRhs instance Eq HsGuardedRhs instance Show HsGuardedRhs instance Data HsGuardedRhs instance Eq HsMatch instance Show HsMatch instance Data HsMatch instance Eq HsFieldUpdate instance Show HsFieldUpdate instance Data HsFieldUpdate instance Eq HsStmt instance Show HsStmt instance Data HsStmt instance Show HsModule instance Data HsModule -- | Pretty printer for Haskell. module Language.Haskell.Pretty -- | Things that can be pretty-printed, including all the syntactic objects -- in Language.Haskell.Syntax. class Pretty a -- | pretty-print with a given style and mode. prettyPrintStyleMode :: Pretty a => Style -> PPHsMode -> a -> String -- | pretty-print with the default style and a given mode. prettyPrintWithMode :: Pretty a => PPHsMode -> a -> String -- | pretty-print with the default style and defaultMode. prettyPrint :: Pretty a => a -> String -- | A rendering style. data Style :: * Style :: Mode -> Int -> Float -> Style -- | The rendering mode mode :: Style -> Mode -- | Length of line, in chars lineLength :: Style -> Int -- | Ratio of ribbon length to line length ribbonsPerLine :: Style -> Float -- | The default style (mode=PageMode, lineLength=100, -- ribbonsPerLine=1.5). style :: Style -- | Rendering mode. data Mode :: * -- | Normal PageMode :: Mode -- | With zig-zag cuts ZigZagMode :: Mode -- | No indentation, infinitely long lines LeftMode :: Mode -- | All on one line OneLineMode :: Mode -- | Pretty-printing parameters. -- -- Note: the onsideIndent must be positive and less than -- all other indents. data PPHsMode PPHsMode :: Indent -> Indent -> Indent -> Indent -> Indent -> Indent -> Bool -> PPLayout -> Bool -> Bool -> PPHsMode -- | indentation of a class or instance classIndent :: PPHsMode -> Indent -- | indentation of a do-expression doIndent :: PPHsMode -> Indent -- | indentation of the body of a case expression caseIndent :: PPHsMode -> Indent -- | indentation of the declarations in a let expression letIndent :: PPHsMode -> Indent -- | indentation of the declarations in a where clause whereIndent :: PPHsMode -> Indent -- | indentation added for continuation lines that would otherwise be -- offside onsideIndent :: PPHsMode -> Indent -- | blank lines between statements? spacing :: PPHsMode -> Bool -- | Pretty-printing style to use layout :: PPHsMode -> PPLayout -- | add GHC-style LINE pragmas to output? linePragmas :: PPHsMode -> Bool -- | not implemented yet comments :: PPHsMode -> Bool type Indent = Int -- | Varieties of layout we can use. data PPLayout -- | classical layout PPOffsideRule :: PPLayout -- | classical layout made explicit PPSemiColon :: PPLayout -- | inline decls, with newlines between them PPInLine :: PPLayout -- | everything on a single line PPNoLayout :: PPLayout -- | The default mode: pretty-print using the offside rule and sensible -- defaults. defaultMode :: PPHsMode instance Eq PPLayout instance Pretty HsCName instance Pretty HsName instance Pretty HsOp instance Pretty HsQName instance Pretty HsQOp instance Pretty HsFieldUpdate instance Pretty HsStmt instance Pretty HsGuardedAlt instance Pretty HsGuardedAlts instance Pretty HsAlt instance Pretty HsPatField instance Pretty HsPat instance Pretty HsExp instance Pretty HsLiteral instance Pretty HsGuardedRhs instance Pretty HsRhs instance Pretty HsType instance Pretty HsQualType instance Pretty HsBangType instance Pretty HsConDecl instance Pretty HsMatch instance Pretty HsSafety instance Pretty HsAssoc instance Pretty HsDecl instance Pretty HsImportSpec instance Pretty HsImportDecl instance Pretty HsExportSpec instance Pretty Module instance Pretty HsModule instance Monad (DocM s) instance Functor (DocM s) -- | Haskell parser. module Language.Haskell.Parser -- | Parse of a string, which should contain a complete Haskell 98 module. parseModule :: String -> ParseResult HsModule -- | Parse of a string, which should contain a complete Haskell 98 module. parseModuleWithMode :: ParseMode -> String -> ParseResult HsModule -- | Static parameters governing a parse. More to come later, e.g. literate -- mode, language extensions. data ParseMode ParseMode :: String -> ParseMode -- | original name of the file being parsed parseFilename :: ParseMode -> String -- | Default parameters for a parse, currently just a marker for an unknown -- filename. defaultParseMode :: ParseMode -- | The result of a parse. data ParseResult a -- | The parse succeeded, yielding a value. ParseOk :: a -> ParseResult a -- | The parse failed at the specified source location, with an error -- message. ParseFailed :: SrcLoc -> String -> ParseResult a