curry-base-1.1.0: Functions for manipulating Curry programs

Copyright(c) 1999 - 2004 Wolfgang Lux
2005 Martin Engelke
2011 - 2014 Björn Peemöller
2015 Jan Tikovsky
2016 Finn Teegen
LicenseBSD-3-clause
Maintainerbjp@informatik.uni-kiel.de
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Curry.Syntax.Utils

Description

This module provides some utility functions for working with the abstract syntax tree of Curry.

Synopsis

Documentation

hasLanguageExtension :: Module a -> KnownExtension -> Bool Source #

Check whether a Module has a specific Extension enabled by a pragma

knownExtensions :: Module a -> [KnownExtension] Source #

Extract all known extensions from a Module

isTopDecl :: Decl a -> Bool Source #

Is the declaration a top declaration?

isBlockDecl :: Decl a -> Bool Source #

Is the declaration a block declaration?

isTypeSig :: Decl a -> Bool Source #

Is the declaration a type signature?

infixOp :: InfixOp a -> Expression a Source #

Convert an infix operator into an expression

isTypeDecl :: Decl a -> Bool Source #

Is the declaration a type declaration?

isValueDecl :: Decl a -> Bool Source #

Is the declaration a value declaration?

isInfixDecl :: Decl a -> Bool Source #

Is the declaration an infix declaration?

isDefaultDecl :: Decl a -> Bool Source #

Is the declaration a default declaration?

isClassDecl :: Decl a -> Bool Source #

Is the declaration a class declaration?

isTypeOrClassDecl :: Decl a -> Bool Source #

Is the declaration a type or a class declaration?

isInstanceDecl :: Decl a -> Bool Source #

Is the declaration an instance declaration?

isFunctionDecl :: Decl a -> Bool Source #

Is the declaration a function declaration?

isExternalDecl :: Decl a -> Bool Source #

Is the declaration an external declaration?

patchModuleId :: FilePath -> Module a -> Module a Source #

Replace the generic module name main with the module name derived from the FilePath of the module.

isVariablePattern :: Pattern a -> Bool Source #

Is the pattern semantically equivalent to a variable pattern?

isVariableType :: TypeExpr -> Bool Source #

Is a type expression a type variable?

isSimpleType :: TypeExpr -> Bool Source #

Is a type expression simple, i.e., is it of the form T u_1 ... u_n, where T is a type constructor and u_1 ... u_n are type variables?

typeConstr :: TypeExpr -> QualIdent Source #

Return the qualified type constructor of a type expression.

typeVariables :: TypeExpr -> [Ident] Source #

Return the list of variables occuring in a type expression.

varIdent :: Var a -> Ident Source #

Return the identifier of a variable.

flatLhs :: Lhs a -> (Ident, [Pattern a]) Source #

flatten the left-hand-side to the identifier and all constructor terms

eqnArity :: Equation a -> Int Source #

Return the arity of an equation.

fieldLabel :: Field a -> QualIdent Source #

Select the label of a field

fieldTerm :: Field a -> a Source #

Select the term of a field

field2Tuple :: Field a -> (QualIdent, a) Source #

Select the label and term of a field

opName :: InfixOp a -> QualIdent Source #

Get the operator name of an infix operator

funDecl :: SpanInfo -> a -> Ident -> [Pattern a] -> Expression a -> Decl a Source #

constrPattern :: a -> QualIdent -> [(a, Ident)] -> Pattern a Source #

constrId :: ConstrDecl -> Ident Source #

Get the identifier of a constructor declaration

nconstrId :: NewConstrDecl -> Ident Source #

Get the identifier of a newtype constructor declaration

nconstrType :: NewConstrDecl -> TypeExpr Source #

Get the type of a newtype constructor declaration

recordLabels :: ConstrDecl -> [Ident] Source #

Get record label identifiers of a constructor declaration

nrecordLabels :: NewConstrDecl -> [Ident] Source #

Get record label identifier of a newtype constructor declaration

methods :: Decl a -> [Ident] Source #

Get the declared method identifiers of a type class method declaration

impls :: Decl a -> [Ident] Source #

Get the method identifiers of a type class method implementations

imethod :: IMethodDecl -> Ident Source #

Get the declared method identifier of an interface method declaration

imethodArity :: IMethodDecl -> Maybe Int Source #

Get the arity of an interface method declaration