-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Compile the functional logic language Curry to several
--   intermediate formats
--   
--   The Curry front end consists of the executable program
--   "curry-frontend". It is used by various backends to compile Curry
--   programs to an intermediate representation. The code is a
--   stripped-down version of an early version of the Muenster Curry
--   Compiler (<a>http://danae.uni-muenster.de/curry/</a>) which has been
--   extended to produce different intermediate representations. For
--   further information, please check <a>http://curry-language.org</a>
@package curry-frontend
@version 2.0.0


-- | This module modules provides the definitions for the internal
--   representation of kinds in the compiler.
module Base.Kinds
data Kind
KindStar :: Kind
KindVariable :: Int -> Kind
KindArrow :: Kind -> Kind -> Kind

-- | The function <a>kindArity</a> computes the arity n of a kind.
kindArity :: Kind -> Int

-- | The function <a>kindVars</a> returns a list of all kind variables
--   occurring in a kind.
kindVars :: Kind -> [Int]

-- | The function <a>defaultKind</a> instantiates all kind variables
--   occurring in a kind to *.
defaultKind :: Kind -> Kind

-- | The function <a>simpleKind</a> returns the kind of a type constructor
--   with arity n whose arguments all have kind *.
simpleKind :: Int -> Kind

-- | The function <a>isSimpleKind</a> returns whether a kind is simple or
--   not.
isSimpleKind :: Kind -> Bool

-- | Fetches a kind's <tt>arguments</tt>, i.e. everything before an arrow
--   at the top-level. For example: A kind k1 -&gt; k2 -&gt; k3 would have
--   the arguments [k1, k2].
kindArgs :: Kind -> [Kind]
instance GHC.Show.Show Base.Kinds.Kind
instance GHC.Classes.Eq Base.Kinds.Kind


-- | At various places in the compiler we had to partition a list of
--   declarations into strongly connected components. The function
--   <a>scc</a> computes this relation in two steps. First, the list is
--   topologically sorted downwards using the <tt>defs</tt> relation. Then
--   the resulting list is sorted upwards using the <tt>uses</tt> relation
--   and partitioned into the connected components. Both relations are
--   computed within this module using the bound and free names of each
--   declaration.
--   
--   In order to avoid useless recomputations, the code in the module first
--   decorates the declarations with their bound and free names and a
--   unique number. The latter is only used to provide a trivial ordering
--   so that the declarations can be used as set elements.
module Base.SCC

-- | Computation of strongly connected components
scc :: Eq b => (a -> [b]) -> (a -> [b]) -> [a] -> [[a]]
instance GHC.Classes.Eq (Base.SCC.Node a b)
instance GHC.Classes.Ord (Base.SCC.Node b a)


-- | The module Subst implements substitutions. A substitution sigma = {x_1
--   |-&gt; t_1, ... ,x_n |-&gt; t_n} is a finite mapping from (finitely
--   many) variables x_1, ... ,x_n to some kind of expression or term.
--   
--   In order to implement substitutions efficiently, composed
--   substitutions are marked with a boolean flag (see below).
module Base.Subst

-- | Data type for substitution
data Subst a b
Subst :: Bool -> Map a b -> Subst a b

-- | Type class for terms where variables are represented as <a>Int</a>s
class IntSubst e

-- | Construct a variable from an <a>Int</a>
ivar :: IntSubst e => Int -> e

-- | Apply a substitution to a term
isubst :: IntSubst e => Subst Int e -> e -> e

-- | Identity substitution
idSubst :: Subst a b

-- | Create a substitution for a single replacement
singleSubst :: Ord v => v -> e -> Subst v e

-- | Extend a substitution with a single replacement
bindSubst :: Ord v => v -> e -> Subst v e -> Subst v e

-- | Remove a single replacement from a substitution
unbindSubst :: Ord v => v -> Subst v e -> Subst v e

-- | Convert a substitution to a list of replacements
substToList :: Subst v e -> [(v, e)]

-- | Compose two substitutions
compose :: Ord v => Subst v e -> Subst v e -> Subst v e

-- | Apply a substitution to a variable
substVar' :: Ord v => (v -> e) -> (Subst v e -> e -> e) -> Subst v e -> v -> e

-- | Apply a substitution to a term with variables represented as
--   <a>Int</a>s
isubstVar :: IntSubst e => Subst Int e -> Int -> e

-- | The function <a>restrictSubstTo</a> implements the restriction of a
--   substitution to a given subset of its domain.
restrictSubstTo :: Ord v => [v] -> Subst v e -> Subst v e
instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Base.Subst.Subst a b)


-- | The module Utils provides a few simple functions that are commonly
--   used in the compiler, but not implemented in the Haskell Prelude or
--   standard library.
module Base.Utils
fst3 :: (a, b, c) -> a
snd3 :: (a, b, c) -> b
thd3 :: (a, b, c) -> c
curry3 :: ((a, b, c) -> d) -> a -> b -> c -> d
uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d
(++!) :: [a] -> [a] -> [a]
infixr 5 ++!
foldr2 :: (a -> b -> c -> c) -> c -> [a] -> [b] -> c
mapAccumM :: (Monad m, MonadPlus p) => (acc -> x -> m (acc, y)) -> acc -> [x] -> m (acc, p y)
findDouble :: Eq a => [a] -> Maybe a
findMultiples :: Eq a => [a] -> [[a]]


-- | This library contains a definition for representing Curry programs in
--   Haskell by the type <a>CurryProg</a> and I/O actions to read Curry
--   programs and transform them into this abstract representation as well
--   as write them to a file.
--   
--   Note that this defines a slightly new format for AbstractCurry in
--   comparison to the first proposal of 2003.
module Curry.AbstractCurry.Type

-- | A Curry module in the intermediate form. A value of this type has the
--   form <tt> CurryProg modname imports dfltdecl clsdecls instdecls
--   typedecls funcdecls opdecls </tt> where [<tt>modname</tt>] Name of
--   this module [<tt>imports</tt>] List of modules names that are imported
--   [<tt>dfltdecl</tt>] Optional default declaration [<tt>clsdecls</tt>]
--   Class declarations [<tt>instdecls</tt>] Instance declarations
--   [<tt>typedecls</tt>] Type declarations [<tt>funcdecls</tt>] Function
--   declarations [<tt>opdecls</tt>] Operator precedence declarations
data CurryProg
CurryProg :: MName -> [MName] -> Maybe CDefaultDecl -> [CClassDecl] -> [CInstanceDecl] -> [CTypeDecl] -> [CFuncDecl] -> [COpDecl] -> CurryProg

-- | A module name.
type MName = String

-- | A qualified name. In AbstractCurry all names are qualified to avoid
--   name clashes. The first component is the module name and the second
--   component the unqualified name as it occurs in the source program.
type QName = (MName, String)

-- | Data type to specify the visibility of various entities.
data CVisibility

-- | exported entity
Public :: CVisibility

-- | private entity
Private :: CVisibility

-- | The type for representing type variables. They are represented by
--   <tt>(i,n)</tt> where <tt>i</tt> is a type variable index which is
--   unique inside a function and <tt>n</tt> is a name (if possible, the
--   name written in the source program).
type CTVarIName = (Int, String)

-- | Default declaration.
data CDefaultDecl
CDefaultDecl :: [CTypeExpr] -> CDefaultDecl

-- | Definitions of type classes. A type class definition of the form <tt>
--   class cx =&gt; c a where { ...;f :: t;... } </tt> is represented by
--   the Curry term <tt> (CClass c v cx tv [...(CFunc f ar v t [...,CRule
--   r,...])...]) </tt> where <tt>tv</tt> is the index of the type variable
--   <tt>a</tt> and <tt>v</tt> is the visibility of the type class resp.
--   method. <i>Note:</i> The type variable indices are unique inside each
--   class declaration and are usually numbered from 0. The methods' types
--   share the type class' type variable index as the class variable has to
--   occur in a method's type signature. The list of rules for a method's
--   declaration may be empty if no default implementation is provided. The
--   arity <tt>ar</tt> is determined by a given default implementation or
--   0. Regardless of whether typed or untyped abstract curry is generated,
--   the methods' declarations are always typed.
data CClassDecl
CClass :: QName -> CVisibility -> CContext -> CTVarIName -> [CFuncDecl] -> CClassDecl

-- | Definitions of instances. An instance definition of the form <tt>
--   instance cx =&gt; c ty where { ...;fundecl;... } </tt> is represented
--   by the Curry term <tt> (CInstance c cx ty [...fundecl...]) </tt>
--   <i>Note:</i> The type variable indices are unique inside each instance
--   declaration and are usually numbered from 0. The methods' types use
--   the instance's type variable indices (if typed abstract curry is
--   generated).
data CInstanceDecl
CInstance :: QName -> CContext -> CTypeExpr -> [CFuncDecl] -> CInstanceDecl

-- | Definitions of algebraic data types and type synonyms. A data type
--   definition of the form <tt> data t x1...xn = ...| forall y1...ym . cx
--   =&gt; c t1....tkc |... deriving (d1,...,dp) </tt> is represented by
--   the Curry term <tt> (CType t v [i1,...,in] [...(CCons [l1,...,lm] cx c
--   kc v [t1,...,tkc])...] [d1,...,dp]) </tt> where each <tt>ij</tt> is
--   the index of the type variable <tt>xj</tt>, each <tt>lj</tt> is the
--   index of the existentially quantified type variable <tt>yj</tt> and
--   <tt>v</tt> is the visibility of the type resp. constructor.
--   <i>Note:</i> The type variable indices are unique inside each type
--   declaration and are usually numbered from 0. Thus, a data type
--   declaration consists of the name of the data type, a list of type
--   parameters and a list of constructor declarations.
data CTypeDecl

-- | algebraic data type
CType :: QName -> CVisibility -> [CTVarIName] -> [CConsDecl] -> [QName] -> CTypeDecl

-- | type synonym
CTypeSyn :: QName -> CVisibility -> [CTVarIName] -> CTypeExpr -> CTypeDecl

-- | renaming type, may have only exactly one type expression in the
--   constructor declaration and no existentially type variables and no
--   context
CNewType :: QName -> CVisibility -> [CTVarIName] -> CConsDecl -> [QName] -> CTypeDecl

-- | A constructor declaration consists of the name of the constructor and
--   a list of the argument types of the constructor. The arity equals the
--   number of types.
data CConsDecl
CCons :: QName -> CVisibility -> [CTypeExpr] -> CConsDecl
CRecord :: QName -> CVisibility -> [CFieldDecl] -> CConsDecl

-- | A record field declaration consists of the name of the the label, the
--   visibility and its corresponding type.
data CFieldDecl
CField :: QName -> CVisibility -> CTypeExpr -> CFieldDecl

-- | The type for representing a class constraint.
type CConstraint = (QName, CTypeExpr)

-- | The type for representing a context.
data CContext
CContext :: [CConstraint] -> CContext

-- | Type expression. A type expression is either a type variable, a
--   function type, a type constructor or a type application.
data CTypeExpr

-- | Type variable
CTVar :: CTVarIName -> CTypeExpr

-- | Function type <tt>t1 -&gt; t2</tt>
CFuncType :: CTypeExpr -> CTypeExpr -> CTypeExpr

-- | Type constructor
CTCons :: QName -> CTypeExpr

-- | Type application
CTApply :: CTypeExpr -> CTypeExpr -> CTypeExpr

-- | Qualified type expression.
data CQualTypeExpr
CQualType :: CContext -> CTypeExpr -> CQualTypeExpr

-- | Operator precedence declaration. An operator precedence declaration
--   <tt>fix p n</tt> in Curry corresponds to the AbstractCurry term
--   <tt>(COp n fix p)</tt>.
data COpDecl
COp :: QName -> CFixity -> Int -> COpDecl

-- | Fixity declarations of infix operators
data CFixity

-- | non-associative infix operator
CInfixOp :: CFixity

-- | left-associative infix operator
CInfixlOp :: CFixity

-- | right-associative infix operator
CInfixrOp :: CFixity

-- | Function arity
type Arity = Int

-- | Data type for representing function declarations. A function
--   declaration in FlatCurry is a term of the form <tt> (CFunc name arity
--   visibility type (CRules eval [CRule rule1,...,rulek])) </tt> and
--   represents the function <tt>name</tt> with definition <tt> name ::
--   type rule1 ... rulek </tt> <i>Note:</i> The variable indices are
--   unique inside each rule. External functions are represented as <tt>
--   (CFunc name arity type (CExternal s)) </tt> where s is the external
--   name associated to this function. Thus, a function declaration
--   consists of the name, arity, type, and a list of rules. If the list of
--   rules is empty, the function is considered to be externally defined.
data CFuncDecl
CFunc :: QName -> Arity -> CVisibility -> CQualTypeExpr -> [CRule] -> CFuncDecl

-- | Right-hand-side of a <a>CRule</a> or an <tt>case</tt> expression
data CRhs
CSimpleRhs :: CExpr -> [CLocalDecl] -> CRhs
CGuardedRhs :: [(CExpr, CExpr)] -> [CLocalDecl] -> CRhs

-- | The general form of a function rule. It consists of a list of patterns
--   (left-hand side), a list of guards (<tt>success</tt> if not present in
--   the source text) with their corresponding right-hand sides, and a list
--   of local declarations.
data CRule
CRule :: [CPattern] -> CRhs -> CRule

-- | Local (let/where) declarations
data CLocalDecl

-- | local function declaration
CLocalFunc :: CFuncDecl -> CLocalDecl

-- | local pattern declaration
CLocalPat :: CPattern -> CRhs -> CLocalDecl

-- | local free variable declarations
CLocalVars :: [CVarIName] -> CLocalDecl

-- | Variable names. Object variables occurring in expressions are
--   represented by <tt>(Var i)</tt> where <tt>i</tt> is a variable index.
type CVarIName = (Int, String)

-- | Curry expressions.
data CExpr

-- | variable (unique index / name)
CVar :: CVarIName -> CExpr

-- | literal (Integer<i>Float</i>Char/String constant)
CLit :: CLiteral -> CExpr

-- | a defined symbol with module and name, i.e., a function or a
--   constructor
CSymbol :: QName -> CExpr

-- | application (e1 e2)
CApply :: CExpr -> CExpr -> CExpr

-- | lambda abstraction
CLambda :: [CPattern] -> CExpr -> CExpr

-- | local let declarations
CLetDecl :: [CLocalDecl] -> CExpr -> CExpr

-- | do block
CDoExpr :: [CStatement] -> CExpr

-- | list comprehension
CListComp :: CExpr -> [CStatement] -> CExpr

-- | case expression
CCase :: CCaseType -> CExpr -> [(CPattern, CRhs)] -> CExpr

-- | typed expression
CTyped :: CExpr -> CQualTypeExpr -> CExpr

-- | record construction (extended Curry)
CRecConstr :: QName -> [CField CExpr] -> CExpr

-- | record update (extended Curry)
CRecUpdate :: CExpr -> [CField CExpr] -> CExpr

-- | Type of case expressions
data CCaseType

-- | rigid case expression
CRigid :: CCaseType

-- | flexible case expression
CFlex :: CCaseType

-- | Statements in do expressions and list comprehensions.
data CStatement

-- | an expression (I/O action or boolean)
CSExpr :: CExpr -> CStatement

-- | a pattern definition
CSPat :: CPattern -> CExpr -> CStatement

-- | a local let declaration
CSLet :: [CLocalDecl] -> CStatement

-- | Pattern expressions.
data CPattern

-- | pattern variable (unique index / name)
CPVar :: CVarIName -> CPattern

-- | literal (Integer<i>Float</i>Char constant)
CPLit :: CLiteral -> CPattern

-- | application <tt>(m.c e1 ... en)</tt> of n-ary constructor <tt>m.c</tt>
--   (<tt>CPComb (m,c) [e1,...,en]</tt>)
CPComb :: QName -> [CPattern] -> CPattern

-- | as-pattern (extended Curry)
CPAs :: CVarIName -> CPattern -> CPattern

-- | functional pattern (extended Curry)
CPFuncComb :: QName -> [CPattern] -> CPattern

-- | lazy pattern (extended Curry)
CPLazy :: CPattern -> CPattern

-- | record pattern (extended curry)
CPRecord :: QName -> [CField CPattern] -> CPattern

-- | Literals occurring in an expression or a pattern, either an integer, a
--   float, a character, or a string constant. <i>Note:</i> The constructor
--   definition of <a>CIntc</a> differs from the original PAKCS definition.
--   It uses Haskell type <a>Integer</a> instead of <a>Int</a> to provide
--   an unlimited range of integer numbers. Furthermore, float values are
--   represented with Haskell type <a>Double</a> instead of <a>Float</a> to
--   gain double precision.
data CLiteral

-- | Int literal
CIntc :: Integer -> CLiteral

-- | Float literal
CFloatc :: Double -> CLiteral

-- | Char literal
CCharc :: Char -> CLiteral

-- | String literal
CStringc :: String -> CLiteral

-- | Labeled record fields
type CField a = (QName, a)

-- | Current version of AbstractCurry
version :: String
instance GHC.Show.Show Curry.AbstractCurry.Type.CurryProg
instance GHC.Read.Read Curry.AbstractCurry.Type.CurryProg
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CurryProg
instance GHC.Show.Show Curry.AbstractCurry.Type.CClassDecl
instance GHC.Read.Read Curry.AbstractCurry.Type.CClassDecl
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CClassDecl
instance GHC.Show.Show Curry.AbstractCurry.Type.CInstanceDecl
instance GHC.Read.Read Curry.AbstractCurry.Type.CInstanceDecl
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CInstanceDecl
instance GHC.Show.Show Curry.AbstractCurry.Type.CRule
instance GHC.Read.Read Curry.AbstractCurry.Type.CRule
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CRule
instance GHC.Show.Show Curry.AbstractCurry.Type.CFuncDecl
instance GHC.Read.Read Curry.AbstractCurry.Type.CFuncDecl
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CFuncDecl
instance GHC.Show.Show Curry.AbstractCurry.Type.CRhs
instance GHC.Read.Read Curry.AbstractCurry.Type.CRhs
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CRhs
instance GHC.Show.Show Curry.AbstractCurry.Type.CLocalDecl
instance GHC.Read.Read Curry.AbstractCurry.Type.CLocalDecl
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CLocalDecl
instance GHC.Show.Show Curry.AbstractCurry.Type.CStatement
instance GHC.Read.Read Curry.AbstractCurry.Type.CStatement
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CStatement
instance GHC.Show.Show Curry.AbstractCurry.Type.CExpr
instance GHC.Read.Read Curry.AbstractCurry.Type.CExpr
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CExpr
instance GHC.Show.Show Curry.AbstractCurry.Type.CCaseType
instance GHC.Read.Read Curry.AbstractCurry.Type.CCaseType
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CCaseType
instance GHC.Show.Show Curry.AbstractCurry.Type.CPattern
instance GHC.Read.Read Curry.AbstractCurry.Type.CPattern
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CPattern
instance GHC.Show.Show Curry.AbstractCurry.Type.CLiteral
instance GHC.Read.Read Curry.AbstractCurry.Type.CLiteral
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CLiteral
instance GHC.Show.Show Curry.AbstractCurry.Type.COpDecl
instance GHC.Read.Read Curry.AbstractCurry.Type.COpDecl
instance GHC.Classes.Eq Curry.AbstractCurry.Type.COpDecl
instance GHC.Show.Show Curry.AbstractCurry.Type.CFixity
instance GHC.Read.Read Curry.AbstractCurry.Type.CFixity
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CFixity
instance GHC.Show.Show Curry.AbstractCurry.Type.CQualTypeExpr
instance GHC.Read.Read Curry.AbstractCurry.Type.CQualTypeExpr
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CQualTypeExpr
instance GHC.Show.Show Curry.AbstractCurry.Type.CDefaultDecl
instance GHC.Read.Read Curry.AbstractCurry.Type.CDefaultDecl
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CDefaultDecl
instance GHC.Show.Show Curry.AbstractCurry.Type.CTypeDecl
instance GHC.Read.Read Curry.AbstractCurry.Type.CTypeDecl
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CTypeDecl
instance GHC.Show.Show Curry.AbstractCurry.Type.CConsDecl
instance GHC.Read.Read Curry.AbstractCurry.Type.CConsDecl
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CConsDecl
instance GHC.Show.Show Curry.AbstractCurry.Type.CFieldDecl
instance GHC.Read.Read Curry.AbstractCurry.Type.CFieldDecl
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CFieldDecl
instance GHC.Show.Show Curry.AbstractCurry.Type.CContext
instance GHC.Read.Read Curry.AbstractCurry.Type.CContext
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CContext
instance GHC.Show.Show Curry.AbstractCurry.Type.CTypeExpr
instance GHC.Read.Read Curry.AbstractCurry.Type.CTypeExpr
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CTypeExpr
instance GHC.Show.Show Curry.AbstractCurry.Type.CVisibility
instance GHC.Read.Read Curry.AbstractCurry.Type.CVisibility
instance GHC.Classes.Eq Curry.AbstractCurry.Type.CVisibility


-- | This module re-exports the well known pretty printing combinators from
--   Hughes and Peyton-Jones. In addition, it re-exports the type class
--   <a>Pretty</a> for pretty printing arbitrary types.
module Curry.Base.Pretty

-- | Pretty printing class. The precedence level is used in a similar way
--   as in the <a>Show</a> class. Minimal complete definition is either
--   <a>pPrintPrec</a> or <a>pPrint</a>.
class Pretty a

-- | Pretty-print something in isolation.
pPrint :: Pretty a => a -> Doc

-- | Pretty-print something in a precedence context.
pPrintPrec :: Pretty a => Int -> a -> Doc

-- | Pretty-print a list.
pPrintList :: Pretty a => [a] -> Doc

-- | Pretty print a value to a <a>String</a>.
prettyShow :: Pretty a => a -> String

-- | Parenthesize an value if the boolean is true.
parenIf :: Bool -> Doc -> Doc

-- | Pretty print a value if the boolean is true
ppIf :: Bool -> Doc -> Doc

-- | Pretty print a <a>Maybe</a> value for the <a>Just</a> constructor only
maybePP :: (a -> Doc) -> Maybe a -> Doc

-- | A blank line.
blankLine :: Doc

-- | Above with a blank line in between. If one of the documents is empty,
--   then the other document is returned.
($++$) :: Doc -> Doc -> Doc

-- | Above with overlapping, but with a space in between. If one of the
--   documents is empty, then the other document is returned.
($-$) :: Doc -> Doc -> Doc

-- | Seperate a list of <a>Doc</a>s by a <a>blankLine</a>.
sepByBlankLine :: [Doc] -> Doc

-- | A <a>.</a> character.
dot :: Doc

-- | Precedence of function application
appPrec :: Int

-- | A left arrow <tt>&lt;-</tt>.
larrow :: Doc

-- | A right arrow <tt>-&gt;</tt>.
rarrow :: Doc

-- | A double arrow <tt>=&gt;</tt>.
darrow :: Doc

-- | A back quote <tt>`</tt>.
backQuote :: Doc

-- | A backslash @@.
backsl :: Doc

-- | A vertical bar <tt>|</tt>.
vbar :: Doc

-- | Set a document in backquotes.
bquotes :: Doc -> Doc

-- | Set a document in backquotes if the condition is <tt>True</tt>.
bquotesIf :: Bool -> Doc -> Doc

-- | Seperate a list of documents by commas
list :: [Doc] -> Doc
instance Curry.Base.Pretty.Pretty GHC.Types.Int
instance Curry.Base.Pretty.Pretty GHC.Integer.Type.Integer
instance Curry.Base.Pretty.Pretty GHC.Types.Float
instance Curry.Base.Pretty.Pretty GHC.Types.Double
instance Curry.Base.Pretty.Pretty ()
instance Curry.Base.Pretty.Pretty GHC.Types.Bool
instance Curry.Base.Pretty.Pretty GHC.Types.Ordering
instance Curry.Base.Pretty.Pretty GHC.Types.Char
instance Curry.Base.Pretty.Pretty a => Curry.Base.Pretty.Pretty (GHC.Maybe.Maybe a)
instance (Curry.Base.Pretty.Pretty a, Curry.Base.Pretty.Pretty b) => Curry.Base.Pretty.Pretty (Data.Either.Either a b)
instance Curry.Base.Pretty.Pretty a => Curry.Base.Pretty.Pretty [a]
instance (Curry.Base.Pretty.Pretty a, Curry.Base.Pretty.Pretty b) => Curry.Base.Pretty.Pretty (a, b)
instance (Curry.Base.Pretty.Pretty a, Curry.Base.Pretty.Pretty b, Curry.Base.Pretty.Pretty c) => Curry.Base.Pretty.Pretty (a, b, c)
instance (Curry.Base.Pretty.Pretty a, Curry.Base.Pretty.Pretty b, Curry.Base.Pretty.Pretty c, Curry.Base.Pretty.Pretty d) => Curry.Base.Pretty.Pretty (a, b, c, d)
instance (Curry.Base.Pretty.Pretty a, Curry.Base.Pretty.Pretty b, Curry.Base.Pretty.Pretty c, Curry.Base.Pretty.Pretty d, Curry.Base.Pretty.Pretty e) => Curry.Base.Pretty.Pretty (a, b, c, d, e)
instance (Curry.Base.Pretty.Pretty a, Curry.Base.Pretty.Pretty b, Curry.Base.Pretty.Pretty c, Curry.Base.Pretty.Pretty d, Curry.Base.Pretty.Pretty e, Curry.Base.Pretty.Pretty f) => Curry.Base.Pretty.Pretty (a, b, c, d, e, f)
instance (Curry.Base.Pretty.Pretty a, Curry.Base.Pretty.Pretty b, Curry.Base.Pretty.Pretty c, Curry.Base.Pretty.Pretty d, Curry.Base.Pretty.Pretty e, Curry.Base.Pretty.Pretty f, Curry.Base.Pretty.Pretty g) => Curry.Base.Pretty.Pretty (a, b, c, d, e, f, g)
instance (Curry.Base.Pretty.Pretty a, Curry.Base.Pretty.Pretty b, Curry.Base.Pretty.Pretty c, Curry.Base.Pretty.Pretty d, Curry.Base.Pretty.Pretty e, Curry.Base.Pretty.Pretty f, Curry.Base.Pretty.Pretty g, Curry.Base.Pretty.Pretty h) => Curry.Base.Pretty.Pretty (a, b, c, d, e, f, g, h)


-- | This module implements a data type for positions in a source file and
--   respective functions to operate on them. A source file position
--   consists of a filename, a line number, and a column number. A tab stop
--   is assumed at every eighth column.
module Curry.Base.Position

-- | Type class for entities which have a source code <a>Position</a>
class HasPosition a

-- | Get the <a>Position</a>
getPosition :: HasPosition a => a -> Position

-- | Set the <a>Position</a>
setPosition :: HasPosition a => Position -> a -> a

-- | Source code positions
data Position

-- | Normal source code position
Position :: FilePath -> Int -> Int -> Position

-- | <a>FilePath</a> of the source file
[file] :: Position -> FilePath

-- | line number, beginning at 1
[line] :: Position -> Int

-- | column number, beginning at 1
[column] :: Position -> Int

-- | no position
NoPos :: Position

-- | <tt>x @&gt; y</tt> returns <tt>x</tt> with the position obtained from
--   <tt>y</tt>
(@>) :: (HasPosition a, HasPosition b) => a -> b -> a

-- | Show a <a>Position</a> as a <a>String</a>
showPosition :: Position -> String

-- | Pretty print a <a>Position</a>
ppPosition :: Position -> Doc

-- | Pretty print a compact representation of a <tt>Position'</tt>s
--   line/column
ppCompactLine :: Position -> Doc

-- | Pretty print the line and column of a <a>Position</a>
ppLine :: Position -> Doc

-- | Show the line and column of a <a>Position</a>
showLine :: Position -> String

-- | Absolute first position of a file
first :: FilePath -> Position

-- | Next position to the right
next :: Position -> Position

-- | Increment a position by a number of columns
incr :: Position -> Int -> Position

-- | First position after the next tabulator
tab :: Position -> Position

-- | Number of spaces for a tabulator
tabWidth :: Int

-- | First position of the next line
nl :: Position -> Position
instance GHC.Show.Show Curry.Base.Position.Position
instance GHC.Read.Read Curry.Base.Position.Position
instance GHC.Classes.Ord Curry.Base.Position.Position
instance GHC.Classes.Eq Curry.Base.Position.Position
instance Curry.Base.Position.HasPosition Curry.Base.Position.Position
instance Curry.Base.Pretty.Pretty Curry.Base.Position.Position
instance Data.Binary.Class.Binary Curry.Base.Position.Position


-- | This module implements a data type for span information in a source
--   file and respective functions to operate on them. A source file span
--   consists of a filename, a start position and an end position.
--   
--   In addition, the type <tt>SrcRef</tt> identifies the path to an
--   expression in the abstract syntax tree by argument positions, which is
--   used for debugging purposes.
module Curry.Base.Span
data Span

-- | Normal source code span
Span :: FilePath -> Position -> Position -> Span

-- | <a>FilePath</a> of the source file
[file] :: Span -> FilePath

-- | start position
[start] :: Span -> Position

-- | end position
[end] :: Span -> Position

-- | no span
NoSpan :: Span

-- | Show a <a>Span</a> as a <a>String</a>
showSpan :: Span -> String

-- | Pretty print a <a>Span</a>
ppSpan :: Span -> Doc

-- | Pretty print a span with it's file path and position compactly.
ppCompactSpan :: Span -> Doc

-- | Pretty print a source preview of a span
ppSpanPreview :: Span -> IO Doc

-- | Pretty print the positions compactly.
ppCompactPositions :: Span -> Doc

-- | Pretty print the start and end position of a <a>Span</a>
ppPositions :: Span -> Doc
fstSpan :: FilePath -> Span

-- | Compute the column of the start position of a <a>Span</a>
startCol :: Span -> Int
nextSpan :: Span -> Span
incrSpan :: Span -> Int -> Span

-- | Convert a position to a single character span.
pos2Span :: Position -> Span

-- | Convert a span to a (start) position TODO: This function should be
--   removed as soon as positions are completely replaced by spans in the
--   frontend
span2Pos :: Span -> Position
combineSpans :: Span -> Span -> Span

-- | First position after the next tabulator
tabSpan :: Span -> Span

-- | First position of the next line
nlSpan :: Span -> Span
addSpan :: Span -> (a, [Span]) -> (a, [Span])

-- | Distance of a span, i.e. the line and column distance between start
--   and end position
type Distance = (Int, Int)

-- | Set the distance of a span, i.e. update its end position
setDistance :: Span -> Distance -> Span

-- | Move position by given distance
moveBy :: Position -> Distance -> Position
instance GHC.Show.Show Curry.Base.Span.Span
instance GHC.Read.Read Curry.Base.Span.Span
instance GHC.Classes.Ord Curry.Base.Span.Span
instance GHC.Classes.Eq Curry.Base.Span.Span
instance Curry.Base.Pretty.Pretty Curry.Base.Span.Span
instance Curry.Base.Position.HasPosition Curry.Base.Span.Span
instance Data.Binary.Class.Binary Curry.Base.Span.Span


-- | This module implements a data type for span information for entities
--   from a source file and function to operate on them. A span info
--   consists of the span of the entity and a list of sub-spans whith
--   additional information about location of keywords, e.g.
module Curry.Base.SpanInfo
data SpanInfo
SpanInfo :: Span -> [Span] -> SpanInfo
[srcSpan] :: SpanInfo -> Span
[srcInfoPoints] :: SpanInfo -> [Span]
NoSpanInfo :: SpanInfo
spanInfo :: Span -> [Span] -> SpanInfo
data LayoutInfo
ExplicitLayout :: [Span] -> LayoutInfo
WhitespaceLayout :: LayoutInfo
class HasPosition a => HasSpanInfo a
getSpanInfo :: HasSpanInfo a => a -> SpanInfo
setSpanInfo :: HasSpanInfo a => SpanInfo -> a -> a
updateEndPos :: HasSpanInfo a => a -> a
getLayoutInfo :: HasSpanInfo a => a -> LayoutInfo
fromSrcSpan :: Span -> SpanInfo
fromSrcSpanBoth :: Span -> SpanInfo
getSrcSpan :: HasSpanInfo a => a -> Span
setSrcSpan :: HasSpanInfo a => Span -> a -> a
spanInfoLike :: (HasSpanInfo a, HasSpanInfo b) => a -> b -> a
fromSrcInfoPoints :: [Span] -> SpanInfo
getSrcInfoPoints :: HasSpanInfo a => a -> [Span]
setSrcInfoPoints :: HasSpanInfo a => [Span] -> a -> a
getStartPosition :: HasSpanInfo a => a -> Position
getSrcSpanEnd :: HasSpanInfo a => a -> Position
setStartPosition :: HasSpanInfo a => Position -> a -> a
setEndPosition :: HasSpanInfo a => Position -> a -> a
spanInfo2Pos :: HasSpanInfo a => a -> Position
instance GHC.Show.Show Curry.Base.SpanInfo.LayoutInfo
instance GHC.Read.Read Curry.Base.SpanInfo.LayoutInfo
instance GHC.Classes.Eq Curry.Base.SpanInfo.LayoutInfo
instance GHC.Show.Show Curry.Base.SpanInfo.SpanInfo
instance GHC.Read.Read Curry.Base.SpanInfo.SpanInfo
instance GHC.Classes.Ord Curry.Base.SpanInfo.SpanInfo
instance GHC.Classes.Eq Curry.Base.SpanInfo.SpanInfo
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Base.SpanInfo.SpanInfo
instance Data.Binary.Class.Binary Curry.Base.SpanInfo.LayoutInfo
instance Curry.Base.Position.HasPosition Curry.Base.SpanInfo.SpanInfo
instance Data.Binary.Class.Binary Curry.Base.SpanInfo.SpanInfo


-- | The type message represents a compiler message with an optional source
--   code position.
module Curry.Base.Message

-- | Compiler message
data Message
Message :: SpanInfo -> Doc -> Message

-- | span in the source code
[msgSpanInfo] :: Message -> SpanInfo

-- | the message itself
[msgTxt] :: Message -> Doc

-- | Construct a <a>Message</a> without a <a>SpanInfo</a>
message :: Doc -> Message

-- | Construct a message from a position.
posMessage :: HasPosition p => p -> Doc -> Message

-- | Construct a message from a span and a text
spanMessage :: Span -> Doc -> Message

-- | Construct a message from an entity with a <a>SpanInfo</a> and a text
spanInfoMessage :: HasSpanInfo s => s -> Doc -> Message

-- | Show a <a>Message</a> as a warning
showWarning :: Message -> String

-- | Show a <a>Message</a> as an error
showError :: Message -> String

-- | Pretty print a <a>Message</a>
ppMessage :: Message -> Doc

-- | Pretty print a <a>Message</a> as a warning
ppWarning :: Message -> Doc

-- | Pretty print a <a>Message</a> as an error
ppError :: Message -> Doc

-- | Pretty print a list of <a>Message</a>s by vertical concatenation
ppMessages :: (Message -> Doc) -> [Message] -> Doc

-- | Pretty print a list of <a>Message</a>s with previews by vertical
--   concatenation
ppMessagesWithPreviews :: (Message -> Doc) -> [Message] -> IO Doc
instance GHC.Classes.Eq Curry.Base.Message.Message
instance GHC.Classes.Ord Curry.Base.Message.Message
instance GHC.Show.Show Curry.Base.Message.Message
instance Curry.Base.Position.HasPosition Curry.Base.Message.Message
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Base.Message.Message
instance Curry.Base.Pretty.Pretty Curry.Base.Message.Message


-- | The monads defined in this module provide a common way to stop
--   execution when some errors occur. They are used to integrate different
--   compiler passes smoothly.
module Curry.Base.Monad

-- | Curry compiler monad based on the <a>IO</a> monad
type CYIO a = CYT IO a

-- | Pure Curry compiler monad
type CYM a = CYT Identity a

-- | Curry compiler monad transformer
type CYT m a = WriterT [Message] (ExceptT [Message] m) a

-- | Failing action with a list of messages describing the cause(s) of
--   failure.
failMessages :: Monad m => [Message] -> CYT m a

-- | Failing action with a source code span and a <a>String</a> indicating
--   the cause of failure.
failMessageAt :: Monad m => Span -> String -> CYT m a

-- | Warning with a list of messages describing the cause(s) of the
--   warnings.
warnMessages :: Monad m => [Message] -> CYT m ()

-- | Warning with a source code position and a <a>String</a> indicating the
--   cause of the warning.
warnMessageAt :: Monad m => Span -> String -> CYT m ()

-- | Lift a value into the `CYT m` monad, same as <a>return</a>.
ok :: Monad m => a -> CYT m a

-- | Run an <a>IO</a>-based Curry compiler action in the <a>IO</a> monad,
--   yielding either a list of errors or a result in case of success
--   consisting of the actual result and a (possibly empty) list of
--   warnings
runCYIO :: CYIO a -> IO (Either [Message] (a, [Message]))

-- | Run an pure Curry compiler action, yielding either a list of errors or
--   a result in case of success consisting of the actual result and a
--   (possibly empty) list of warnings
runCYM :: CYM a -> Either [Message] (a, [Message])

-- | Run an <a>IO</a>-based Curry compiler action in the <a>IO</a> monad,
--   yielding either a list of errors or a result in case of success.
runCYIOIgnWarn :: CYIO a -> IO (Either [Message] a)

-- | Run an pure Curry compiler action, yielding either a list of errors or
--   a result in case of success.
runCYMIgnWarn :: CYM a -> Either [Message] a

-- | Lift a pure action into an action based on another monad.
liftCYM :: Monad m => CYM a -> CYT m a

-- | Execute a monadic action, but ignore any warnings it issues
silent :: Monad m => CYT m a -> CYT m a


-- | This module provides the basic types and combinators to implement the
--   lexers. The combinators use continuation passing code in a monadic
--   style.
--   
--   The first argument of the continuation function is the current span,
--   and the second is the string to be parsed. The third argument is a
--   flag which signals the lexer that it is lexing the beginning of a line
--   and therefore has to check for layout tokens. The fourth argument is a
--   stack of indentations that is used to handle nested layout groups.
module Curry.Base.LexComb

-- | Type class for symbols
class (Ord s, Show s) => Symbol s

-- | Does the <a>Symbol</a> represent the end of the input?
isEOF :: Symbol s => s -> Bool

-- | Compute the distance of a <a>Symbol</a>
dist :: Symbol s => Int -> s -> Distance

-- | Type for indentations, necessary for the layout rule
type Indent = Int

-- | Type of context for representing layout grouping
type Context = [Indent]

-- | Basic lexer function
type P a = Span " Current source code span" -> String " 'String' to be parsed" -> Bool " Flag whether the beginning of a line should be parsed, which requires layout checking" -> Context " context as a stack of 'Indent's" -> CYM a

-- | Pure Curry compiler monad
type CYM a = CYT Identity a

-- | success continuation
type SuccessP s a = Span -> s -> P a

-- | failure continuation
type FailP a = Span -> String -> P a

-- | A CPS lexer
type Lexer s a = SuccessP s a -> FailP a -> P a

-- | Apply a lexer on a <a>String</a> to lex the content. The second
--   parameter requires a <a>FilePath</a> to use in the <a>Span</a>
parse :: P a -> FilePath -> String -> CYM a

-- | Apply a lexer
applyLexer :: Symbol s => Lexer s [(Span, s)] -> P [(Span, s)]

-- | Lift a value into the lexer type
returnP :: a -> P a

-- | Apply the first lexer and then apply the second one, based on the
--   result of the first lexer.
thenP :: P a -> (a -> P b) -> P b
infixl 1 `thenP`

-- | Apply the first lexer and then apply the second one, ignoring the
--   first result.
thenP_ :: P a -> P b -> P b
infixl 1 `thenP_`

-- | Fail to lex on a <a>Span</a>, given an error message
failP :: Span -> String -> P a

-- | Warn on a <a>Span</a>, given a warning message
warnP :: Span -> String -> P a -> P a

-- | Apply a pure function to the lexers result
liftP :: (a -> b) -> P a -> P b

-- | Lift a lexer into the <a>P</a> monad, returning the lexer when
--   evaluated.
closeP0 :: P a -> P (P a)

-- | Lift a lexer-generating function into the <a>P</a> monad, returning
--   the function when evaluated.
closeP1 :: (a -> P b) -> P (a -> P b)

-- | Push an <a>Indent</a> to the context, increasing the levels of
--   indentation
pushContext :: Indent -> P a -> P a

-- | Pop an <a>Indent</a> from the context, decreasing the levels of
--   indentation
popContext :: P a -> P a

-- | Convert a String into a signed intergral using a given base
convertSignedIntegral :: Num a => a -> String -> a

-- | Convert a mantissa, a fraction part and an exponent into a signed
--   floating value
convertSignedFloating :: Fractional a => String -> String -> Int -> a

-- | Convert a String into an unsigned intergral using a given base
convertIntegral :: Num a => a -> String -> a

-- | Convert a mantissa, a fraction part and an exponent into an unsigned
--   floating value
convertFloating :: Fractional a => String -> String -> Int -> a


-- | The parsing combinators implemented in this module are based on the
--   LL(1) parsing combinators developed by Swierstra and Duponcheel. They
--   have been adapted to using continuation passing style in order to work
--   with the lexing combinators described in the previous section. In
--   addition, the facilities for error correction are omitted in this
--   implementation.
--   
--   The two functions <tt>applyParser</tt> and <a>prefixParser</a> use the
--   specified parser for parsing a string. When <tt>applyParser</tt> is
--   used, an error is reported if the parser does not consume the whole
--   string, whereas <a>prefixParser</a> discards the rest of the input
--   string in this case.
module Curry.Base.LLParseComb

-- | CPS-Parser type
data Parser a s b

-- | Apply a parser and lexer to a <a>String</a>, whereas the
--   <a>FilePath</a> is used to identify the origin of the <a>String</a> in
--   case of parsing errors.
fullParser :: Symbol s => Parser a s a -> Lexer s a -> FilePath -> String -> CYM a

-- | Apply a parser and lexer to parse the beginning of a <a>String</a>.
--   The <a>FilePath</a> is used to identify the origin of the
--   <a>String</a> in case of parsing errors.
prefixParser :: Symbol s => Parser a s a -> Lexer s a -> FilePath -> String -> CYM a

-- | Return the current position without consuming the input
position :: Parser a s Position
spanPosition :: Symbol s => Parser a s Span

-- | Always succeeding parser
succeed :: b -> Parser a s b

-- | Always failing parser with a given message
failure :: String -> Parser a s b

-- | Create a parser accepting the given <a>Symbol</a>
symbol :: s -> Parser a s s

-- | Behave like the given parser, but use the given <a>String</a> as the
--   error message if the parser fails
(<?>) :: Symbol s => Parser a s b -> String -> Parser a s b
infixl 2 <?>

-- | Deterministic choice between two parsers. The appropriate parser is
--   chosen based on the next <a>Symbol</a>
(<|>) :: Symbol s => Parser a s b -> Parser a s b -> Parser a s b
infixl 3 <|>

-- | Non-deterministic choice between two parsers.
--   
--   The other parsing combinators require that the grammar being parsed is
--   LL(1). In some cases it may be difficult or even impossible to
--   transform a grammar into LL(1) form. As a remedy, we include a
--   non-deterministic version of the choice combinator in addition to the
--   deterministic combinator adapted from the paper. For every symbol from
--   the intersection of the parser's first sets, the combinator
--   <a>(&lt;|?&gt;)</a> applies both parsing functions to the input stream
--   and uses that one which processes the longer prefix of the input
--   stream irrespective of whether it succeeds or fails. If both functions
--   recognize the same prefix, we choose the one that succeeds and report
--   an ambiguous parse error if both succeed.
(<|?>) :: Symbol s => Parser a s b -> Parser a s b -> Parser a s b
infixl 3 <|?>

-- | Sequential application.
--   
--   A few functors support an implementation of <a>&lt;*&gt;</a> that is
--   more efficient than the default one.
(<*>) :: Applicative f => f (a -> b) -> f a -> f b
infixl 4 <*>

-- | Restrict the first parser by the first <a>Symbol</a>s of the second
(<\>) :: Symbol s => Parser a s b -> Parser a s c -> Parser a s b
infixl 5 <\>

-- | Restrict a parser by a list of first <a>Symbol</a>s
(<\\>) :: Symbol s => Parser a s b -> [s] -> Parser a s b
infixl 5 <\\>

-- | An infix synonym for <a>fmap</a>.
--   
--   The name of this operator is an allusion to <a>$</a>. Note the
--   similarities between their types:
--   
--   <pre>
--    ($)  ::              (a -&gt; b) -&gt;   a -&gt;   b
--   (&lt;$&gt;) :: Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
--   </pre>
--   
--   Whereas <a>$</a> is function application, <a>&lt;$&gt;</a> is function
--   application lifted over a <a>Functor</a>.
--   
--   <h4><b>Examples</b></h4>
--   
--   Convert from a <tt><a>Maybe</a> <a>Int</a></tt> to a <tt><a>Maybe</a>
--   <a>String</a></tt> using <a>show</a>:
--   
--   <pre>
--   &gt;&gt;&gt; show &lt;$&gt; Nothing
--   Nothing
--   
--   &gt;&gt;&gt; show &lt;$&gt; Just 3
--   Just "3"
--   </pre>
--   
--   Convert from an <tt><a>Either</a> <a>Int</a> <a>Int</a></tt> to an
--   <tt><a>Either</a> <a>Int</a></tt> <a>String</a> using <a>show</a>:
--   
--   <pre>
--   &gt;&gt;&gt; show &lt;$&gt; Left 17
--   Left 17
--   
--   &gt;&gt;&gt; show &lt;$&gt; Right 17
--   Right "17"
--   </pre>
--   
--   Double each element of a list:
--   
--   <pre>
--   &gt;&gt;&gt; (*2) &lt;$&gt; [1,2,3]
--   [2,4,6]
--   </pre>
--   
--   Apply <a>even</a> to the second element of a pair:
--   
--   <pre>
--   &gt;&gt;&gt; even &lt;$&gt; (2,2)
--   (2,True)
--   </pre>
(<$>) :: Functor f => (a -> b) -> f a -> f b
infixl 4 <$>

-- | Replace the result of the parser with the first argument
(<$->) :: Symbol s => a -> Parser b s c -> Parser b s a
infixl 4 <$->

-- | Apply two parsers in sequence, but return only the result of the first
--   parser
(<*->) :: Symbol s => Parser a s b -> Parser a s c -> Parser a s b
infixl 4 <*->

-- | Apply two parsers in sequence, but return only the result of the
--   second parser
(<-*>) :: Symbol s => Parser a s b -> Parser a s c -> Parser a s c
infixl 4 <-*>

-- | Apply the parsers in sequence and apply the result function of the
--   second parse to the result of the first
(<**>) :: Symbol s => Parser a s b -> Parser a s (b -> c) -> Parser a s c
infixl 4 <**>

-- | Same as (<a>**</a>), but only applies the function if the second
--   parser succeeded.
(<??>) :: Symbol s => Parser a s b -> Parser a s (b -> b) -> Parser a s b
infixl 4 <??>

-- | Flipped function composition on parsers
(<.>) :: Symbol s => Parser a s (b -> c) -> Parser a s (c -> d) -> Parser a s (b -> d)
infixl 4 <.>

-- | Try the first parser, but return the second argument if it didn't
--   succeed
opt :: Symbol s => Parser a s b -> b -> Parser a s b
infixl 2 `opt`

-- | Choose the first succeeding parser from a non-empty list of parsers
choice :: Symbol s => [Parser a s b] -> Parser a s b

-- | Try to apply a given parser and return a boolean value if the parser
--   succeeded.
flag :: Symbol s => Parser a s b -> Parser a s Bool

-- | Try to apply a parser but forget if it succeeded
optional :: Symbol s => Parser a s b -> Parser a s ()

-- | Try to apply a parser and return its result in a <a>Maybe</a> type
option :: Symbol s => Parser a s b -> Parser a s (Maybe b)

-- | Repeatedly apply a parser for 0 or more occurences
many :: Symbol s => Parser a s b -> Parser a s [b]

-- | Repeatedly apply a parser for 1 or more occurences
many1 :: Symbol s => Parser a s b -> Parser a s [b]

-- | Parse a list with is separated by a seperator
sepBy :: Symbol s => Parser a s b -> Parser a s c -> Parser a s [b]

-- | Parse a non-empty list with is separated by a seperator
sepBy1 :: Symbol s => Parser a s b -> Parser a s c -> Parser a s [b]

-- | Parse a list with is separated by a seperator
sepBySp :: Symbol s => Parser a s b -> Parser a s c -> Parser a s ([b], [Span])
sepBy1Sp :: Symbol s => Parser a s b -> Parser a s c -> Parser a s ([b], [Span])

-- | <tt>chainr p op x</tt> parses zero or more occurrences of <tt>p</tt>,
--   separated by <tt>op</tt>. Returns a value produced by a *right*
--   associative application of all functions returned by op. If there are
--   no occurrences of <tt>p</tt>, <tt>x</tt> is returned.
chainr :: Symbol s => Parser a s b -> Parser a s (b -> b -> b) -> b -> Parser a s b

-- | Like <a>chainr</a>, but parses one or more occurrences of p.
chainr1 :: Symbol s => Parser a s b -> Parser a s (b -> b -> b) -> Parser a s b

-- | <tt>chainr p op x</tt> parses zero or more occurrences of <tt>p</tt>,
--   separated by <tt>op</tt>. Returns a value produced by a *left*
--   associative application of all functions returned by op. If there are
--   no occurrences of <tt>p</tt>, <tt>x</tt> is returned.
chainl :: Symbol s => Parser a s b -> Parser a s (b -> b -> b) -> b -> Parser a s b

-- | Like <a>chainl</a>, but parses one or more occurrences of p.
chainl1 :: Symbol s => Parser a s b -> Parser a s (b -> b -> b) -> Parser a s b

-- | Parse an expression between an opening and a closing part.
between :: Symbol s => Parser a s b -> Parser a s c -> Parser a s b -> Parser a s c

-- | Parse one of the given operators
ops :: Symbol s => [(s, b)] -> Parser a s b

-- | Add a new scope for layout
layoutOn :: Symbol s => Parser a s b

-- | Disable layout-awareness for the following
layoutOff :: Symbol s => Parser a s b

-- | End the current layout scope (or re-enable layout-awareness if it is
--   currently disabled
layoutEnd :: Symbol s => Parser a s b
instance Curry.Base.LexComb.Symbol s => GHC.Base.Functor (Curry.Base.LLParseComb.Parser a s)
instance Curry.Base.LexComb.Symbol s => GHC.Base.Applicative (Curry.Base.LLParseComb.Parser a s)
instance GHC.Show.Show s => GHC.Show.Show (Curry.Base.LLParseComb.Parser a s b)


-- | This module provides the implementation of identifiers and some
--   utility functions for identifiers.
--   
--   Identifiers comprise the name of the denoted entity and an <i>id</i>,
--   which can be used for renaming identifiers, e.g., in order to resolve
--   name conflicts between identifiers from different scopes. An
--   identifier with an <i>id</i> <tt>0</tt> is considered as not being
--   renamed and, hence, its <i>id</i> will not be shown.
--   
--   Qualified identifiers may optionally be prefixed by a module name.
module Curry.Base.Ident

-- | Module identifier
data ModuleIdent
ModuleIdent :: SpanInfo -> [String] -> ModuleIdent

-- | source code <a>SpanInfo</a>
[midSpanInfo] :: ModuleIdent -> SpanInfo

-- | hierarchical idenfiers
[midQualifiers] :: ModuleIdent -> [String]

-- | Construct a <a>ModuleIdent</a> from a list of <a>String</a>s forming
--   the the hierarchical module name.
mkMIdent :: [String] -> ModuleIdent

-- | Retrieve the hierarchical name of a module
moduleName :: ModuleIdent -> String

-- | Show the name of an <a>ModuleIdent</a> escaped by ticks
escModuleName :: ModuleIdent -> String

-- | Resemble the hierarchical module name from a <a>String</a> by
--   splitting the <a>String</a> at inner dots.
--   
--   <i>Note:</i> This function does not check the <a>String</a> to be a
--   valid module identifier, use isValidModuleName for this purpose.
fromModuleName :: String -> ModuleIdent

-- | Check whether a <a>String</a> is a valid module name.
--   
--   Valid module names must satisfy the following conditions:
--   
--   <ul>
--   <li>The name must not be empty</li>
--   <li>The name must consist of one or more single identifiers, seperated
--   by dots</li>
--   <li>Each single identifier must be non-empty, start with a letter and
--   consist of letter, digits, single quotes or underscores only</li>
--   </ul>
isValidModuleName :: String -> Bool

-- | Add a source code <a>Position</a> to a <a>ModuleIdent</a>
addPositionModuleIdent :: Position -> ModuleIdent -> ModuleIdent
mIdentLength :: ModuleIdent -> Int

-- | Simple identifier
data Ident
Ident :: SpanInfo -> String -> Integer -> Ident

-- | Source code <a>SpanInfo</a>
[idSpanInfo] :: Ident -> SpanInfo

-- | Name of the identifier
[idName] :: Ident -> String

-- | Unique number of the identifier
[idUnique] :: Ident -> Integer

-- | Construct an <a>Ident</a> from a <a>String</a>
mkIdent :: String -> Ident

-- | Show function for an <a>Ident</a>
showIdent :: Ident -> String

-- | Show the name of an <a>Ident</a> escaped by ticks
escName :: Ident -> String

-- | Infinite list of different <a>Ident</a>s
identSupply :: [Ident]

-- | Global scope for renaming
globalScope :: Integer

-- | Has the identifier global scope?
hasGlobalScope :: Ident -> Bool

-- | Is the <a>Ident</a> renamed?
isRenamed :: Ident -> Bool

-- | Rename an <a>Ident</a> by changing its unique number
renameIdent :: Ident -> Integer -> Ident

-- | Revert the renaming of an <a>Ident</a> by resetting its unique number
unRenameIdent :: Ident -> Ident

-- | Change the name of an <a>Ident</a> using a renaming function
updIdentName :: (String -> String) -> Ident -> Ident

-- | Add a <a>Position</a> to an <a>Ident</a>
addPositionIdent :: Position -> Ident -> Ident

-- | Check whether an <a>Ident</a> identifies an infix operation
isInfixOp :: Ident -> Bool
identLength :: Ident -> Int

-- | Qualified identifier
data QualIdent
QualIdent :: SpanInfo -> Maybe ModuleIdent -> Ident -> QualIdent

-- | Source code <a>SpanInfo</a>
[qidSpanInfo] :: QualIdent -> SpanInfo

-- | optional module identifier
[qidModule] :: QualIdent -> Maybe ModuleIdent

-- | identifier itself
[qidIdent] :: QualIdent -> Ident

-- | show function for qualified identifiers)=
qualName :: QualIdent -> String

-- | Show the name of an <a>QualIdent</a> escaped by ticks
escQualName :: QualIdent -> String

-- | Check whether an <a>QualIdent</a> identifies an infix operation
isQInfixOp :: QualIdent -> Bool

-- | Convert an <a>Ident</a> to a <a>QualIdent</a>
qualify :: Ident -> QualIdent

-- | Convert an <a>Ident</a> to a <a>QualIdent</a> with a given
--   <a>ModuleIdent</a>
qualifyWith :: ModuleIdent -> Ident -> QualIdent

-- | Convert an <a>QualIdent</a> to a new <a>QualIdent</a> with a given
--   <a>ModuleIdent</a>. If the original <a>QualIdent</a> already contains
--   an <a>ModuleIdent</a> it remains unchanged.
qualQualify :: ModuleIdent -> QualIdent -> QualIdent

-- | Qualify an <a>Ident</a> with the <a>ModuleIdent</a> of the given
--   <a>QualIdent</a>, if present.
qualifyLike :: QualIdent -> Ident -> QualIdent

-- | Check whether a <a>QualIdent</a> contains a <a>ModuleIdent</a>
isQualified :: QualIdent -> Bool

-- | Remove the qualification of an <a>QualIdent</a>
unqualify :: QualIdent -> Ident

-- | Remove the qualification with a specific <a>ModuleIdent</a>. If the
--   original <a>QualIdent</a> has no <a>ModuleIdent</a> or a different
--   one, it remains unchanged.
qualUnqualify :: ModuleIdent -> QualIdent -> QualIdent

-- | Extract the <a>Ident</a> of an <a>QualIdent</a> if it is local to the
--   <a>ModuleIdent</a>, i.e. if the <a>Ident</a> is either unqualified or
--   qualified with the given <a>ModuleIdent</a>.
localIdent :: ModuleIdent -> QualIdent -> Maybe Ident

-- | Check whether the given <a>QualIdent</a> is local to the given
--   <a>ModuleIdent</a>.
isLocalIdent :: ModuleIdent -> QualIdent -> Bool

-- | Update a <a>QualIdent</a> by applying functions to its components
updQualIdent :: (ModuleIdent -> ModuleIdent) -> (Ident -> Ident) -> QualIdent -> QualIdent
qIdentLength :: QualIdent -> Int

-- | <a>ModuleIdent</a> for the empty module
emptyMIdent :: ModuleIdent

-- | <a>ModuleIdent</a> for the main module
mainMIdent :: ModuleIdent

-- | <a>ModuleIdent</a> for the Prelude
preludeMIdent :: ModuleIdent

-- | <a>Ident</a> for the type '(-&gt;)'
arrowId :: Ident

-- | <a>Ident</a> for the type/value unit (<tt>()</tt>)
unitId :: Ident

-- | <a>Ident</a> for the type <a>Bool</a>
boolId :: Ident

-- | <a>Ident</a> for the type <a>Char</a>
charId :: Ident

-- | <a>Ident</a> for the type <a>Int</a>
intId :: Ident

-- | <a>Ident</a> for the type <a>Float</a>
floatId :: Ident

-- | <a>Ident</a> for the type '[]'
listId :: Ident

-- | <a>Ident</a> for the type <a>IO</a>
ioId :: Ident

-- | <a>Ident</a> for the type <tt>Success</tt>
successId :: Ident

-- | <a>Ident</a> for the <a>Eq</a> class
eqId :: Ident

-- | <a>Ident</a> for the <a>Ord</a> class
ordId :: Ident

-- | <a>Ident</a> for the <a>Enum</a> class
enumId :: Ident

-- | <a>Ident</a> for the <a>Bounded</a> class
boundedId :: Ident

-- | <a>Ident</a> for the <a>Read</a> class
readId :: Ident

-- | <a>Ident</a> for the <a>Show</a> class
showId :: Ident

-- | <a>Ident</a> for the <a>Num</a> class
numId :: Ident

-- | <a>Ident</a> for the <a>Fractional</a> class
fractionalId :: Ident

-- | <a>Ident</a> for the <a>Monad</a> class
monadId :: Ident

-- | <a>Ident</a> for the <a>MonadFail</a> class
monadFailId :: Ident

-- | <a>Ident</a> for the <tt>Data</tt> class
dataId :: Ident

-- | <a>Ident</a> for the value <a>True</a>
trueId :: Ident

-- | <a>Ident</a> for the value <a>False</a>
falseId :: Ident

-- | <a>Ident</a> for the value '[]'
nilId :: Ident

-- | <a>Ident</a> for the function <tt>:</tt>
consId :: Ident

-- | Construct an <a>Ident</a> for an n-ary tuple where n &gt; 1
tupleId :: Int -> Ident

-- | Check whether an <a>Ident</a> is an identifier for an tuple type
isTupleId :: Ident -> Bool

-- | Compute the arity of a tuple identifier
tupleArity :: Ident -> Int

-- | <a>Ident</a> for the main function
mainId :: Ident

-- | <a>Ident</a> for the minus function
minusId :: Ident

-- | <a>Ident</a> for the minus function for Floats
fminusId :: Ident

-- | <a>Ident</a> for the apply function
applyId :: Ident

-- | <a>Ident</a> for the error function
errorId :: Ident

-- | <a>Ident</a> for the failed function
failedId :: Ident

-- | <a>Ident</a> for the id function
idId :: Ident

-- | <a>Ident</a> for the succ function
succId :: Ident

-- | <a>Ident</a> for the pred function
predId :: Ident

-- | <a>Ident</a> for the toEnum function
toEnumId :: Ident

-- | <a>Ident</a> for the fromEnum function
fromEnumId :: Ident

-- | <a>Ident</a> for the enumFrom function
enumFromId :: Ident

-- | <a>Ident</a> for the enumFromThen function
enumFromThenId :: Ident

-- | <a>Ident</a> for the enumFromTo function
enumFromToId :: Ident

-- | <a>Ident</a> for the enumFromThenTo function
enumFromThenToId :: Ident

-- | <a>Ident</a> for the maxBound function
maxBoundId :: Ident

-- | <a>Ident</a> for the minBound function
minBoundId :: Ident

-- | <a>Ident</a> for the lex function
lexId :: Ident

-- | <a>Ident</a> for the readsPrec function
readsPrecId :: Ident

-- | <a>Ident</a> for the readParen function
readParenId :: Ident

-- | <a>Ident</a> for the showsPrec function
showsPrecId :: Ident

-- | <a>Ident</a> for the showParen function
showParenId :: Ident

-- | <a>Ident</a> for the showString function
showStringId :: Ident

-- | <a>Ident</a> for the <a>&amp;&amp;</a> operator
andOpId :: Ident

-- | <a>Ident</a> for the <a>==</a> operator
eqOpId :: Ident

-- | <a>Ident</a> for the <a>&lt;=</a> operator
leqOpId :: Ident

-- | <a>Ident</a> for the <a>&lt;</a> operator
ltOpId :: Ident

-- | <a>Ident</a> for the <a>||</a> operator
orOpId :: Ident

-- | <a>Ident</a> for the <a>++</a> operator
appendOpId :: Ident

-- | <a>Ident</a> for the <a>.</a> operator
dotOpId :: Ident
aValueId :: Ident
dataEqId :: Ident

-- | <a>Ident</a> for anonymous variable
anonId :: Ident

-- | Check whether an <a>Ident</a> represents an anonymous identifier
--   (<a>anonId</a>)
isAnonId :: Ident -> Bool

-- | <a>QualIdent</a> for the type '(-&gt;)'
qArrowId :: QualIdent

-- | <a>QualIdent</a> for the type/value unit (<tt>()</tt>)
qUnitId :: QualIdent

-- | <a>QualIdent</a> for the type <a>Bool</a>
qBoolId :: QualIdent

-- | <a>QualIdent</a> for the type <a>Char</a>
qCharId :: QualIdent

-- | <a>QualIdent</a> for the type <a>Int</a>
qIntId :: QualIdent

-- | <a>QualIdent</a> for the type <a>Float</a>
qFloatId :: QualIdent

-- | <a>QualIdent</a> for the type '[]'
qListId :: QualIdent

-- | <a>QualIdent</a> for the type <a>IO</a>
qIOId :: QualIdent

-- | <a>QualIdent</a> for the type <tt>Success</tt>
qSuccessId :: QualIdent

-- | Check whether an <a>QualIdent</a> is an primary type constructor
isPrimTypeId :: QualIdent -> Bool

-- | <a>QualIdent</a> for the <a>Eq</a> class
qEqId :: QualIdent

-- | <a>QualIdent</a> for the <a>Ord</a> class
qOrdId :: QualIdent

-- | <a>QualIdent</a> for the <a>Enum</a> class
qEnumId :: QualIdent

-- | <a>QualIdent</a> for the <a>Bounded</a> class
qBoundedId :: QualIdent

-- | <a>QualIdent</a> for the <a>Read</a> class
qReadId :: QualIdent

-- | <a>QualIdent</a> for the <a>Show</a> class
qShowId :: QualIdent

-- | <a>QualIdent</a> for the <a>Num</a> class
qNumId :: QualIdent

-- | <a>QualIdent</a> for the <a>Fractional</a> class
qFractionalId :: QualIdent

-- | <a>QualIdent</a> for the <a>Monad</a> class
qMonadId :: QualIdent

-- | <a>QualIdent</a> for the <a>MonadFail</a> class
qMonadFailId :: QualIdent

-- | <a>QualIdent</a> for the <tt>Data</tt> class
qDataId :: QualIdent

-- | <a>QualIdent</a> for the constructor <a>True</a>
qTrueId :: QualIdent

-- | <a>QualIdent</a> for the constructor <a>False</a>
qFalseId :: QualIdent

-- | <a>QualIdent</a> for the constructor '[]'
qNilId :: QualIdent

-- | <a>QualIdent</a> for the constructor <tt>:</tt>
qConsId :: QualIdent

-- | <a>QualIdent</a> for the type of n-ary tuples
qTupleId :: Int -> QualIdent

-- | Check whether an <a>QualIdent</a> is an identifier for an tuple type
isQTupleId :: QualIdent -> Bool

-- | Compute the arity of an qualified tuple identifier
qTupleArity :: QualIdent -> Int

-- | <a>QualIdent</a> for the apply function
qApplyId :: QualIdent

-- | <a>QualIdent</a> for the error function
qErrorId :: QualIdent

-- | <a>QualIdent</a> for the failed function
qFailedId :: QualIdent

-- | <a>QualIdent</a> for the id function
qIdId :: QualIdent

-- | <a>QualIdent</a> for the fromEnum function
qFromEnumId :: QualIdent

-- | <a>QualIdent</a> for the enumFrom function
qEnumFromId :: QualIdent

-- | <a>QualIdent</a> for the enumFromThen function
qEnumFromThenId :: QualIdent

-- | <a>QualIdent</a> for the enumFromTo function
qEnumFromToId :: QualIdent

-- | <a>QualIdent</a> for the enumFromThenTo function
qEnumFromThenToId :: QualIdent

-- | <a>QualIdent</a> for the maxBound function
qMaxBoundId :: QualIdent

-- | <a>QualIdent</a> for the minBound function
qMinBoundId :: QualIdent

-- | <a>QualIdent</a> for the lex function
qLexId :: QualIdent

-- | <a>QualIdent</a> for the readsPrec function
qReadsPrecId :: QualIdent

-- | <a>QualIdent</a> for the readParen function
qReadParenId :: QualIdent

-- | <a>QualIdent</a> for the showsPrec function
qShowsPrecId :: QualIdent

-- | <a>QualIdent</a> for the showParen function
qShowParenId :: QualIdent

-- | <a>QualIdent</a> for the showString function
qShowStringId :: QualIdent

-- | <a>QualIdent</a> for the <a>&amp;&amp;</a> operator
qAndOpId :: QualIdent

-- | <a>QualIdent</a> for the <a>==</a> operator
qEqOpId :: QualIdent

-- | <a>QualIdent</a> for the <a>&lt;=</a> operator
qLeqOpId :: QualIdent

-- | <a>QualIdent</a> for the <a>&lt;</a> operator
qLtOpId :: QualIdent

-- | <a>QualIdent</a> for the <a>||</a> operator
qOrOpId :: QualIdent

-- | <a>QualIdent</a> for the <a>++</a> operator
qAppendOpId :: QualIdent

-- | <a>QualIdent</a> for the <a>.</a> operator
qDotOpId :: QualIdent
qAValueId :: QualIdent
qDataEqId :: QualIdent

-- | Construct an <a>Ident</a> for a functional pattern
fpSelectorId :: Int -> Ident

-- | Check whether an <a>Ident</a> is an identifier for a functional
--   pattern
isFpSelectorId :: Ident -> Bool

-- | Check whether an <a>QualIdent</a> is an identifier for a function
--   pattern
isQualFpSelectorId :: QualIdent -> Bool

-- | Construct an <a>Ident</a> for a record selection pattern
recSelectorId :: QualIdent -> Ident -> Ident

-- | Construct a <a>QualIdent</a> for a record selection pattern
qualRecSelectorId :: ModuleIdent -> QualIdent -> Ident -> QualIdent

-- | Construct an <a>Ident</a> for a record update pattern
recUpdateId :: QualIdent -> Ident -> Ident

-- | Construct a <a>QualIdent</a> for a record update pattern
qualRecUpdateId :: ModuleIdent -> QualIdent -> Ident -> QualIdent

-- | Annotation for record identifiers
recordExt :: String

-- | Construct an <a>Ident</a> for a record
recordExtId :: Ident -> Ident

-- | Check whether an <a>Ident</a> is an identifier for a record
isRecordExtId :: Ident -> Bool

-- | Retrieve the <a>Ident</a> from a record identifier
fromRecordExtId :: Ident -> Ident

-- | Annotation for record label identifiers
labelExt :: String

-- | Construct an <a>Ident</a> for a record label
labelExtId :: Ident -> Ident

-- | Check whether an <a>Ident</a> is an identifier for a record label
isLabelExtId :: Ident -> Bool

-- | Retrieve the <a>Ident</a> from a record label identifier
fromLabelExtId :: Ident -> Ident

-- | Rename an <a>Ident</a> for a record label
renameLabel :: Ident -> Ident

-- | Construct an <a>Ident</a> for a record label
mkLabelIdent :: String -> Ident
instance GHC.Show.Show Curry.Base.Ident.QualIdent
instance GHC.Read.Read Curry.Base.Ident.QualIdent
instance GHC.Show.Show Curry.Base.Ident.Ident
instance GHC.Read.Read Curry.Base.Ident.Ident
instance GHC.Show.Show Curry.Base.Ident.ModuleIdent
instance GHC.Read.Read Curry.Base.Ident.ModuleIdent
instance GHC.Classes.Eq Curry.Base.Ident.QualIdent
instance GHC.Classes.Ord Curry.Base.Ident.QualIdent
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Base.Ident.QualIdent
instance Curry.Base.Position.HasPosition Curry.Base.Ident.QualIdent
instance Curry.Base.Pretty.Pretty Curry.Base.Ident.QualIdent
instance Data.Binary.Class.Binary Curry.Base.Ident.QualIdent
instance GHC.Classes.Eq Curry.Base.Ident.Ident
instance GHC.Classes.Ord Curry.Base.Ident.Ident
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Base.Ident.Ident
instance Curry.Base.Position.HasPosition Curry.Base.Ident.Ident
instance Curry.Base.Pretty.Pretty Curry.Base.Ident.Ident
instance Data.Binary.Class.Binary Curry.Base.Ident.Ident
instance GHC.Classes.Eq Curry.Base.Ident.ModuleIdent
instance GHC.Classes.Ord Curry.Base.Ident.ModuleIdent
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Base.Ident.ModuleIdent
instance Curry.Base.Position.HasPosition Curry.Base.Ident.ModuleIdent
instance Curry.Base.Pretty.Pretty Curry.Base.Ident.ModuleIdent
instance Data.Binary.Class.Binary Curry.Base.Ident.ModuleIdent


-- | TODO
module Curry.CondCompile.Type
type Program = [Stmt]
data Stmt
If :: Cond -> [Stmt] -> [Elif] -> Else -> Stmt
IfDef :: String -> [Stmt] -> [Elif] -> Else -> Stmt
IfNDef :: String -> [Stmt] -> [Elif] -> Else -> Stmt
Define :: String -> Int -> Stmt
Undef :: String -> Stmt
Line :: String -> Stmt
newtype Else
Else :: Maybe [Stmt] -> Else
newtype Elif
Elif :: (Cond, [Stmt]) -> Elif
data Cond
Comp :: String -> Op -> Int -> Cond
Defined :: String -> Cond
NDefined :: String -> Cond
data Op
Eq :: Op
Neq :: Op
Lt :: Op
Leq :: Op
Gt :: Op
Geq :: Op
instance GHC.Show.Show Curry.CondCompile.Type.Else
instance GHC.Show.Show Curry.CondCompile.Type.Elif
instance GHC.Show.Show Curry.CondCompile.Type.Stmt
instance GHC.Show.Show Curry.CondCompile.Type.Cond
instance GHC.Show.Show Curry.CondCompile.Type.Op
instance Curry.Base.Pretty.Pretty Curry.CondCompile.Type.Stmt
instance Curry.Base.Pretty.Pretty Curry.CondCompile.Type.Elif
instance Curry.Base.Pretty.Pretty Curry.CondCompile.Type.Else
instance Curry.Base.Pretty.Pretty Curry.CondCompile.Type.Cond
instance Curry.Base.Pretty.Pretty Curry.CondCompile.Type.Op


-- | TODO
module Curry.CondCompile.Parser
type Parser a = Parsec String () a
program :: Parser Program
statement :: Parser Stmt
ifElse :: String -> Parser a -> (a -> [Stmt] -> [Elif] -> Else -> Stmt) -> Parser Stmt
define :: Parser Stmt
undef :: Parser Stmt
line :: Parser Stmt
keyword :: String -> Parser String
condition :: Parser Cond
identifier :: Parser String
operator :: Parser Op
value :: Parser Int
eol :: Parser ()
sp :: Parser Char


-- | TODO
module Curry.CondCompile.Transform
condTransform :: CCState -> FilePath -> String -> Either Message String
instance Curry.CondCompile.Transform.FillLength Curry.CondCompile.Type.Stmt
instance Curry.CondCompile.Transform.FillLength a => Curry.CondCompile.Transform.FillLength [a]
instance Curry.CondCompile.Transform.FillLength Curry.CondCompile.Type.Else
instance Curry.CondCompile.Transform.FillLength Curry.CondCompile.Type.Elif
instance Curry.CondCompile.Transform.CCTransform Curry.CondCompile.Type.Stmt
instance Curry.CondCompile.Transform.CCTransform a => Curry.CondCompile.Transform.CCTransform [a]
instance Curry.CondCompile.Transform.CCTransform Curry.CondCompile.Type.Else


-- | The functions in this module were collected from several compiler
--   modules in order to provide a unique accessing point for this
--   functionality.
module Curry.Files.Filenames

-- | File and directory names are values of type <a>String</a>, whose
--   precise meaning is operating system dependent. Files can be opened,
--   yielding a handle which can then be used to operate on the contents of
--   that file.
type FilePath = String

-- | Get the base name, without an extension or path.
--   
--   <pre>
--   takeBaseName "/directory/file.ext" == "file"
--   takeBaseName "file/test.txt" == "test"
--   takeBaseName "dave.ext" == "dave"
--   takeBaseName "" == ""
--   takeBaseName "test" == "test"
--   takeBaseName (addTrailingPathSeparator x) == ""
--   takeBaseName "file/file.tar.gz" == "file.tar"
--   </pre>
takeBaseName :: FilePath -> String

-- | Remove last extension, and the "." preceding it.
--   
--   <pre>
--   dropExtension "/directory/path.ext" == "/directory/path"
--   dropExtension x == fst (splitExtension x)
--   </pre>
dropExtension :: FilePath -> FilePath

-- | Get the extension of a file, returns <tt>""</tt> for no extension,
--   <tt>.ext</tt> otherwise.
--   
--   <pre>
--   takeExtension "/directory/path.ext" == ".ext"
--   takeExtension x == snd (splitExtension x)
--   Valid x =&gt; takeExtension (addExtension x "ext") == ".ext"
--   Valid x =&gt; takeExtension (replaceExtension x "ext") == ".ext"
--   </pre>
takeExtension :: FilePath -> String

-- | Get the file name.
--   
--   <pre>
--   takeFileName "/directory/file.ext" == "file.ext"
--   takeFileName "test/" == ""
--   takeFileName x `isSuffixOf` x
--   takeFileName x == snd (splitFileName x)
--   Valid x =&gt; takeFileName (replaceFileName x "fred") == "fred"
--   Valid x =&gt; takeFileName (x &lt;/&gt; "fred") == "fred"
--   Valid x =&gt; isRelative (takeFileName x)
--   </pre>
takeFileName :: FilePath -> FilePath

-- | Create a <a>FilePath</a> from a <a>ModuleIdent</a> using the
--   hierarchical module system
moduleNameToFile :: ModuleIdent -> FilePath

-- | Extract the <a>ModuleIdent</a> from a <a>FilePath</a>
fileNameToModule :: FilePath -> ModuleIdent

-- | Split a <a>FilePath</a> into a prefix directory part and those part
--   that corresponds to the <a>ModuleIdent</a>. This is especially useful
--   for hierarchically module names.
splitModuleFileName :: ModuleIdent -> FilePath -> (FilePath, FilePath)

-- | Checks whether a <a>String</a> represents a <a>FilePath</a> to a Curry
--   module
isCurryFilePath :: String -> Bool

-- | The standard hidden subdirectory for curry files
defaultOutDir :: String

-- | Does the given <a>FilePath</a> contain the <tt>outDir</tt> as its last
--   directory component?
hasOutDir :: String -> FilePath -> Bool

-- | Add the <tt>outDir</tt> to the given <a>FilePath</a> if the flag is
--   <a>True</a> and the path does not already contain it, otherwise leave
--   the path untouched.
addOutDir :: Bool -> String -> FilePath -> FilePath

-- | Add the <tt>outDir</tt> to the given <a>FilePath</a> if the flag is
--   <a>True</a> and the path does not already contain it, otherwise leave
--   the path untouched.
addOutDirModule :: Bool -> String -> ModuleIdent -> FilePath -> FilePath

-- | Ensure that the <tt>outDir</tt> is the last component of the directory
--   structure of the given <a>FilePath</a>. If the <a>FilePath</a> already
--   contains the sub-directory, it remains unchanged.
ensureOutDir :: String -> FilePath -> FilePath

-- | Filename extension for non-literate curry files
curryExt :: String

-- | Filename extension for literate curry files
lcurryExt :: String

-- | Filename extension for curry interface files
icurryExt :: String

-- | Filename extension for type-annotated flat-curry files
annotatedFlatExt :: String

-- | Filename extension for typed flat-curry files
typedFlatExt :: String

-- | Filename extension for flat-curry files
flatExt :: String

-- | Filename extension for extended-flat-curry interface files
flatIntExt :: String

-- | Filename extension for abstract-curry files
acyExt :: String

-- | Filename extension for untyped-abstract-curry files
uacyExt :: String

-- | Filename extension for curry source representation files
sourceRepExt :: String

-- | Filename extension for curry source files.
--   
--   <i>Note:</i> The order of the extensions defines the order in which
--   source files should be searched for, i.e. given a module name
--   <tt>M</tt>, the search order should be the following:
--   
--   <ol>
--   <li><pre>M.curry</pre></li>
--   <li><pre>M.lcurry</pre></li>
--   </ol>
sourceExts :: [String]

-- | Filename extension for curry module files TODO: Is the order correct?
moduleExts :: [String]

-- | Compute the filename of the interface file for a source file
interfName :: FilePath -> FilePath

-- | Compute the filename of the typed flat curry file for a source file
typedFlatName :: FilePath -> FilePath

-- | Compute the filename of the typed flat curry file for a source file
annotatedFlatName :: FilePath -> FilePath

-- | Compute the filename of the flat curry file for a source file
flatName :: FilePath -> FilePath

-- | Compute the filename of the flat curry interface file for a source
--   file
flatIntName :: FilePath -> FilePath

-- | Compute the filename of the abstract curry file for a source file
acyName :: FilePath -> FilePath

-- | Compute the filename of the untyped abstract curry file for a source
--   file
uacyName :: FilePath -> FilePath

-- | Compute the filename of the source representation file for a source
--   file
sourceRepName :: FilePath -> FilePath

-- | Compute the filename of the tokens file for a source file
tokensName :: FilePath -> FilePath

-- | Compute the filename of the comment tokens file for a source file
commentsName :: FilePath -> FilePath

-- | Compute the filename of the ast file for a source file
astName :: FilePath -> FilePath

-- | Compute the filename of the ast file for a source file
shortASTName :: FilePath -> FilePath

-- | Compute the filename of the HTML file for a source file
htmlName :: ModuleIdent -> String


module Curry.Files.PathUtils

-- | Search in the given list of paths for the given <a>FilePath</a> and
--   eventually return the file name of the found file.
--   
--   <ul>
--   <li>If the file name already contains a directory, then the paths to
--   search in are ignored.</li>
--   <li>If the file name has no extension, then a source file extension is
--   assumed.</li>
--   </ul>
lookupCurryFile :: [FilePath] -> FilePath -> IO (Maybe FilePath)

-- | Search for a given curry module in the given source file and library
--   paths. Note that the current directory is always searched first.
--   Returns the path of the found file.
lookupCurryModule :: [FilePath] -> [FilePath] -> ModuleIdent -> IO (Maybe FilePath)

-- | Search for an interface file in the import search path using the
--   interface extension <a>icurryExt</a>. Note that the current directory
--   is always searched first.
lookupCurryInterface :: [FilePath] -> ModuleIdent -> IO (Maybe FilePath)

-- | Search in the given directories for the file with the specified file
--   extensions and eventually return the <a>FilePath</a> of the file.
lookupFile :: [FilePath] -> [String] -> FilePath -> IO (Maybe FilePath)

-- | Get the modification time of a file, if existent
getModuleModTime :: FilePath -> IO (Maybe UTCTime)

-- | Write the content to a file in the given directory.
writeModule :: FilePath -> String -> IO ()

-- | Read the specified module and returns either 'Just String' if reading
--   was successful or <a>Nothing</a> otherwise.
readModule :: FilePath -> IO (Maybe String)

-- | Write the content in binary to a file in the given directory.
writeBinaryModule :: FilePath -> ByteString -> IO ()

-- | Add the given version string to the file content
addVersion :: String -> String -> String

-- | Check a source file for the given version string
checkVersion :: String -> String -> Either String String


-- | This library contains I/O actions to read Curry programs and transform
--   them into this abstract representation as well as write them to a
--   file.
module Curry.AbstractCurry.Files

-- | Read an AbstractCurry file and return the corresponding AbstractCurry
--   program term of type <a>CurryProg</a>
readCurry :: FilePath -> IO (Maybe CurryProg)

-- | Write an AbstractCurry program term into a file.
writeCurry :: FilePath -> CurryProg -> IO ()

-- | Show an AbstractCurry program in a nicer way
showCurry :: CurryProg -> String


-- | This library contains a definition for representing Curry programs in
--   Haskell by the type <a>CurryProg</a> and I/O actions to read Curry
--   programs and transform them into this abstract representation as well
--   as write them to a file.
--   
--   Note that this defines a slightly new format for AbstractCurry in
--   comparison to the first proposal of 2003.
--   
--   <i>Assumption:</i> An AbstractCurry program <tt>Prog</tt> is stored in
--   a file with the file extension <tt>acy</tt>, i.e. in a file
--   <tt>Prog.acy</tt>.
module Curry.AbstractCurry


-- | Since version 0.7 of the language report, Curry accepts literate
--   source programs. In a literate source, all program lines must begin
--   with a greater sign in the first column. All other lines are assumed
--   to be documentation. In order to avoid some common errors with
--   literate programs, Curry requires at least one program line to be
--   present in the file. In addition, every block of program code must be
--   preceded by a blank line and followed by a blank line.
--   
--   It is also possible to use "begin{code}" and "end{code}" to mark code
--   segments. Both styles can be used in mixed fashion.
module Curry.Files.Unlit

-- | Check whether a <a>FilePath</a> represents a literate Curry module
isLiterate :: FilePath -> Bool

-- | Process a curry program into error messages (if any) and the
--   corresponding non-literate program.
unlit :: FilePath -> String -> CYM String


-- | This module contains a definition for representing FlatCurry programs
--   in Haskell in type <a>Prog</a>.
module Curry.FlatCurry.Type

-- | Qualified names.
--   
--   In FlatCurry all names are qualified to avoid name clashes. The first
--   component is the module name and the second component the unqualified
--   name as it occurs in the source program.
type QName = (String, String)

-- | Representation of variables.
type VarIndex = Int

-- | Type variables are represented by <tt>(TVar i)</tt> where <tt>i</tt>
--   is a type variable index.
type TVarIndex = Int

-- | Kinded type variables are represented by a tuple of type variable
--   index and kind.
type TVarWithKind = (TVarIndex, Kind)

-- | Visibility of various entities.
data Visibility

-- | public (exported) entity
Public :: Visibility

-- | private entity
Private :: Visibility

-- | A FlatCurry module.
--   
--   A value of this data type has the form
--   
--   <pre>
--   Prog modname imports typedecls functions opdecls
--   </pre>
--   
--   where
--   
--   <ul>
--   <li><i><tt>modname</tt></i> Name of this module</li>
--   <li><i><tt>imports</tt></i> List of modules names that are
--   imported</li>
--   <li><i><tt>typedecls</tt></i> Type declarations</li>
--   <li><i><tt>funcdecls</tt></i> Function declarations</li>
--   <li><i><tt> opdecls</tt></i> Operator declarations</li>
--   </ul>
data Prog
Prog :: String -> [String] -> [TypeDecl] -> [FuncDecl] -> [OpDecl] -> Prog

-- | Declaration of algebraic data type or type synonym.
--   
--   A data type declaration of the form
--   
--   <pre>
--   data t x1...xn = ...| c t1....tkc |...
--   </pre>
--   
--   is represented by the FlatCurry term
--   
--   <pre>
--   Type t [i1,...,in] [...(Cons c kc [t1,...,tkc])...]
--   </pre>
--   
--   where each <tt>ij</tt> is the index of the type variable <tt>xj</tt>
--   
--   <i>Note:</i> The type variable indices are unique inside each type
--   declaration and are usually numbered from 0.
--   
--   Thus, a data type declaration consists of the name of the data type, a
--   list of type parameters and a list of constructor declarations.
data TypeDecl
Type :: QName -> Visibility -> [TVarWithKind] -> [ConsDecl] -> TypeDecl
TypeSyn :: QName -> Visibility -> [TVarWithKind] -> TypeExpr -> TypeDecl
TypeNew :: QName -> Visibility -> [TVarWithKind] -> NewConsDecl -> TypeDecl

-- | Type expressions.
--   
--   A type expression is either a type variable, a function type, or a
--   type constructor application.
--   
--   <i>Note:</i> the names of the predefined type constructors are
--   <tt>Int</tt>, <tt>Float</tt>, <tt>Bool</tt>, <tt>Char</tt>,
--   <tt>IO</tt>, <tt>Success</tt>, <tt>()</tt> (unit type),
--   <tt>(,...,)</tt> (tuple types), <tt>[]</tt> (list type)
data TypeExpr

-- | type variable
TVar :: TVarIndex -> TypeExpr

-- | function type <tt>t1 -&gt; t2</tt>
FuncType :: TypeExpr -> TypeExpr -> TypeExpr

-- | type constructor application
TCons :: QName -> [TypeExpr] -> TypeExpr

-- | forall type
ForallType :: [TVarWithKind] -> TypeExpr -> TypeExpr

-- | Kinds.
--   
--   A kind is either * or k_1 -&gt; k_2 where k_1 and k_2 are kinds.
data Kind

-- | star kind
KStar :: Kind

-- | arrow kind
KArrow :: Kind -> Kind -> Kind

-- | A constructor declaration consists of the name and arity of the
--   constructor and a list of the argument types of the constructor.
data ConsDecl
Cons :: QName -> Int -> Visibility -> [TypeExpr] -> ConsDecl

-- | A constructor declaration for a newtype consists of the name of the
--   constructor and the argument type of the constructor.
data NewConsDecl
NewCons :: QName -> Visibility -> TypeExpr -> NewConsDecl

-- | Operator declarations.
--   
--   An operator declaration <tt>fix p n</tt> in Curry corresponds to the
--   FlatCurry term <tt>(Op n fix p)</tt>.
--   
--   <i>Note:</i> the constructor definition of <a>Op</a> differs from the
--   original PAKCS definition using Haskell type <a>Integer</a> instead of
--   <a>Int</a> for representing the precedence.
data OpDecl
Op :: QName -> Fixity -> Integer -> OpDecl

-- | Fixity of an operator.
data Fixity

-- | non-associative infix operator
InfixOp :: Fixity

-- | left-associative infix operator
InfixlOp :: Fixity

-- | right-associative infix operator
InfixrOp :: Fixity

-- | Data type for representing function declarations.
--   
--   A function declaration in FlatCurry is a term of the form
--   
--   <pre>
--   (Func name arity type (Rule [i_1,...,i_arity] e))
--   </pre>
--   
--   and represents the function "name" with definition
--   
--   <pre>
--   name :: type
--   name x_1...x_arity = e
--   </pre>
--   
--   where each <tt>i_j</tt> is the index of the variable <tt>x_j</tt>
--   
--   <i>Note:</i> The variable indices are unique inside each function
--   declaration and are usually numbered from 0.
--   
--   External functions are represented as
--   
--   <pre>
--   Func name arity type (External s)
--   </pre>
--   
--   where s is the external name associated to this function.
--   
--   Thus, a function declaration consists of the name, arity, type, and
--   rule.
data FuncDecl
Func :: QName -> Int -> Visibility -> TypeExpr -> Rule -> FuncDecl

-- | A rule is either a list of formal parameters together with an
--   expression or an <a>External</a> tag.
data Rule
Rule :: [VarIndex] -> Expr -> Rule
External :: String -> Rule

-- | Data type for representing expressions.
--   
--   Remarks:
--   
--   <ol>
--   <li>if-then-else expressions are represented as function calls:</li>
--   </ol>
--   
--   <pre>
--   (if e1 then e2 else e3)
--   </pre>
--   
--   is represented as
--   
--   <pre>
--   (Comb FuncCall (<a>Prelude</a>,"ifThenElse") [e1,e2,e3])
--   </pre>
--   
--   <ol>
--   <li>Higher order applications are represented as calls to the
--   (external) function <tt>apply</tt>. For instance, the rule</li>
--   </ol>
--   
--   <pre>
--   app f x = f x
--   </pre>
--   
--   is represented as
--   
--   <pre>
--   (Rule  [0,1] (Comb FuncCall (<a>Prelude</a>,"apply") [Var 0, Var 1]))
--   </pre>
--   
--   <ol>
--   <li>A conditional rule is represented as a call to an external
--   function <tt>cond</tt> where the first argument is the condition (a
--   constraint).</li>
--   </ol>
--   
--   For instance, the rule
--   
--   <pre>
--   equal2 x | x=:=2 = success
--   </pre>
--   
--   is represented as
--   
--   <pre>
--   (Rule [0]
--       (Comb FuncCall (<a>Prelude</a>,"cond")
--             [Comb FuncCall (<a>Prelude</a>,"=:=") [Var 0, Lit (Intc 2)],
--             Comb FuncCall (<a>Prelude</a>,"success") []]))
--   
--   </pre>
--   
--   <ol>
--   <li>Functions with evaluation annotation <tt>choice</tt> are
--   represented by a rule whose right-hand side is enclosed in a call to
--   the external function <tt>Prelude.commit</tt>. Furthermore, all rules
--   of the original definition must be represented by conditional
--   expressions (i.e., (cond [c,e])) after pattern matching.</li>
--   </ol>
--   
--   Example:
--   
--   <pre>
--   m eval choice
--   m [] y = y
--   m x [] = x
--   
--   </pre>
--   
--   is translated into (note that the conditional branches can be also
--   wrapped with Free declarations in general):
--   
--   <pre>
--   Rule [0,1]
--     (Comb FuncCall (<a>Prelude</a>,"commit")
--       [Or (Case Rigid (Var 0)
--             [(Pattern (<a>Prelude</a>,"[]") []
--                 (Comb FuncCall (<a>Prelude</a>,"cond")
--                       [Comb FuncCall (<a>Prelude</a>,"success") [],
--                         Var 1]))] )
--           (Case Rigid (Var 1)
--             [(Pattern (<a>Prelude</a>,"[]") []
--                 (Comb FuncCall (<a>Prelude</a>,"cond")
--                       [Comb FuncCall (<a>Prelude</a>,"success") [],
--                         Var 0]))] )])
--   
--   </pre>
--   
--   Operational meaning of <tt>(Prelude.commit e)</tt>: evaluate
--   <tt>e</tt> with local search spaces and commit to the first <tt>(Comb
--   FuncCall (<a>Prelude</a>,"cond") [c,ge])</tt> in <tt>e</tt> whose
--   constraint <tt>c</tt> is satisfied
data Expr

-- | Variable, represented by unique index
Var :: VarIndex -> Expr

-- | Literal (Integer<i>Float</i>Char constant)
Lit :: Literal -> Expr

-- | Application <tt>(f e1 ... en)</tt> of function/constructor <tt>f</tt>
--   with <tt>n &lt;= arity f</tt>
Comb :: CombType -> QName -> [Expr] -> Expr

-- | Introduction of free local variables for an expression
Free :: [VarIndex] -> Expr -> Expr

-- | Local let-declarations
Let :: [(VarIndex, Expr)] -> Expr -> Expr

-- | Disjunction of two expressions (resulting from overlapping left-hand
--   sides)
Or :: Expr -> Expr -> Expr

-- | case expression
Case :: CaseType -> Expr -> [BranchExpr] -> Expr

-- | typed expression
Typed :: Expr -> TypeExpr -> Expr

-- | Data type for representing literals.
--   
--   A literal is either an integer, a float, or a character constant.
--   
--   <i>Note:</i> The constructor definition of <a>Intc</a> differs from
--   the original PAKCS definition. It uses Haskell type <a>Integer</a>
--   instead of <a>Int</a> to provide an unlimited range of integer
--   numbers. Furthermore, float values are represented with Haskell type
--   <a>Double</a> instead of <a>Float</a>.
data Literal
Intc :: Integer -> Literal
Floatc :: Double -> Literal
Charc :: Char -> Literal

-- | Data type for classifying combinations (i.e., a function/constructor
--   applied to some arguments).
data CombType

-- | a call to a function where all arguments are provided
FuncCall :: CombType

-- | a call with a constructor at the top, all arguments are provided
ConsCall :: CombType

-- | a partial call to a function (i.e., not all arguments are provided)
--   where the parameter is the number of missing arguments
FuncPartCall :: Int -> CombType

-- | a partial call to a constructor along with number of missing arguments
ConsPartCall :: Int -> CombType

-- | Classification of case expressions, either flexible or rigid.
data CaseType
Rigid :: CaseType
Flex :: CaseType

-- | Branches in a case expression.
--   
--   Branches <tt>(m.c x1...xn) -&gt; e</tt> in case expressions are
--   represented as
--   
--   <pre>
--   (Branch (Pattern (m,c) [i1,...,in]) e)
--   </pre>
--   
--   where each <tt>ij</tt> is the index of the pattern variable
--   <tt>xj</tt>, or as
--   
--   <pre>
--   (Branch (LPattern (Intc i)) e)
--   </pre>
--   
--   for integers as branch patterns (similarly for other literals like
--   float or character constants).
data BranchExpr
Branch :: Pattern -> Expr -> BranchExpr

-- | Patterns in case expressions.
data Pattern
Pattern :: QName -> [VarIndex] -> Pattern
LPattern :: Literal -> Pattern
instance GHC.Show.Show Curry.FlatCurry.Type.Prog
instance GHC.Read.Read Curry.FlatCurry.Type.Prog
instance GHC.Classes.Eq Curry.FlatCurry.Type.Prog
instance GHC.Show.Show Curry.FlatCurry.Type.FuncDecl
instance GHC.Read.Read Curry.FlatCurry.Type.FuncDecl
instance GHC.Classes.Eq Curry.FlatCurry.Type.FuncDecl
instance GHC.Show.Show Curry.FlatCurry.Type.Rule
instance GHC.Read.Read Curry.FlatCurry.Type.Rule
instance GHC.Classes.Eq Curry.FlatCurry.Type.Rule
instance GHC.Show.Show Curry.FlatCurry.Type.Expr
instance GHC.Read.Read Curry.FlatCurry.Type.Expr
instance GHC.Classes.Eq Curry.FlatCurry.Type.Expr
instance GHC.Show.Show Curry.FlatCurry.Type.BranchExpr
instance GHC.Read.Read Curry.FlatCurry.Type.BranchExpr
instance GHC.Classes.Eq Curry.FlatCurry.Type.BranchExpr
instance GHC.Show.Show Curry.FlatCurry.Type.Pattern
instance GHC.Read.Read Curry.FlatCurry.Type.Pattern
instance GHC.Classes.Eq Curry.FlatCurry.Type.Pattern
instance GHC.Show.Show Curry.FlatCurry.Type.CaseType
instance GHC.Read.Read Curry.FlatCurry.Type.CaseType
instance GHC.Classes.Eq Curry.FlatCurry.Type.CaseType
instance GHC.Show.Show Curry.FlatCurry.Type.CombType
instance GHC.Read.Read Curry.FlatCurry.Type.CombType
instance GHC.Classes.Eq Curry.FlatCurry.Type.CombType
instance GHC.Show.Show Curry.FlatCurry.Type.Literal
instance GHC.Read.Read Curry.FlatCurry.Type.Literal
instance GHC.Classes.Eq Curry.FlatCurry.Type.Literal
instance GHC.Show.Show Curry.FlatCurry.Type.OpDecl
instance GHC.Read.Read Curry.FlatCurry.Type.OpDecl
instance GHC.Classes.Eq Curry.FlatCurry.Type.OpDecl
instance GHC.Show.Show Curry.FlatCurry.Type.Fixity
instance GHC.Read.Read Curry.FlatCurry.Type.Fixity
instance GHC.Classes.Eq Curry.FlatCurry.Type.Fixity
instance GHC.Show.Show Curry.FlatCurry.Type.TypeDecl
instance GHC.Read.Read Curry.FlatCurry.Type.TypeDecl
instance GHC.Classes.Eq Curry.FlatCurry.Type.TypeDecl
instance GHC.Show.Show Curry.FlatCurry.Type.ConsDecl
instance GHC.Read.Read Curry.FlatCurry.Type.ConsDecl
instance GHC.Classes.Eq Curry.FlatCurry.Type.ConsDecl
instance GHC.Show.Show Curry.FlatCurry.Type.NewConsDecl
instance GHC.Read.Read Curry.FlatCurry.Type.NewConsDecl
instance GHC.Classes.Eq Curry.FlatCurry.Type.NewConsDecl
instance GHC.Show.Show Curry.FlatCurry.Type.TypeExpr
instance GHC.Read.Read Curry.FlatCurry.Type.TypeExpr
instance GHC.Classes.Eq Curry.FlatCurry.Type.TypeExpr
instance GHC.Show.Show Curry.FlatCurry.Type.Kind
instance GHC.Read.Read Curry.FlatCurry.Type.Kind
instance GHC.Classes.Ord Curry.FlatCurry.Type.Kind
instance GHC.Classes.Eq Curry.FlatCurry.Type.Kind
instance GHC.Show.Show Curry.FlatCurry.Type.Visibility
instance GHC.Read.Read Curry.FlatCurry.Type.Visibility
instance GHC.Classes.Eq Curry.FlatCurry.Type.Visibility
instance Data.Binary.Class.Binary Curry.FlatCurry.Type.Prog
instance Data.Binary.Class.Binary Curry.FlatCurry.Type.FuncDecl
instance Data.Binary.Class.Binary Curry.FlatCurry.Type.Rule
instance Data.Binary.Class.Binary Curry.FlatCurry.Type.Expr
instance Data.Binary.Class.Binary Curry.FlatCurry.Type.BranchExpr
instance Data.Binary.Class.Binary Curry.FlatCurry.Type.Pattern
instance Data.Binary.Class.Binary Curry.FlatCurry.Type.CaseType
instance Data.Binary.Class.Binary Curry.FlatCurry.Type.CombType
instance Data.Binary.Class.Binary Curry.FlatCurry.Type.Literal
instance Data.Binary.Class.Binary Curry.FlatCurry.Type.OpDecl
instance Data.Binary.Class.Binary Curry.FlatCurry.Type.Fixity
instance Data.Binary.Class.Binary Curry.FlatCurry.Type.TypeDecl
instance Data.Binary.Class.Binary Curry.FlatCurry.Type.ConsDecl
instance Data.Binary.Class.Binary Curry.FlatCurry.Type.NewConsDecl
instance Data.Binary.Class.Binary Curry.FlatCurry.Type.TypeExpr
instance Data.Binary.Class.Binary Curry.FlatCurry.Type.Kind
instance Data.Binary.Class.Binary Curry.FlatCurry.Type.Visibility


-- | This module implements a pretty printer for FlatCurry modules.
module Curry.FlatCurry.Pretty

-- | Pretty-print something in isolation.
pPrint :: Pretty a => a -> Doc

-- | Pretty-print something in a precedence context.
pPrintPrec :: Pretty a => Int -> a -> Doc
instance Curry.Base.Pretty.Pretty Curry.FlatCurry.Type.Prog
instance Curry.Base.Pretty.Pretty Curry.FlatCurry.Type.OpDecl
instance Curry.Base.Pretty.Pretty Curry.FlatCurry.Type.Fixity
instance Curry.Base.Pretty.Pretty Curry.FlatCurry.Type.TypeDecl
instance Curry.Base.Pretty.Pretty Curry.FlatCurry.Type.ConsDecl
instance Curry.Base.Pretty.Pretty Curry.FlatCurry.Type.NewConsDecl
instance Curry.Base.Pretty.Pretty Curry.FlatCurry.Type.TypeExpr
instance Curry.Base.Pretty.Pretty Curry.FlatCurry.Type.FuncDecl
instance Curry.Base.Pretty.Pretty Curry.FlatCurry.Type.Rule
instance Curry.Base.Pretty.Pretty Curry.FlatCurry.Type.Expr
instance Curry.Base.Pretty.Pretty Curry.FlatCurry.Type.Literal
instance Curry.Base.Pretty.Pretty Curry.FlatCurry.Type.CaseType
instance Curry.Base.Pretty.Pretty Curry.FlatCurry.Type.BranchExpr
instance Curry.Base.Pretty.Pretty Curry.FlatCurry.Type.Pattern


module Curry.FlatCurry.InterfaceEquivalence

-- | Check whether the interfaces of two FlatCurry programs are equivalent.
eqInterface :: Prog -> Prog -> Bool
instance Curry.FlatCurry.InterfaceEquivalence.Equiv a => Curry.FlatCurry.InterfaceEquivalence.Equiv [a]
instance Curry.FlatCurry.InterfaceEquivalence.Equiv GHC.Types.Char
instance Curry.FlatCurry.InterfaceEquivalence.Equiv Curry.FlatCurry.Type.Prog
instance Curry.FlatCurry.InterfaceEquivalence.Equiv Curry.FlatCurry.Type.TypeDecl
instance Curry.FlatCurry.InterfaceEquivalence.Equiv Curry.FlatCurry.Type.FuncDecl
instance Curry.FlatCurry.InterfaceEquivalence.Equiv Curry.FlatCurry.Type.Rule
instance Curry.FlatCurry.InterfaceEquivalence.Equiv Curry.FlatCurry.Type.OpDecl


-- | This library provides selector functions, test and update operations
--   as well as some useful auxiliary functions for FlatCurry data terms.
--   Most of the provided functions are based on general transformation
--   functions that replace constructors with user-defined functions. For
--   recursive datatypes the transformations are defined inductively over
--   the term structure. This is quite usual for transformations on
--   FlatCurry terms, so the provided functions can be used to implement
--   specific transformations without having to explicitly state the
--   recursion. Essentially, the tedious part of such transformations -
--   descend in fairly complex term structures - is abstracted away, which
--   hopefully makes the code more clear and brief.
module Curry.FlatCurry.Goodies

-- | Update of a type's component
type Update a b = (b -> b) -> a -> a

-- | transform program
trProg :: (String -> [String] -> [TypeDecl] -> [FuncDecl] -> [OpDecl] -> a) -> Prog -> a

-- | get name from program
progName :: Prog -> String

-- | get imports from program
progImports :: Prog -> [String]

-- | get type declarations from program
progTypes :: Prog -> [TypeDecl]

-- | get functions from program
progFuncs :: Prog -> [FuncDecl]

-- | get infix operators from program
progOps :: Prog -> [OpDecl]

-- | update program
updProg :: (String -> String) -> ([String] -> [String]) -> ([TypeDecl] -> [TypeDecl]) -> ([FuncDecl] -> [FuncDecl]) -> ([OpDecl] -> [OpDecl]) -> Prog -> Prog

-- | update name of program
updProgName :: Update Prog String

-- | update imports of program
updProgImports :: Update Prog [String]

-- | update type declarations of program
updProgTypes :: Update Prog [TypeDecl]

-- | update functions of program
updProgFuncs :: Update Prog [FuncDecl]

-- | update infix operators of program
updProgOps :: Update Prog [OpDecl]

-- | get all program variables (also from patterns)
allVarsInProg :: Prog -> [VarIndex]

-- | lift transformation on expressions to program
updProgExps :: Update Prog Expr

-- | rename programs variables
rnmAllVarsInProg :: Update Prog VarIndex

-- | update all qualified names in program
updQNamesInProg :: Update Prog QName

-- | rename program (update name of and all qualified names in program)
rnmProg :: String -> Prog -> Prog

-- | transform type declaration
trType :: (QName -> Visibility -> [TVarWithKind] -> [ConsDecl] -> a) -> (QName -> Visibility -> [TVarWithKind] -> TypeExpr -> a) -> (QName -> Visibility -> [TVarWithKind] -> NewConsDecl -> a) -> TypeDecl -> a

-- | get name of type declaration
typeName :: TypeDecl -> QName

-- | get visibility of type declaration
typeVisibility :: TypeDecl -> Visibility

-- | get type parameters of type declaration
typeParams :: TypeDecl -> [TVarWithKind]

-- | get constructor declarations from type declaration
typeConsDecls :: TypeDecl -> [ConsDecl]

-- | get synonym of type declaration
typeSyn :: TypeDecl -> TypeExpr

-- | is type declaration a type synonym?
isTypeSyn :: TypeDecl -> Bool

-- | is type declaration declaring a regular type?
isDataTypeDecl :: TypeDecl -> Bool

-- | is type declaration declaring an external type?
isExternalType :: TypeDecl -> Bool

-- | is type declaration a newtype?
isNewtype :: TypeDecl -> Bool

-- | Is the <a>TypeDecl</a> public?
isPublicType :: TypeDecl -> Bool

-- | update type declaration
updType :: (QName -> QName) -> (Visibility -> Visibility) -> ([TVarWithKind] -> [TVarWithKind]) -> ([ConsDecl] -> [ConsDecl]) -> (NewConsDecl -> NewConsDecl) -> (TypeExpr -> TypeExpr) -> TypeDecl -> TypeDecl

-- | update name of type declaration
updTypeName :: Update TypeDecl QName

-- | update visibility of type declaration
updTypeVisibility :: Update TypeDecl Visibility

-- | update type parameters of type declaration
updTypeParams :: Update TypeDecl [TVarWithKind]

-- | update constructor declarations of type declaration
updTypeConsDecls :: Update TypeDecl [ConsDecl]

-- | update constructor declarations of newtype declaration
updTypeNewConsDecls :: Update TypeDecl NewConsDecl

-- | update synonym of type declaration
updTypeSynonym :: Update TypeDecl TypeExpr

-- | update all qualified names in type declaration
updQNamesInType :: Update TypeDecl QName

-- | transform constructor declaration
trCons :: (QName -> Int -> Visibility -> [TypeExpr] -> a) -> ConsDecl -> a

-- | get name of constructor declaration
consName :: ConsDecl -> QName

-- | get arity of constructor declaration
consArity :: ConsDecl -> Int

-- | get visibility of constructor declaration
consVisibility :: ConsDecl -> Visibility

-- | Is the constructor declaration public?
isPublicCons :: ConsDecl -> Bool

-- | get arguments of constructor declaration
consArgs :: ConsDecl -> [TypeExpr]

-- | update constructor declaration
updCons :: (QName -> QName) -> (Int -> Int) -> (Visibility -> Visibility) -> ([TypeExpr] -> [TypeExpr]) -> ConsDecl -> ConsDecl

-- | update name of constructor declaration
updConsName :: Update ConsDecl QName

-- | update arity of constructor declaration
updConsArity :: Update ConsDecl Int

-- | update visibility of constructor declaration
updConsVisibility :: Update ConsDecl Visibility

-- | update arguments of constructor declaration
updConsArgs :: Update ConsDecl [TypeExpr]

-- | update all qualified names in constructor declaration
updQNamesInConsDecl :: Update ConsDecl QName

-- | transform newtype constructor declaration
trNewCons :: (QName -> Visibility -> TypeExpr -> a) -> NewConsDecl -> a

-- | get name of new constructor declaration
newConsName :: NewConsDecl -> QName

-- | get visibility of new constructor declaration
newConsVisibility :: NewConsDecl -> Visibility

-- | Is the new constructor declaration public?
isPublicNewCons :: ConsDecl -> Bool

-- | get argument of new constructor declaration
newConsArg :: NewConsDecl -> TypeExpr

-- | update new constructor declaration
updNewCons :: (QName -> QName) -> (Visibility -> Visibility) -> (TypeExpr -> TypeExpr) -> NewConsDecl -> NewConsDecl

-- | update name of new constructor declaration
updNewConsName :: Update NewConsDecl QName

-- | update visibility of new constructor declaration
updNewConsVisibility :: Update NewConsDecl Visibility

-- | update argument of new constructor declaration
updNewConsArg :: Update NewConsDecl TypeExpr

-- | update all qualified names in new constructor declaration
updQNamesInNewConsDecl :: Update NewConsDecl QName

-- | get index from type variable
tVarIndex :: TypeExpr -> TVarIndex

-- | get domain from functional type
domain :: TypeExpr -> TypeExpr

-- | get range from functional type
range :: TypeExpr -> TypeExpr

-- | get name from constructed type
tConsName :: TypeExpr -> QName

-- | get arguments from constructed type
tConsArgs :: TypeExpr -> [TypeExpr]

-- | transform type expression
trTypeExpr :: (TVarIndex -> a) -> (QName -> [a] -> a) -> (a -> a -> a) -> ([TVarWithKind] -> a -> a) -> TypeExpr -> a

-- | is type expression a type variable?
isTVar :: TypeExpr -> Bool

-- | is type declaration a constructed type?
isTCons :: TypeExpr -> Bool

-- | is type declaration a functional type?
isFuncType :: TypeExpr -> Bool

-- | is type declaration a forall type?
isForallType :: TypeExpr -> Bool

-- | update all type variables
updTVars :: (TVarIndex -> TypeExpr) -> TypeExpr -> TypeExpr

-- | update all type constructors
updTCons :: (QName -> [TypeExpr] -> TypeExpr) -> TypeExpr -> TypeExpr

-- | update all functional types
updFuncTypes :: (TypeExpr -> TypeExpr -> TypeExpr) -> TypeExpr -> TypeExpr

-- | update all forall types
updForallTypes :: ([TVarWithKind] -> TypeExpr -> TypeExpr) -> TypeExpr -> TypeExpr

-- | get argument types from functional type
argTypes :: TypeExpr -> [TypeExpr]

-- | Compute the arity of a <a>TypeExpr</a>
typeArity :: TypeExpr -> Int

-- | get result type from (nested) functional type
resultType :: TypeExpr -> TypeExpr

-- | get indexes of all type variables
allVarsInTypeExpr :: TypeExpr -> [TVarIndex]

-- | yield the list of all contained type constructors
allTypeCons :: TypeExpr -> [QName]

-- | rename variables in type expression
rnmAllVarsInTypeExpr :: (TVarIndex -> TVarIndex) -> TypeExpr -> TypeExpr

-- | update all qualified names in type expression
updQNamesInTypeExpr :: (QName -> QName) -> TypeExpr -> TypeExpr

-- | transform operator declaration
trOp :: (QName -> Fixity -> Integer -> a) -> OpDecl -> a

-- | get name from operator declaration
opName :: OpDecl -> QName

-- | get fixity of operator declaration
opFixity :: OpDecl -> Fixity

-- | get precedence of operator declaration
opPrecedence :: OpDecl -> Integer

-- | update operator declaration
updOp :: (QName -> QName) -> (Fixity -> Fixity) -> (Integer -> Integer) -> OpDecl -> OpDecl

-- | update name of operator declaration
updOpName :: Update OpDecl QName

-- | update fixity of operator declaration
updOpFixity :: Update OpDecl Fixity

-- | update precedence of operator declaration
updOpPrecedence :: Update OpDecl Integer

-- | transform function
trFunc :: (QName -> Int -> Visibility -> TypeExpr -> Rule -> a) -> FuncDecl -> a

-- | get name of function
funcName :: FuncDecl -> QName

-- | get arity of function
funcArity :: FuncDecl -> Int

-- | get visibility of function
funcVisibility :: FuncDecl -> Visibility

-- | get type of function
funcType :: FuncDecl -> TypeExpr

-- | get rule of function
funcRule :: FuncDecl -> Rule

-- | update function
updFunc :: (QName -> QName) -> (Int -> Int) -> (Visibility -> Visibility) -> (TypeExpr -> TypeExpr) -> (Rule -> Rule) -> FuncDecl -> FuncDecl

-- | update name of function
updFuncName :: Update FuncDecl QName

-- | update arity of function
updFuncArity :: Update FuncDecl Int

-- | update visibility of function
updFuncVisibility :: Update FuncDecl Visibility

-- | update type of function
updFuncType :: Update FuncDecl TypeExpr

-- | update rule of function
updFuncRule :: Update FuncDecl Rule

-- | is function public?
isPublicFunc :: FuncDecl -> Bool

-- | is function externally defined?
isExternal :: FuncDecl -> Bool

-- | get variable names in a function declaration
allVarsInFunc :: FuncDecl -> [VarIndex]

-- | get arguments of function, if not externally defined
funcArgs :: FuncDecl -> [VarIndex]

-- | get body of function, if not externally defined
funcBody :: FuncDecl -> Expr

-- | get the right-hand-sides of a <a>FuncDecl</a>
funcRHS :: FuncDecl -> [Expr]

-- | rename all variables in function
rnmAllVarsInFunc :: Update FuncDecl VarIndex

-- | update all qualified names in function
updQNamesInFunc :: Update FuncDecl QName

-- | update arguments of function, if not externally defined
updFuncArgs :: Update FuncDecl [VarIndex]

-- | update body of function, if not externally defined
updFuncBody :: Update FuncDecl Expr

-- | transform rule
trRule :: ([VarIndex] -> Expr -> a) -> (String -> a) -> Rule -> a

-- | get rules arguments if it's not external
ruleArgs :: Rule -> [VarIndex]

-- | get rules body if it's not external
ruleBody :: Rule -> Expr

-- | get rules external declaration
ruleExtDecl :: Rule -> String

-- | is rule external?
isRuleExternal :: Rule -> Bool

-- | update rule
updRule :: ([VarIndex] -> [VarIndex]) -> (Expr -> Expr) -> (String -> String) -> Rule -> Rule

-- | update rules arguments
updRuleArgs :: Update Rule [VarIndex]

-- | update rules body
updRuleBody :: Update Rule Expr

-- | update rules external declaration
updRuleExtDecl :: Update Rule String

-- | get variable names in a functions rule
allVarsInRule :: Rule -> [VarIndex]

-- | rename all variables in rule
rnmAllVarsInRule :: Update Rule VarIndex

-- | update all qualified names in rule
updQNamesInRule :: Update Rule QName

-- | transform combination type
trCombType :: a -> (Int -> a) -> a -> (Int -> a) -> CombType -> a

-- | is type of combination FuncCall?
isCombTypeFuncCall :: CombType -> Bool

-- | is type of combination FuncPartCall?
isCombTypeFuncPartCall :: CombType -> Bool

-- | is type of combination ConsCall?
isCombTypeConsCall :: CombType -> Bool

-- | is type of combination ConsPartCall?
isCombTypeConsPartCall :: CombType -> Bool

-- | get internal number of variable
varNr :: Expr -> VarIndex

-- | get literal if expression is literal expression
literal :: Expr -> Literal

-- | get combination type of a combined expression
combType :: Expr -> CombType

-- | get name of a combined expression
combName :: Expr -> QName

-- | get arguments of a combined expression
combArgs :: Expr -> [Expr]

-- | get number of missing arguments if expression is combined
missingCombArgs :: Expr -> Int

-- | get indices of varoables in let declaration
letBinds :: Expr -> [(VarIndex, Expr)]

-- | get body of let declaration
letBody :: Expr -> Expr

-- | get variable indices from declaration of free variables
freeVars :: Expr -> [VarIndex]

-- | get expression from declaration of free variables
freeExpr :: Expr -> Expr

-- | get expressions from or-expression
orExps :: Expr -> [Expr]

-- | get case-type of case expression
caseType :: Expr -> CaseType

-- | get scrutinee of case expression
caseExpr :: Expr -> Expr

-- | get branch expressions from case expression
caseBranches :: Expr -> [BranchExpr]

-- | is expression a variable?
isVar :: Expr -> Bool

-- | is expression a literal expression?
isLit :: Expr -> Bool

-- | is expression combined?
isComb :: Expr -> Bool

-- | is expression a let expression?
isLet :: Expr -> Bool

-- | is expression a declaration of free variables?
isFree :: Expr -> Bool

-- | is expression an or-expression?
isOr :: Expr -> Bool

-- | is expression a case expression?
isCase :: Expr -> Bool

-- | transform expression
trExpr :: (VarIndex -> a) -> (Literal -> a) -> (CombType -> QName -> [a] -> a) -> ([(VarIndex, a)] -> a -> a) -> ([VarIndex] -> a -> a) -> (a -> a -> a) -> (CaseType -> a -> [b] -> a) -> (Pattern -> a -> b) -> (a -> TypeExpr -> a) -> Expr -> a

-- | update all variables in given expression
updVars :: (VarIndex -> Expr) -> Expr -> Expr

-- | update all literals in given expression
updLiterals :: (Literal -> Expr) -> Expr -> Expr

-- | update all combined expressions in given expression
updCombs :: (CombType -> QName -> [Expr] -> Expr) -> Expr -> Expr

-- | update all let expressions in given expression
updLets :: ([(VarIndex, Expr)] -> Expr -> Expr) -> Expr -> Expr

-- | update all free declarations in given expression
updFrees :: ([VarIndex] -> Expr -> Expr) -> Expr -> Expr

-- | update all or expressions in given expression
updOrs :: (Expr -> Expr -> Expr) -> Expr -> Expr

-- | update all case expressions in given expression
updCases :: (CaseType -> Expr -> [BranchExpr] -> Expr) -> Expr -> Expr

-- | update all case branches in given expression
updBranches :: (Pattern -> Expr -> BranchExpr) -> Expr -> Expr

-- | update all typed expressions in given expression
updTypeds :: (Expr -> TypeExpr -> Expr) -> Expr -> Expr

-- | is expression a call of a function where all arguments are provided?
isFuncCall :: Expr -> Bool

-- | is expression a partial function call?
isFuncPartCall :: Expr -> Bool

-- | is expression a call of a constructor?
isConsCall :: Expr -> Bool

-- | is expression a partial constructor call?
isConsPartCall :: Expr -> Bool

-- | is expression fully evaluated?
isGround :: Expr -> Bool

-- | get all variables (also pattern variables) in expression
allVars :: Expr -> [VarIndex]

-- | rename all variables (also in patterns) in expression
rnmAllVars :: Update Expr VarIndex

-- | update all qualified names in expression
updQNames :: Update Expr QName

-- | transform branch expression
trBranch :: (Pattern -> Expr -> a) -> BranchExpr -> a

-- | get pattern from branch expression
branchPattern :: BranchExpr -> Pattern

-- | get expression from branch expression
branchExpr :: BranchExpr -> Expr

-- | update branch expression
updBranch :: (Pattern -> Pattern) -> (Expr -> Expr) -> BranchExpr -> BranchExpr

-- | update pattern of branch expression
updBranchPattern :: Update BranchExpr Pattern

-- | update expression of branch expression
updBranchExpr :: Update BranchExpr Expr

-- | transform pattern
trPattern :: (QName -> [VarIndex] -> a) -> (Literal -> a) -> Pattern -> a

-- | get name from constructor pattern
patCons :: Pattern -> QName

-- | get arguments from constructor pattern
patArgs :: Pattern -> [VarIndex]

-- | get literal from literal pattern
patLiteral :: Pattern -> Literal

-- | is pattern a constructor pattern?
isConsPattern :: Pattern -> Bool

-- | update pattern
updPattern :: (QName -> QName) -> ([VarIndex] -> [VarIndex]) -> (Literal -> Literal) -> Pattern -> Pattern

-- | update constructors name of pattern
updPatCons :: (QName -> QName) -> Pattern -> Pattern

-- | update arguments of constructor pattern
updPatArgs :: ([VarIndex] -> [VarIndex]) -> Pattern -> Pattern

-- | update literal of pattern
updPatLiteral :: (Literal -> Literal) -> Pattern -> Pattern

-- | build expression from pattern
patExpr :: Pattern -> Expr

-- | Is this a public <a>Visibility</a>?
isPublic :: Visibility -> Bool


-- | This module defines a Typeclass for easy access to the type of entites
module Curry.FlatCurry.Typeable
class Typeable a
typeOf :: Typeable a => a -> TypeExpr
instance Curry.FlatCurry.Typeable.Typeable Curry.FlatCurry.Type.TypeExpr


-- | TODO
module Curry.FlatCurry.Annotated.Type
data APattern a
APattern :: a -> (QName, a) -> [(VarIndex, a)] -> APattern a
ALPattern :: a -> Literal -> APattern a
data ABranchExpr a
ABranch :: APattern a -> AExpr a -> ABranchExpr a
data AExpr a
AVar :: a -> VarIndex -> AExpr a
ALit :: a -> Literal -> AExpr a
AComb :: a -> CombType -> (QName, a) -> [AExpr a] -> AExpr a
ALet :: a -> [((VarIndex, a), AExpr a)] -> AExpr a -> AExpr a
AFree :: a -> [(VarIndex, a)] -> AExpr a -> AExpr a
AOr :: a -> AExpr a -> AExpr a -> AExpr a
ACase :: a -> CaseType -> AExpr a -> [ABranchExpr a] -> AExpr a
ATyped :: a -> AExpr a -> TypeExpr -> AExpr a
data ARule a
ARule :: a -> [(VarIndex, a)] -> AExpr a -> ARule a
AExternal :: a -> String -> ARule a
data AFuncDecl a
AFunc :: QName -> Int -> Visibility -> TypeExpr -> ARule a -> AFuncDecl a
data AProg a
AProg :: String -> [String] -> [TypeDecl] -> [AFuncDecl a] -> [OpDecl] -> AProg a

-- | Classification of case expressions, either flexible or rigid.
data CaseType
Rigid :: CaseType
Flex :: CaseType

-- | Data type for classifying combinations (i.e., a function/constructor
--   applied to some arguments).
data CombType

-- | a call to a function where all arguments are provided
FuncCall :: CombType

-- | a call with a constructor at the top, all arguments are provided
ConsCall :: CombType

-- | a partial call to a function (i.e., not all arguments are provided)
--   where the parameter is the number of missing arguments
FuncPartCall :: Int -> CombType

-- | a partial call to a constructor along with number of missing arguments
ConsPartCall :: Int -> CombType

-- | Data type for representing literals.
--   
--   A literal is either an integer, a float, or a character constant.
--   
--   <i>Note:</i> The constructor definition of <a>Intc</a> differs from
--   the original PAKCS definition. It uses Haskell type <a>Integer</a>
--   instead of <a>Int</a> to provide an unlimited range of integer
--   numbers. Furthermore, float values are represented with Haskell type
--   <a>Double</a> instead of <a>Float</a>.
data Literal
Intc :: Integer -> Literal
Floatc :: Double -> Literal
Charc :: Char -> Literal

-- | Fixity of an operator.
data Fixity

-- | non-associative infix operator
InfixOp :: Fixity

-- | left-associative infix operator
InfixlOp :: Fixity

-- | right-associative infix operator
InfixrOp :: Fixity

-- | Operator declarations.
--   
--   An operator declaration <tt>fix p n</tt> in Curry corresponds to the
--   FlatCurry term <tt>(Op n fix p)</tt>.
--   
--   <i>Note:</i> the constructor definition of <a>Op</a> differs from the
--   original PAKCS definition using Haskell type <a>Integer</a> instead of
--   <a>Int</a> for representing the precedence.
data OpDecl
Op :: QName -> Fixity -> Integer -> OpDecl

-- | Kinds.
--   
--   A kind is either * or k_1 -&gt; k_2 where k_1 and k_2 are kinds.
data Kind

-- | star kind
KStar :: Kind

-- | arrow kind
KArrow :: Kind -> Kind -> Kind

-- | Type expressions.
--   
--   A type expression is either a type variable, a function type, or a
--   type constructor application.
--   
--   <i>Note:</i> the names of the predefined type constructors are
--   <tt>Int</tt>, <tt>Float</tt>, <tt>Bool</tt>, <tt>Char</tt>,
--   <tt>IO</tt>, <tt>Success</tt>, <tt>()</tt> (unit type),
--   <tt>(,...,)</tt> (tuple types), <tt>[]</tt> (list type)
data TypeExpr

-- | type variable
TVar :: TVarIndex -> TypeExpr

-- | function type <tt>t1 -&gt; t2</tt>
FuncType :: TypeExpr -> TypeExpr -> TypeExpr

-- | type constructor application
TCons :: QName -> [TypeExpr] -> TypeExpr

-- | forall type
ForallType :: [TVarWithKind] -> TypeExpr -> TypeExpr

-- | A constructor declaration for a newtype consists of the name of the
--   constructor and the argument type of the constructor.
data NewConsDecl
NewCons :: QName -> Visibility -> TypeExpr -> NewConsDecl

-- | A constructor declaration consists of the name and arity of the
--   constructor and a list of the argument types of the constructor.
data ConsDecl
Cons :: QName -> Int -> Visibility -> [TypeExpr] -> ConsDecl

-- | Type variables are represented by <tt>(TVar i)</tt> where <tt>i</tt>
--   is a type variable index.
type TVarIndex = Int

-- | Declaration of algebraic data type or type synonym.
--   
--   A data type declaration of the form
--   
--   <pre>
--   data t x1...xn = ...| c t1....tkc |...
--   </pre>
--   
--   is represented by the FlatCurry term
--   
--   <pre>
--   Type t [i1,...,in] [...(Cons c kc [t1,...,tkc])...]
--   </pre>
--   
--   where each <tt>ij</tt> is the index of the type variable <tt>xj</tt>
--   
--   <i>Note:</i> The type variable indices are unique inside each type
--   declaration and are usually numbered from 0.
--   
--   Thus, a data type declaration consists of the name of the data type, a
--   list of type parameters and a list of constructor declarations.
data TypeDecl
Type :: QName -> Visibility -> [TVarWithKind] -> [ConsDecl] -> TypeDecl
TypeSyn :: QName -> Visibility -> [TVarWithKind] -> TypeExpr -> TypeDecl
TypeNew :: QName -> Visibility -> [TVarWithKind] -> NewConsDecl -> TypeDecl

-- | Visibility of various entities.
data Visibility

-- | public (exported) entity
Public :: Visibility

-- | private entity
Private :: Visibility

-- | Representation of variables.
type VarIndex = Int

-- | Qualified names.
--   
--   In FlatCurry all names are qualified to avoid name clashes. The first
--   component is the module name and the second component the unqualified
--   name as it occurs in the source program.
type QName = (String, String)
instance GHC.Show.Show a => GHC.Show.Show (Curry.FlatCurry.Annotated.Type.AProg a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.FlatCurry.Annotated.Type.AProg a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.FlatCurry.Annotated.Type.AProg a)
instance GHC.Show.Show a => GHC.Show.Show (Curry.FlatCurry.Annotated.Type.AFuncDecl a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.FlatCurry.Annotated.Type.AFuncDecl a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.FlatCurry.Annotated.Type.AFuncDecl a)
instance GHC.Show.Show a => GHC.Show.Show (Curry.FlatCurry.Annotated.Type.ARule a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.FlatCurry.Annotated.Type.ARule a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.FlatCurry.Annotated.Type.ARule a)
instance GHC.Show.Show a => GHC.Show.Show (Curry.FlatCurry.Annotated.Type.AExpr a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.FlatCurry.Annotated.Type.AExpr a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.FlatCurry.Annotated.Type.AExpr a)
instance GHC.Show.Show a => GHC.Show.Show (Curry.FlatCurry.Annotated.Type.ABranchExpr a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.FlatCurry.Annotated.Type.ABranchExpr a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.FlatCurry.Annotated.Type.ABranchExpr a)
instance GHC.Show.Show a => GHC.Show.Show (Curry.FlatCurry.Annotated.Type.APattern a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.FlatCurry.Annotated.Type.APattern a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.FlatCurry.Annotated.Type.APattern a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.FlatCurry.Annotated.Type.AProg a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.FlatCurry.Annotated.Type.AFuncDecl a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.FlatCurry.Annotated.Type.ARule a)
instance Curry.FlatCurry.Typeable.Typeable a => Curry.FlatCurry.Typeable.Typeable (Curry.FlatCurry.Annotated.Type.AExpr a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.FlatCurry.Annotated.Type.AExpr a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.FlatCurry.Annotated.Type.ABranchExpr a)
instance Curry.FlatCurry.Typeable.Typeable a => Curry.FlatCurry.Typeable.Typeable (Curry.FlatCurry.Annotated.Type.APattern a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.FlatCurry.Annotated.Type.APattern a)


-- | This module contains functions for reading and writing FlatCurry
--   files.
module Curry.FlatCurry.Files

-- | Reads an typed FlatCurry file (extension ".tfcy") and eventually
--   returns the corresponding FlatCurry program term (type <a>AProg</a>).
readTypedFlatCurry :: FilePath -> IO (Maybe (AProg TypeExpr))

-- | Reads a FlatCurry file (extension ".fcy") and eventually returns the
--   corresponding FlatCurry program term (type <a>Prog</a>).
readFlatCurry :: FilePath -> IO (Maybe Prog)

-- | Reads a FlatInterface file (extension <tt>.fint</tt>) and returns the
--   corresponding term (type <a>Prog</a>) as a value of type <a>Maybe</a>.
readFlatInterface :: FilePath -> IO (Maybe Prog)

-- | Writes a FlatCurry program term into a file.
writeFlatCurry :: Show a => FilePath -> a -> IO ()

-- | Writes a FlatCurry program term into a normal and a binary file.
writeBinaryFlatCurry :: Binary a => FilePath -> a -> IO ()


module Curry.FlatCurry


-- | This library provides selector functions, test and update operations
--   as well as some useful auxiliary functions for AnnotatedFlatCurry data
--   terms. Most of the provided functions are based on general
--   transformation functions that replace constructors with user-defined
--   functions. For recursive datatypes the transformations are defined
--   inductively over the term structure. This is quite usual for
--   transformations on AnnotatedFlatCurry terms, so the provided functions
--   can be used to implement specific transformations without having to
--   explicitly state the recursion. Essentially, the tedious part of such
--   transformations - descend in fairly complex term structures - is
--   abstracted away, which hopefully makes the code more clear and brief.
module Curry.FlatCurry.Annotated.Goodies

-- | transform program
trAProg :: (String -> [String] -> [TypeDecl] -> [AFuncDecl a] -> [OpDecl] -> b) -> AProg a -> b

-- | get name from program
aProgName :: AProg a -> String

-- | get imports from program
aProgImports :: AProg a -> [String]

-- | get type declarations from program
aProgTypes :: AProg a -> [TypeDecl]

-- | get functions from program
aProgAFuncs :: AProg a -> [AFuncDecl a]

-- | get infix operators from program
aProgOps :: AProg a -> [OpDecl]

-- | update program
updAProg :: (String -> String) -> ([String] -> [String]) -> ([TypeDecl] -> [TypeDecl]) -> ([AFuncDecl a] -> [AFuncDecl a]) -> ([OpDecl] -> [OpDecl]) -> AProg a -> AProg a

-- | update name of program
updAProgName :: Update (AProg a) String

-- | update imports of program
updAProgImports :: Update (AProg a) [String]

-- | update type declarations of program
updAProgTypes :: Update (AProg a) [TypeDecl]

-- | update functions of program
updAProgAFuncs :: Update (AProg a) [AFuncDecl a]

-- | update infix operators of program
updAProgOps :: Update (AProg a) [OpDecl]

-- | get all program variables (also from patterns)
allVarsInAProg :: AProg a -> [(VarIndex, a)]

-- | lift transformation on expressions to program
updAProgAExps :: Update (AProg a) (AExpr a)

-- | rename programs variables
rnmAllVarsInAProg :: Update (AProg a) VarIndex

-- | update all qualified names in program
updQNamesInAProg :: Update (AProg a) QName

-- | rename program (update name of and all qualified names in program)
rnmAProg :: String -> AProg a -> AProg a

-- | transform function
trAFunc :: (QName -> Int -> Visibility -> TypeExpr -> ARule a -> b) -> AFuncDecl a -> b

-- | get name of function
aFuncName :: AFuncDecl a -> QName

-- | get arity of function
aFuncArity :: AFuncDecl a -> Int

-- | get visibility of function
aFuncVisibility :: AFuncDecl a -> Visibility

-- | get type of function
aFuncType :: AFuncDecl a -> TypeExpr

-- | get rule of function
aFuncARule :: AFuncDecl a -> ARule a

-- | update function
updAFunc :: (QName -> QName) -> (Int -> Int) -> (Visibility -> Visibility) -> (TypeExpr -> TypeExpr) -> (ARule a -> ARule a) -> AFuncDecl a -> AFuncDecl a

-- | update name of function
updAFuncName :: Update (AFuncDecl a) QName

-- | update arity of function
updAFuncArity :: Update (AFuncDecl a) Int

-- | update visibility of function
updAFuncVisibility :: Update (AFuncDecl a) Visibility

-- | update type of function
updFuncType :: Update (AFuncDecl a) TypeExpr

-- | update rule of function
updAFuncARule :: Update (AFuncDecl a) (ARule a)

-- | is function public?
isPublicAFunc :: AFuncDecl a -> Bool

-- | is function externally defined?
isExternal :: AFuncDecl a -> Bool

-- | get variable names in a function declaration
allVarsInAFunc :: AFuncDecl a -> [(VarIndex, a)]

-- | get arguments of function, if not externally defined
aFuncArgs :: AFuncDecl a -> [(VarIndex, a)]

-- | get body of function, if not externally defined
aFuncBody :: AFuncDecl a -> AExpr a

-- | get the right-hand-sides of a <tt>FuncDecl</tt>
aFuncRHS :: AFuncDecl a -> [AExpr a]

-- | rename all variables in function
rnmAllVarsInAFunc :: Update (AFuncDecl a) VarIndex

-- | update all qualified names in function
updQNamesInAFunc :: Update (AFuncDecl a) QName

-- | update arguments of function, if not externally defined
updAFuncArgs :: Update (AFuncDecl a) [(VarIndex, a)]

-- | update body of function, if not externally defined
updAFuncBody :: Update (AFuncDecl a) (AExpr a)

-- | transform rule
trARule :: (a -> [(VarIndex, a)] -> AExpr a -> b) -> (a -> String -> b) -> ARule a -> b

-- | get rules annotation
aRuleAnnot :: ARule a -> a

-- | get rules arguments if it's not external
aRuleArgs :: ARule a -> [(VarIndex, a)]

-- | get rules body if it's not external
aRuleBody :: ARule a -> AExpr a

-- | get rules external declaration
aRuleExtDecl :: ARule a -> String

-- | is rule external?
isARuleExternal :: ARule a -> Bool

-- | update rule
updARule :: (a -> b) -> ([(VarIndex, a)] -> [(VarIndex, b)]) -> (AExpr a -> AExpr b) -> (String -> String) -> ARule a -> ARule b

-- | update rules annotation
updARuleAnnot :: Update (ARule a) a

-- | update rules arguments
updARuleArgs :: Update (ARule a) [(VarIndex, a)]

-- | update rules body
updARuleBody :: Update (ARule a) (AExpr a)

-- | update rules external declaration
updARuleExtDecl :: Update (ARule a) String

-- | get variable names in a functions rule
allVarsInARule :: ARule a -> [(VarIndex, a)]

-- | rename all variables in rule
rnmAllVarsInARule :: Update (ARule a) VarIndex

-- | update all qualified names in rule
updQNamesInARule :: Update (ARule a) QName

-- | get annoation of an expression
annot :: AExpr a -> a

-- | get internal number of variable
varNr :: AExpr a -> VarIndex

-- | get literal if expression is literal expression
literal :: AExpr a -> Literal

-- | get combination type of a combined expression
combType :: AExpr a -> CombType

-- | get name of a combined expression
combName :: AExpr a -> (QName, a)

-- | get arguments of a combined expression
combArgs :: AExpr a -> [AExpr a]

-- | get number of missing arguments if expression is combined
missingCombArgs :: AExpr a -> Int

-- | get indices of varoables in let declaration
letBinds :: AExpr a -> [((VarIndex, a), AExpr a)]

-- | get body of let declaration
letBody :: AExpr a -> AExpr a

-- | get variable indices from declaration of free variables
freeVars :: AExpr a -> [(VarIndex, a)]

-- | get expression from declaration of free variables
freeExpr :: AExpr a -> AExpr a

-- | get expressions from or-expression
orExps :: AExpr a -> [AExpr a]

-- | get case-type of case expression
caseType :: AExpr a -> CaseType

-- | get scrutinee of case expression
caseExpr :: AExpr a -> AExpr a

-- | get branch expressions from case expression
caseBranches :: AExpr a -> [ABranchExpr a]

-- | is expression a variable?
isAVar :: AExpr a -> Bool

-- | is expression a literal expression?
isALit :: AExpr a -> Bool

-- | is expression combined?
isAComb :: AExpr a -> Bool

-- | is expression a let expression?
isALet :: AExpr a -> Bool

-- | is expression a declaration of free variables?
isAFree :: AExpr a -> Bool

-- | is expression an or-expression?
isAOr :: AExpr a -> Bool

-- | is expression a case expression?
isACase :: AExpr a -> Bool

-- | transform expression
trAExpr :: (a -> VarIndex -> b) -> (a -> Literal -> b) -> (a -> CombType -> (QName, a) -> [b] -> b) -> (a -> [((VarIndex, a), b)] -> b -> b) -> (a -> [(VarIndex, a)] -> b -> b) -> (a -> b -> b -> b) -> (a -> CaseType -> b -> [c] -> b) -> (APattern a -> b -> c) -> (a -> b -> TypeExpr -> b) -> AExpr a -> b

-- | update all variables in given expression
updVars :: (a -> VarIndex -> AExpr a) -> AExpr a -> AExpr a

-- | update all literals in given expression
updLiterals :: (a -> Literal -> AExpr a) -> AExpr a -> AExpr a

-- | update all combined expressions in given expression
updCombs :: (a -> CombType -> (QName, a) -> [AExpr a] -> AExpr a) -> AExpr a -> AExpr a

-- | update all let expressions in given expression
updLets :: (a -> [((VarIndex, a), AExpr a)] -> AExpr a -> AExpr a) -> AExpr a -> AExpr a

-- | update all free declarations in given expression
updFrees :: (a -> [(VarIndex, a)] -> AExpr a -> AExpr a) -> AExpr a -> AExpr a

-- | update all or expressions in given expression
updOrs :: (a -> AExpr a -> AExpr a -> AExpr a) -> AExpr a -> AExpr a

-- | update all case expressions in given expression
updCases :: (a -> CaseType -> AExpr a -> [ABranchExpr a] -> AExpr a) -> AExpr a -> AExpr a

-- | update all case branches in given expression
updBranches :: (APattern a -> AExpr a -> ABranchExpr a) -> AExpr a -> AExpr a

-- | update all typed expressions in given expression
updTypeds :: (a -> AExpr a -> TypeExpr -> AExpr a) -> AExpr a -> AExpr a

-- | is expression a call of a function where all arguments are provided?
isFuncCall :: AExpr a -> Bool

-- | is expression a partial function call?
isFuncPartCall :: AExpr a -> Bool

-- | is expression a call of a constructor?
isConsCall :: AExpr a -> Bool

-- | is expression a partial constructor call?
isConsPartCall :: AExpr a -> Bool

-- | is expression fully evaluated?
isGround :: AExpr a -> Bool

-- | get all variables (also pattern variables) in expression
allVars :: AExpr a -> [(VarIndex, a)]

-- | rename all variables (also in patterns) in expression
rnmAllVars :: Update (AExpr a) VarIndex

-- | update all qualified names in expression
updQNames :: Update (AExpr a) QName

-- | transform branch expression
trABranch :: (APattern a -> AExpr a -> b) -> ABranchExpr a -> b

-- | get pattern from branch expression
aBranchAPattern :: ABranchExpr a -> APattern a

-- | get expression from branch expression
aBranchAExpr :: ABranchExpr a -> AExpr a

-- | update branch expression
updABranch :: (APattern a -> APattern a) -> (AExpr a -> AExpr a) -> ABranchExpr a -> ABranchExpr a

-- | update pattern of branch expression
updABranchAPattern :: Update (ABranchExpr a) (APattern a)

-- | update expression of branch expression
updABranchAExpr :: Update (ABranchExpr a) (AExpr a)

-- | transform pattern
trAPattern :: (a -> (QName, a) -> [(VarIndex, a)] -> b) -> (a -> Literal -> b) -> APattern a -> b

-- | get annotation from pattern
aPatAnnot :: APattern a -> a

-- | get name from constructor pattern
aPatCons :: APattern a -> (QName, a)

-- | get arguments from constructor pattern
aPatArgs :: APattern a -> [(VarIndex, a)]

-- | get literal from literal pattern
aPatLiteral :: APattern a -> Literal

-- | is pattern a constructor pattern?
isConsPattern :: APattern a -> Bool

-- | update pattern
updAPattern :: (a -> a) -> ((QName, a) -> (QName, a)) -> ([(VarIndex, a)] -> [(VarIndex, a)]) -> (Literal -> Literal) -> APattern a -> APattern a

-- | update annotation of pattern
updAPatAnnot :: (a -> a) -> APattern a -> APattern a

-- | update constructors name of pattern
updAPatCons :: ((QName, a) -> (QName, a)) -> APattern a -> APattern a

-- | update arguments of constructor pattern
updAPatArgs :: ([(VarIndex, a)] -> [(VarIndex, a)]) -> APattern a -> APattern a

-- | update literal of pattern
updAPatLiteral :: (Literal -> Literal) -> APattern a -> APattern a

-- | build expression from pattern
aPatExpr :: APattern a -> AExpr a

-- | Update of a type's component
type Update a b = (b -> b) -> a -> a

-- | transform type declaration
trType :: (QName -> Visibility -> [TVarWithKind] -> [ConsDecl] -> a) -> (QName -> Visibility -> [TVarWithKind] -> TypeExpr -> a) -> (QName -> Visibility -> [TVarWithKind] -> NewConsDecl -> a) -> TypeDecl -> a

-- | get name of type declaration
typeName :: TypeDecl -> QName

-- | get visibility of type declaration
typeVisibility :: TypeDecl -> Visibility

-- | get type parameters of type declaration
typeParams :: TypeDecl -> [TVarWithKind]

-- | get constructor declarations from type declaration
typeConsDecls :: TypeDecl -> [ConsDecl]

-- | get synonym of type declaration
typeSyn :: TypeDecl -> TypeExpr

-- | is type declaration a type synonym?
isTypeSyn :: TypeDecl -> Bool

-- | is type declaration declaring a regular type?
isDataTypeDecl :: TypeDecl -> Bool

-- | is type declaration declaring an external type?
isExternalType :: TypeDecl -> Bool

-- | Is the <a>TypeDecl</a> public?
isPublicType :: TypeDecl -> Bool

-- | update type declaration
updType :: (QName -> QName) -> (Visibility -> Visibility) -> ([TVarWithKind] -> [TVarWithKind]) -> ([ConsDecl] -> [ConsDecl]) -> (NewConsDecl -> NewConsDecl) -> (TypeExpr -> TypeExpr) -> TypeDecl -> TypeDecl

-- | update name of type declaration
updTypeName :: Update TypeDecl QName

-- | update visibility of type declaration
updTypeVisibility :: Update TypeDecl Visibility

-- | update type parameters of type declaration
updTypeParams :: Update TypeDecl [TVarWithKind]

-- | update constructor declarations of type declaration
updTypeConsDecls :: Update TypeDecl [ConsDecl]

-- | update synonym of type declaration
updTypeSynonym :: Update TypeDecl TypeExpr

-- | update all qualified names in type declaration
updQNamesInType :: Update TypeDecl QName

-- | transform constructor declaration
trCons :: (QName -> Int -> Visibility -> [TypeExpr] -> a) -> ConsDecl -> a

-- | get name of constructor declaration
consName :: ConsDecl -> QName

-- | get arity of constructor declaration
consArity :: ConsDecl -> Int

-- | get visibility of constructor declaration
consVisibility :: ConsDecl -> Visibility

-- | Is the constructor declaration public?
isPublicCons :: ConsDecl -> Bool

-- | get arguments of constructor declaration
consArgs :: ConsDecl -> [TypeExpr]

-- | update constructor declaration
updCons :: (QName -> QName) -> (Int -> Int) -> (Visibility -> Visibility) -> ([TypeExpr] -> [TypeExpr]) -> ConsDecl -> ConsDecl

-- | update name of constructor declaration
updConsName :: Update ConsDecl QName

-- | update arity of constructor declaration
updConsArity :: Update ConsDecl Int

-- | update visibility of constructor declaration
updConsVisibility :: Update ConsDecl Visibility

-- | update arguments of constructor declaration
updConsArgs :: Update ConsDecl [TypeExpr]

-- | update all qualified names in constructor declaration
updQNamesInConsDecl :: Update ConsDecl QName

-- | transform newtype constructor declaration
trNewCons :: (QName -> Visibility -> TypeExpr -> a) -> NewConsDecl -> a

-- | get name of new constructor declaration
newConsName :: NewConsDecl -> QName

-- | get visibility of new constructor declaration
newConsVisibility :: NewConsDecl -> Visibility

-- | Is the new constructor declaration public?
isPublicNewCons :: ConsDecl -> Bool

-- | get argument of new constructor declaration
newConsArg :: NewConsDecl -> TypeExpr

-- | update new constructor declaration
updNewCons :: (QName -> QName) -> (Visibility -> Visibility) -> (TypeExpr -> TypeExpr) -> NewConsDecl -> NewConsDecl

-- | update name of new constructor declaration
updNewConsName :: Update NewConsDecl QName

-- | update visibility of new constructor declaration
updNewConsVisibility :: Update NewConsDecl Visibility

-- | update argument of new constructor declaration
updNewConsArg :: Update NewConsDecl TypeExpr

-- | update all qualified names in new constructor declaration
updQNamesInNewConsDecl :: Update NewConsDecl QName

-- | get index from type variable
tVarIndex :: TypeExpr -> TVarIndex

-- | get domain from functional type
domain :: TypeExpr -> TypeExpr

-- | get range from functional type
range :: TypeExpr -> TypeExpr

-- | get name from constructed type
tConsName :: TypeExpr -> QName

-- | get arguments from constructed type
tConsArgs :: TypeExpr -> [TypeExpr]

-- | transform type expression
trTypeExpr :: (TVarIndex -> a) -> (QName -> [a] -> a) -> (a -> a -> a) -> ([TVarWithKind] -> a -> a) -> TypeExpr -> a

-- | is type expression a type variable?
isTVar :: TypeExpr -> Bool

-- | is type declaration a constructed type?
isTCons :: TypeExpr -> Bool

-- | is type declaration a functional type?
isFuncType :: TypeExpr -> Bool

-- | update all type variables
updTVars :: (TVarIndex -> TypeExpr) -> TypeExpr -> TypeExpr

-- | update all type constructors
updTCons :: (QName -> [TypeExpr] -> TypeExpr) -> TypeExpr -> TypeExpr

-- | update all functional types
updFuncTypes :: (TypeExpr -> TypeExpr -> TypeExpr) -> TypeExpr -> TypeExpr

-- | get argument types from functional type
argTypes :: TypeExpr -> [TypeExpr]

-- | Compute the arity of a <a>TypeExpr</a>
typeArity :: TypeExpr -> Int

-- | get result type from (nested) functional type
resultType :: TypeExpr -> TypeExpr

-- | get indexes of all type variables
allVarsInTypeExpr :: TypeExpr -> [TVarIndex]

-- | yield the list of all contained type constructors
allTypeCons :: TypeExpr -> [QName]

-- | rename variables in type expression
rnmAllVarsInTypeExpr :: (TVarIndex -> TVarIndex) -> TypeExpr -> TypeExpr

-- | update all qualified names in type expression
updQNamesInTypeExpr :: (QName -> QName) -> TypeExpr -> TypeExpr

-- | transform operator declaration
trOp :: (QName -> Fixity -> Integer -> a) -> OpDecl -> a

-- | get name from operator declaration
opName :: OpDecl -> QName

-- | get fixity of operator declaration
opFixity :: OpDecl -> Fixity

-- | get precedence of operator declaration
opPrecedence :: OpDecl -> Integer

-- | update operator declaration
updOp :: (QName -> QName) -> (Fixity -> Fixity) -> (Integer -> Integer) -> OpDecl -> OpDecl

-- | update name of operator declaration
updOpName :: Update OpDecl QName

-- | update fixity of operator declaration
updOpFixity :: Update OpDecl Fixity

-- | update precedence of operator declaration
updOpPrecedence :: Update OpDecl Integer

-- | transform combination type
trCombType :: a -> (Int -> a) -> a -> (Int -> a) -> CombType -> a

-- | is type of combination FuncCall?
isCombTypeFuncCall :: CombType -> Bool

-- | is type of combination FuncPartCall?
isCombTypeFuncPartCall :: CombType -> Bool

-- | is type of combination ConsCall?
isCombTypeConsCall :: CombType -> Bool

-- | is type of combination ConsPartCall?
isCombTypeConsPartCall :: CombType -> Bool

-- | Is this a public <a>Visibility</a>?
isPublic :: Visibility -> Bool


-- | This library contains a version of FlatCurry's abstract syntax tree
--   modified with type information
--   
--   For more information about the abstract syntax tree of
--   <tt>FlatCurry</tt>, see the documentation of the respective module.
module Curry.FlatCurry.Typed.Type
data TPattern
TPattern :: TypeExpr -> QName -> [(VarIndex, TypeExpr)] -> TPattern
TLPattern :: TypeExpr -> Literal -> TPattern
data TBranchExpr
TBranch :: TPattern -> TExpr -> TBranchExpr
data TExpr
TVarE :: TypeExpr -> VarIndex -> TExpr
TLit :: TypeExpr -> Literal -> TExpr
TComb :: TypeExpr -> CombType -> QName -> [TExpr] -> TExpr
TLet :: [((VarIndex, TypeExpr), TExpr)] -> TExpr -> TExpr
TFree :: [(VarIndex, TypeExpr)] -> TExpr -> TExpr
TOr :: TExpr -> TExpr -> TExpr
TCase :: CaseType -> TExpr -> [TBranchExpr] -> TExpr
TTyped :: TExpr -> TypeExpr -> TExpr
data TRule
TRule :: [(VarIndex, TypeExpr)] -> TExpr -> TRule
TExternal :: TypeExpr -> String -> TRule
data TFuncDecl
TFunc :: QName -> Int -> Visibility -> TypeExpr -> TRule -> TFuncDecl
data TProg
TProg :: String -> [String] -> [TypeDecl] -> [TFuncDecl] -> [OpDecl] -> TProg

-- | Classification of case expressions, either flexible or rigid.
data CaseType
Rigid :: CaseType
Flex :: CaseType

-- | Data type for classifying combinations (i.e., a function/constructor
--   applied to some arguments).
data CombType

-- | a call to a function where all arguments are provided
FuncCall :: CombType

-- | a call with a constructor at the top, all arguments are provided
ConsCall :: CombType

-- | a partial call to a function (i.e., not all arguments are provided)
--   where the parameter is the number of missing arguments
FuncPartCall :: Int -> CombType

-- | a partial call to a constructor along with number of missing arguments
ConsPartCall :: Int -> CombType

-- | Data type for representing literals.
--   
--   A literal is either an integer, a float, or a character constant.
--   
--   <i>Note:</i> The constructor definition of <a>Intc</a> differs from
--   the original PAKCS definition. It uses Haskell type <a>Integer</a>
--   instead of <a>Int</a> to provide an unlimited range of integer
--   numbers. Furthermore, float values are represented with Haskell type
--   <a>Double</a> instead of <a>Float</a>.
data Literal
Intc :: Integer -> Literal
Floatc :: Double -> Literal
Charc :: Char -> Literal

-- | Fixity of an operator.
data Fixity

-- | non-associative infix operator
InfixOp :: Fixity

-- | left-associative infix operator
InfixlOp :: Fixity

-- | right-associative infix operator
InfixrOp :: Fixity

-- | Operator declarations.
--   
--   An operator declaration <tt>fix p n</tt> in Curry corresponds to the
--   FlatCurry term <tt>(Op n fix p)</tt>.
--   
--   <i>Note:</i> the constructor definition of <a>Op</a> differs from the
--   original PAKCS definition using Haskell type <a>Integer</a> instead of
--   <a>Int</a> for representing the precedence.
data OpDecl
Op :: QName -> Fixity -> Integer -> OpDecl

-- | Kinds.
--   
--   A kind is either * or k_1 -&gt; k_2 where k_1 and k_2 are kinds.
data Kind

-- | star kind
KStar :: Kind

-- | arrow kind
KArrow :: Kind -> Kind -> Kind

-- | Type expressions.
--   
--   A type expression is either a type variable, a function type, or a
--   type constructor application.
--   
--   <i>Note:</i> the names of the predefined type constructors are
--   <tt>Int</tt>, <tt>Float</tt>, <tt>Bool</tt>, <tt>Char</tt>,
--   <tt>IO</tt>, <tt>Success</tt>, <tt>()</tt> (unit type),
--   <tt>(,...,)</tt> (tuple types), <tt>[]</tt> (list type)
data TypeExpr

-- | type variable
TVar :: TVarIndex -> TypeExpr

-- | function type <tt>t1 -&gt; t2</tt>
FuncType :: TypeExpr -> TypeExpr -> TypeExpr

-- | type constructor application
TCons :: QName -> [TypeExpr] -> TypeExpr

-- | forall type
ForallType :: [TVarWithKind] -> TypeExpr -> TypeExpr

-- | A constructor declaration for a newtype consists of the name of the
--   constructor and the argument type of the constructor.
data NewConsDecl
NewCons :: QName -> Visibility -> TypeExpr -> NewConsDecl

-- | A constructor declaration consists of the name and arity of the
--   constructor and a list of the argument types of the constructor.
data ConsDecl
Cons :: QName -> Int -> Visibility -> [TypeExpr] -> ConsDecl

-- | Type variables are represented by <tt>(TVar i)</tt> where <tt>i</tt>
--   is a type variable index.
type TVarIndex = Int

-- | Declaration of algebraic data type or type synonym.
--   
--   A data type declaration of the form
--   
--   <pre>
--   data t x1...xn = ...| c t1....tkc |...
--   </pre>
--   
--   is represented by the FlatCurry term
--   
--   <pre>
--   Type t [i1,...,in] [...(Cons c kc [t1,...,tkc])...]
--   </pre>
--   
--   where each <tt>ij</tt> is the index of the type variable <tt>xj</tt>
--   
--   <i>Note:</i> The type variable indices are unique inside each type
--   declaration and are usually numbered from 0.
--   
--   Thus, a data type declaration consists of the name of the data type, a
--   list of type parameters and a list of constructor declarations.
data TypeDecl
Type :: QName -> Visibility -> [TVarWithKind] -> [ConsDecl] -> TypeDecl
TypeSyn :: QName -> Visibility -> [TVarWithKind] -> TypeExpr -> TypeDecl
TypeNew :: QName -> Visibility -> [TVarWithKind] -> NewConsDecl -> TypeDecl

-- | Visibility of various entities.
data Visibility

-- | public (exported) entity
Public :: Visibility

-- | private entity
Private :: Visibility

-- | Representation of variables.
type VarIndex = Int

-- | Qualified names.
--   
--   In FlatCurry all names are qualified to avoid name clashes. The first
--   component is the module name and the second component the unqualified
--   name as it occurs in the source program.
type QName = (String, String)
instance GHC.Show.Show Curry.FlatCurry.Typed.Type.TProg
instance GHC.Read.Read Curry.FlatCurry.Typed.Type.TProg
instance GHC.Classes.Eq Curry.FlatCurry.Typed.Type.TProg
instance GHC.Show.Show Curry.FlatCurry.Typed.Type.TFuncDecl
instance GHC.Read.Read Curry.FlatCurry.Typed.Type.TFuncDecl
instance GHC.Classes.Eq Curry.FlatCurry.Typed.Type.TFuncDecl
instance GHC.Show.Show Curry.FlatCurry.Typed.Type.TRule
instance GHC.Read.Read Curry.FlatCurry.Typed.Type.TRule
instance GHC.Classes.Eq Curry.FlatCurry.Typed.Type.TRule
instance GHC.Show.Show Curry.FlatCurry.Typed.Type.TExpr
instance GHC.Read.Read Curry.FlatCurry.Typed.Type.TExpr
instance GHC.Classes.Eq Curry.FlatCurry.Typed.Type.TExpr
instance GHC.Show.Show Curry.FlatCurry.Typed.Type.TBranchExpr
instance GHC.Read.Read Curry.FlatCurry.Typed.Type.TBranchExpr
instance GHC.Classes.Eq Curry.FlatCurry.Typed.Type.TBranchExpr
instance GHC.Show.Show Curry.FlatCurry.Typed.Type.TPattern
instance GHC.Read.Read Curry.FlatCurry.Typed.Type.TPattern
instance GHC.Classes.Eq Curry.FlatCurry.Typed.Type.TPattern
instance Data.Binary.Class.Binary Curry.FlatCurry.Typed.Type.TProg
instance Data.Binary.Class.Binary Curry.FlatCurry.Typed.Type.TFuncDecl
instance Curry.FlatCurry.Typeable.Typeable Curry.FlatCurry.Typed.Type.TRule
instance Data.Binary.Class.Binary Curry.FlatCurry.Typed.Type.TRule
instance Curry.FlatCurry.Typeable.Typeable Curry.FlatCurry.Typed.Type.TExpr
instance Curry.FlatCurry.Typeable.Typeable Curry.FlatCurry.Typed.Type.TBranchExpr
instance Data.Binary.Class.Binary Curry.FlatCurry.Typed.Type.TExpr
instance Data.Binary.Class.Binary Curry.FlatCurry.Typed.Type.TBranchExpr
instance Curry.FlatCurry.Typeable.Typeable Curry.FlatCurry.Typed.Type.TPattern
instance Data.Binary.Class.Binary Curry.FlatCurry.Typed.Type.TPattern


-- | This library provides selector functions, test and update operations
--   as well as some useful auxiliary functions for TypedFlatCurry data
--   terms. Most of the provided functions are based on general
--   transformation functions that replace constructors with user-defined
--   functions. For recursive datatypes the transformations are defined
--   inductively over the term structure. This is quite usual for
--   transformations on TypedFlatCurry terms, so the provided functions can
--   be used to implement specific transformations without having to
--   explicitly state the recursion. Essentially, the tedious part of such
--   transformations - descend in fairly complex term structures - is
--   abstracted away, which hopefully makes the code more clear and brief.
module Curry.FlatCurry.Typed.Goodies

-- | transform program
trTProg :: (String -> [String] -> [TypeDecl] -> [TFuncDecl] -> [OpDecl] -> b) -> TProg -> b

-- | get name from program
tProgName :: TProg -> String

-- | get imports from program
tProgImports :: TProg -> [String]

-- | get type declarations from program
tProgTypes :: TProg -> [TypeDecl]

-- | get functions from program
tProgTFuncs :: TProg -> [TFuncDecl]

-- | get infix operators from program
tProgOps :: TProg -> [OpDecl]

-- | update program
updTProg :: (String -> String) -> ([String] -> [String]) -> ([TypeDecl] -> [TypeDecl]) -> ([TFuncDecl] -> [TFuncDecl]) -> ([OpDecl] -> [OpDecl]) -> TProg -> TProg

-- | update name of program
updTProgName :: Update TProg String

-- | update imports of program
updTProgImports :: Update TProg [String]

-- | update type declarations of program
updTProgTypes :: Update TProg [TypeDecl]

-- | update functions of program
updTProgTFuncs :: Update TProg [TFuncDecl]

-- | update infix operators of program
updTProgOps :: Update TProg [OpDecl]

-- | get all program variables (also from patterns)
allVarsInTProg :: TProg -> [(VarIndex, TypeExpr)]

-- | lift transformation on expressions to program
updTProgTExps :: Update TProg TExpr

-- | rename programs variables
rnmAllVarsInTProg :: Update TProg VarIndex

-- | update all qualified names in program
updQNamesInTProg :: Update TProg QName

-- | rename program (update name of and all qualified names in program)
rnmTProg :: String -> TProg -> TProg

-- | transform function
trTFunc :: (QName -> Int -> Visibility -> TypeExpr -> TRule -> b) -> TFuncDecl -> b

-- | get name of function
tFuncName :: TFuncDecl -> QName

-- | get arity of function
tFuncArity :: TFuncDecl -> Int

-- | get visibility of function
tFuncVisibility :: TFuncDecl -> Visibility

-- | get type of function
tFuncType :: TFuncDecl -> TypeExpr

-- | get rule of function
tFuncTRule :: TFuncDecl -> TRule

-- | update function
updTFunc :: (QName -> QName) -> (Int -> Int) -> (Visibility -> Visibility) -> (TypeExpr -> TypeExpr) -> (TRule -> TRule) -> TFuncDecl -> TFuncDecl

-- | update name of function
updTFuncName :: Update TFuncDecl QName

-- | update arity of function
updTFuncArity :: Update TFuncDecl Int

-- | update visibility of function
updTFuncVisibility :: Update TFuncDecl Visibility

-- | update type of function
updFuncType :: Update TFuncDecl TypeExpr

-- | update rule of function
updTFuncTRule :: Update TFuncDecl TRule

-- | is function public?
isPublicTFunc :: TFuncDecl -> Bool

-- | is function externally defined?
isExternal :: TFuncDecl -> Bool

-- | get variable names in a function declaration
allVarsInTFunc :: TFuncDecl -> [(VarIndex, TypeExpr)]

-- | get arguments of function, if not externally defined
tFuncArgs :: TFuncDecl -> [(VarIndex, TypeExpr)]

-- | get body of function, if not externally defined
tFuncBody :: TFuncDecl -> TExpr

-- | get the right-hand-sides of a <tt>FuncDecl</tt>
tFuncRHS :: TFuncDecl -> [TExpr]

-- | rename all variables in function
rnmAllVarsInTFunc :: Update TFuncDecl VarIndex

-- | update all qualified names in function
updQNamesInTFunc :: Update TFuncDecl QName

-- | update arguments of function, if not externally defined
updTFuncArgs :: Update TFuncDecl [(VarIndex, TypeExpr)]

-- | update body of function, if not externally defined
updTFuncBody :: Update TFuncDecl TExpr

-- | transform rule
trTRule :: ([(VarIndex, TypeExpr)] -> TExpr -> b) -> (TypeExpr -> String -> b) -> TRule -> b

-- | get rules arguments if it's not external
tRuleArgs :: TRule -> [(VarIndex, TypeExpr)]

-- | get rules body if it's not external
tRuleBody :: TRule -> TExpr

-- | get rules external declaration
tRuleExtDecl :: TRule -> String

-- | is rule external?
isTRuleExternal :: TRule -> Bool

-- | update rule
updTRule :: (TypeExpr -> TypeExpr) -> ([(VarIndex, TypeExpr)] -> [(VarIndex, TypeExpr)]) -> (TExpr -> TExpr) -> (String -> String) -> TRule -> TRule

-- | update rules TypeExpr
updTRuleType :: Update TRule TypeExpr

-- | update rules arguments
updTRuleArgs :: Update TRule [(VarIndex, TypeExpr)]

-- | update rules body
updTRuleBody :: Update TRule TExpr

-- | update rules external declaration
updTRuleExtDecl :: Update TRule String

-- | get variable names in a functions rule
allVarsInTRule :: TRule -> [(VarIndex, TypeExpr)]

-- | rename all variables in rule
rnmAllVarsInTRule :: Update TRule VarIndex

-- | update all qualified names in rule
updQNamesInTRule :: Update TRule QName

-- | get internal number of variable
varNr :: TExpr -> VarIndex

-- | get literal if expression is literal expression
literal :: TExpr -> Literal

-- | get combination type of a combined expression
combType :: TExpr -> CombType

-- | get name of a combined expression
combName :: TExpr -> QName

-- | get arguments of a combined expression
combArgs :: TExpr -> [TExpr]

-- | get number of missing arguments if expression is combined
missingCombArgs :: TExpr -> Int

-- | get indices of variables in let declaration
letBinds :: TExpr -> [((VarIndex, TypeExpr), TExpr)]

-- | get body of let declaration
letBody :: TExpr -> TExpr

-- | get variable indices from declaration of free variables
freeVars :: TExpr -> [(VarIndex, TypeExpr)]

-- | get expression from declaration of free variables
freeExpr :: TExpr -> TExpr

-- | get expressions from or-expression
orExps :: TExpr -> [TExpr]

-- | get case-type of case expression
caseType :: TExpr -> CaseType

-- | get scrutinee of case expression
caseExpr :: TExpr -> TExpr

-- | get branch expressions from case expression
caseBranches :: TExpr -> [TBranchExpr]

-- | is expression a variable?
isTVarE :: TExpr -> Bool

-- | is expression a literal expression?
isTLit :: TExpr -> Bool

-- | is expression combined?
isTComb :: TExpr -> Bool

-- | is expression a let expression?
isTLet :: TExpr -> Bool

-- | is expression a declaration of free variables?
isTFree :: TExpr -> Bool

-- | is expression an or-expression?
isTOr :: TExpr -> Bool

-- | is expression a case expression?
isTCase :: TExpr -> Bool

-- | transform expression
trTExpr :: (TypeExpr -> VarIndex -> b) -> (TypeExpr -> Literal -> b) -> (TypeExpr -> CombType -> QName -> [b] -> b) -> ([((VarIndex, TypeExpr), b)] -> b -> b) -> ([(VarIndex, TypeExpr)] -> b -> b) -> (b -> b -> b) -> (CaseType -> b -> [c] -> b) -> (TPattern -> b -> c) -> (b -> TypeExpr -> b) -> TExpr -> b

-- | update all variables in given expression
updVars :: (TypeExpr -> VarIndex -> TExpr) -> TExpr -> TExpr

-- | update all literals in given expression
updLiterals :: (TypeExpr -> Literal -> TExpr) -> TExpr -> TExpr

-- | update all combined expressions in given expression
updCombs :: (TypeExpr -> CombType -> QName -> [TExpr] -> TExpr) -> TExpr -> TExpr

-- | update all let expressions in given expression
updLets :: ([((VarIndex, TypeExpr), TExpr)] -> TExpr -> TExpr) -> TExpr -> TExpr

-- | update all free declarations in given expression
updFrees :: ([(VarIndex, TypeExpr)] -> TExpr -> TExpr) -> TExpr -> TExpr

-- | update all or expressions in given expression
updOrs :: (TExpr -> TExpr -> TExpr) -> TExpr -> TExpr

-- | update all case expressions in given expression
updCases :: (CaseType -> TExpr -> [TBranchExpr] -> TExpr) -> TExpr -> TExpr

-- | update all case branches in given expression
updBranches :: (TPattern -> TExpr -> TBranchExpr) -> TExpr -> TExpr

-- | update all typed expressions in given expression
updTypeds :: (TExpr -> TypeExpr -> TExpr) -> TExpr -> TExpr

-- | is expression a call of a function where all arguments are provided?
isFuncCall :: TExpr -> Bool

-- | is expression a partial function call?
isFuncPartCall :: TExpr -> Bool

-- | is expression a call of a constructor?
isConsCall :: TExpr -> Bool

-- | is expression a partial constructor call?
isConsPartCall :: TExpr -> Bool

-- | is expression fully evaluated?
isGround :: TExpr -> Bool

-- | get all variables (also pattern variables) in expression
allVars :: TExpr -> [(VarIndex, TypeExpr)]

-- | rename all variables (also in patterns) in expression
rnmAllVars :: Update TExpr VarIndex

-- | update all qualified names in expression
updQNames :: Update TExpr QName

-- | transform branch expression
trTBranch :: (TPattern -> TExpr -> b) -> TBranchExpr -> b

-- | get pattern from branch expression
tBranchTPattern :: TBranchExpr -> TPattern

-- | get expression from branch expression
tBranchTExpr :: TBranchExpr -> TExpr

-- | update branch expression
updTBranch :: (TPattern -> TPattern) -> (TExpr -> TExpr) -> TBranchExpr -> TBranchExpr

-- | update pattern of branch expression
updTBranchTPattern :: Update TBranchExpr TPattern

-- | update expression of branch expression
updTBranchTExpr :: Update TBranchExpr TExpr

-- | transform pattern
trTPattern :: (TypeExpr -> QName -> [(VarIndex, TypeExpr)] -> b) -> (TypeExpr -> Literal -> b) -> TPattern -> b

-- | get name from constructor pattern
tPatCons :: TPattern -> QName

-- | get arguments from constructor pattern
tPatArgs :: TPattern -> [(VarIndex, TypeExpr)]

-- | get literal from literal pattern
tPatLiteral :: TPattern -> Literal

-- | is pattern a constructor pattern?
isConsPattern :: TPattern -> Bool

-- | update pattern
updTPattern :: (TypeExpr -> TypeExpr) -> (QName -> QName) -> ([(VarIndex, TypeExpr)] -> [(VarIndex, TypeExpr)]) -> (Literal -> Literal) -> TPattern -> TPattern

-- | update TypeExpr of pattern
updTPatType :: (TypeExpr -> TypeExpr) -> TPattern -> TPattern

-- | update constructors name of pattern
updTPatCons :: (QName -> QName) -> TPattern -> TPattern

-- | update arguments of constructor pattern
updTPatArgs :: ([(VarIndex, TypeExpr)] -> [(VarIndex, TypeExpr)]) -> TPattern -> TPattern

-- | update literal of pattern
updTPatLiteral :: (Literal -> Literal) -> TPattern -> TPattern

-- | build expression from pattern
tPatExpr :: TPattern -> TExpr

-- | Update of a type's component
type Update a b = (b -> b) -> a -> a

-- | transform type declaration
trType :: (QName -> Visibility -> [TVarWithKind] -> [ConsDecl] -> a) -> (QName -> Visibility -> [TVarWithKind] -> TypeExpr -> a) -> (QName -> Visibility -> [TVarWithKind] -> NewConsDecl -> a) -> TypeDecl -> a

-- | get name of type declaration
typeName :: TypeDecl -> QName

-- | get visibility of type declaration
typeVisibility :: TypeDecl -> Visibility

-- | get type parameters of type declaration
typeParams :: TypeDecl -> [TVarWithKind]

-- | get constructor declarations from type declaration
typeConsDecls :: TypeDecl -> [ConsDecl]

-- | get synonym of type declaration
typeSyn :: TypeDecl -> TypeExpr

-- | is type declaration a type synonym?
isTypeSyn :: TypeDecl -> Bool

-- | is type declaration declaring a regular type?
isDataTypeDecl :: TypeDecl -> Bool

-- | is type declaration declaring an external type?
isExternalType :: TypeDecl -> Bool

-- | Is the <a>TypeDecl</a> public?
isPublicType :: TypeDecl -> Bool

-- | update type declaration
updType :: (QName -> QName) -> (Visibility -> Visibility) -> ([TVarWithKind] -> [TVarWithKind]) -> ([ConsDecl] -> [ConsDecl]) -> (NewConsDecl -> NewConsDecl) -> (TypeExpr -> TypeExpr) -> TypeDecl -> TypeDecl

-- | update name of type declaration
updTypeName :: Update TypeDecl QName

-- | update visibility of type declaration
updTypeVisibility :: Update TypeDecl Visibility

-- | update type parameters of type declaration
updTypeParams :: Update TypeDecl [TVarWithKind]

-- | update constructor declarations of type declaration
updTypeConsDecls :: Update TypeDecl [ConsDecl]

-- | update synonym of type declaration
updTypeSynonym :: Update TypeDecl TypeExpr

-- | update all qualified names in type declaration
updQNamesInType :: Update TypeDecl QName

-- | transform constructor declaration
trCons :: (QName -> Int -> Visibility -> [TypeExpr] -> a) -> ConsDecl -> a

-- | get name of constructor declaration
consName :: ConsDecl -> QName

-- | get arity of constructor declaration
consArity :: ConsDecl -> Int

-- | get visibility of constructor declaration
consVisibility :: ConsDecl -> Visibility

-- | Is the constructor declaration public?
isPublicCons :: ConsDecl -> Bool

-- | get arguments of constructor declaration
consArgs :: ConsDecl -> [TypeExpr]

-- | update constructor declaration
updCons :: (QName -> QName) -> (Int -> Int) -> (Visibility -> Visibility) -> ([TypeExpr] -> [TypeExpr]) -> ConsDecl -> ConsDecl

-- | update name of constructor declaration
updConsName :: Update ConsDecl QName

-- | update arity of constructor declaration
updConsArity :: Update ConsDecl Int

-- | update visibility of constructor declaration
updConsVisibility :: Update ConsDecl Visibility

-- | update arguments of constructor declaration
updConsArgs :: Update ConsDecl [TypeExpr]

-- | update all qualified names in constructor declaration
updQNamesInConsDecl :: Update ConsDecl QName

-- | transform newtype constructor declaration
trNewCons :: (QName -> Visibility -> TypeExpr -> a) -> NewConsDecl -> a

-- | get name of new constructor declaration
newConsName :: NewConsDecl -> QName

-- | get visibility of new constructor declaration
newConsVisibility :: NewConsDecl -> Visibility

-- | Is the new constructor declaration public?
isPublicNewCons :: ConsDecl -> Bool

-- | get argument of new constructor declaration
newConsArg :: NewConsDecl -> TypeExpr

-- | update new constructor declaration
updNewCons :: (QName -> QName) -> (Visibility -> Visibility) -> (TypeExpr -> TypeExpr) -> NewConsDecl -> NewConsDecl

-- | update name of new constructor declaration
updNewConsName :: Update NewConsDecl QName

-- | update visibility of new constructor declaration
updNewConsVisibility :: Update NewConsDecl Visibility

-- | update argument of new constructor declaration
updNewConsArg :: Update NewConsDecl TypeExpr

-- | update all qualified names in new constructor declaration
updQNamesInNewConsDecl :: Update NewConsDecl QName

-- | get index from type variable
tVarIndex :: TypeExpr -> TVarIndex

-- | get domain from functional type
domain :: TypeExpr -> TypeExpr

-- | get range from functional type
range :: TypeExpr -> TypeExpr

-- | get name from constructed type
tConsName :: TypeExpr -> QName

-- | get arguments from constructed type
tConsArgs :: TypeExpr -> [TypeExpr]

-- | transform type expression
trTypeExpr :: (TVarIndex -> a) -> (QName -> [a] -> a) -> (a -> a -> a) -> ([TVarWithKind] -> a -> a) -> TypeExpr -> a

-- | is type expression a type variable?
isTVar :: TypeExpr -> Bool

-- | is type declaration a constructed type?
isTCons :: TypeExpr -> Bool

-- | is type declaration a functional type?
isFuncType :: TypeExpr -> Bool

-- | update all type variables
updTVars :: (TVarIndex -> TypeExpr) -> TypeExpr -> TypeExpr

-- | update all type constructors
updTCons :: (QName -> [TypeExpr] -> TypeExpr) -> TypeExpr -> TypeExpr

-- | update all functional types
updFuncTypes :: (TypeExpr -> TypeExpr -> TypeExpr) -> TypeExpr -> TypeExpr

-- | get argument types from functional type
argTypes :: TypeExpr -> [TypeExpr]

-- | Compute the arity of a <a>TypeExpr</a>
typeArity :: TypeExpr -> Int

-- | get result type from (nested) functional type
resultType :: TypeExpr -> TypeExpr

-- | get indexes of all type variables
allVarsInTypeExpr :: TypeExpr -> [TVarIndex]

-- | yield the list of all contained type constructors
allTypeCons :: TypeExpr -> [QName]

-- | rename variables in type expression
rnmAllVarsInTypeExpr :: (TVarIndex -> TVarIndex) -> TypeExpr -> TypeExpr

-- | update all qualified names in type expression
updQNamesInTypeExpr :: (QName -> QName) -> TypeExpr -> TypeExpr

-- | transform operator declaration
trOp :: (QName -> Fixity -> Integer -> a) -> OpDecl -> a

-- | get name from operator declaration
opName :: OpDecl -> QName

-- | get fixity of operator declaration
opFixity :: OpDecl -> Fixity

-- | get precedence of operator declaration
opPrecedence :: OpDecl -> Integer

-- | update operator declaration
updOp :: (QName -> QName) -> (Fixity -> Fixity) -> (Integer -> Integer) -> OpDecl -> OpDecl

-- | update name of operator declaration
updOpName :: Update OpDecl QName

-- | update fixity of operator declaration
updOpFixity :: Update OpDecl Fixity

-- | update precedence of operator declaration
updOpPrecedence :: Update OpDecl Integer

-- | transform combination type
trCombType :: a -> (Int -> a) -> a -> (Int -> a) -> CombType -> a

-- | is type of combination FuncCall?
isCombTypeFuncCall :: CombType -> Bool

-- | is type of combination FuncPartCall?
isCombTypeFuncPartCall :: CombType -> Bool

-- | is type of combination ConsCall?
isCombTypeConsCall :: CombType -> Bool

-- | is type of combination ConsPartCall?
isCombTypeConsPartCall :: CombType -> Bool

-- | Is this a public <a>Visibility</a>?
isPublic :: Visibility -> Bool


-- | This module provides the data structures for Curry language
--   extensions.
module Curry.Syntax.Extension

-- | Specified language extensions, either known or unknown.
data Extension

-- | a known extension
KnownExtension :: SpanInfo -> KnownExtension -> Extension

-- | an unknown extension
UnknownExtension :: SpanInfo -> String -> Extension

-- | Known language extensions of Curry.
data KnownExtension

-- | anonymous free variables
AnonFreeVars :: KnownExtension

-- | C preprocessor
CPP :: KnownExtension

-- | functional patterns
FunctionalPatterns :: KnownExtension

-- | negative literals
NegativeLiterals :: KnownExtension

-- | no implicit import of the prelude
NoImplicitPrelude :: KnownExtension

-- | Classifies a <a>String</a> as an <a>Extension</a>
classifyExtension :: Ident -> Extension

-- | <a>Extension</a>s available by Kiel's Curry compilers.
kielExtensions :: [KnownExtension]

-- | Different Curry tools which may accept compiler options.
data Tool
KICS2 :: Tool
PAKCS :: Tool
CYMAKE :: Tool
FRONTEND :: Tool
UnknownTool :: String -> Tool

-- | Classifies a <a>String</a> as a <a>Tool</a>
classifyTool :: String -> Tool
instance GHC.Show.Show Curry.Syntax.Extension.Tool
instance GHC.Read.Read Curry.Syntax.Extension.Tool
instance GHC.Classes.Eq Curry.Syntax.Extension.Tool
instance GHC.Show.Show Curry.Syntax.Extension.Extension
instance GHC.Read.Read Curry.Syntax.Extension.Extension
instance GHC.Classes.Eq Curry.Syntax.Extension.Extension
instance GHC.Enum.Bounded Curry.Syntax.Extension.KnownExtension
instance GHC.Enum.Enum Curry.Syntax.Extension.KnownExtension
instance GHC.Show.Show Curry.Syntax.Extension.KnownExtension
instance GHC.Read.Read Curry.Syntax.Extension.KnownExtension
instance GHC.Classes.Eq Curry.Syntax.Extension.KnownExtension
instance Data.Binary.Class.Binary Curry.Syntax.Extension.Tool
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Extension.Extension
instance Curry.Base.Position.HasPosition Curry.Syntax.Extension.Extension
instance Data.Binary.Class.Binary Curry.Syntax.Extension.Extension
instance Data.Binary.Class.Binary Curry.Syntax.Extension.KnownExtension


-- | This module defines data structures holding options for the
--   compilation of Curry programs, and utility functions for printing help
--   information as well as parsing the command line arguments.
module CompilerOpts

-- | Compiler options
data Options
Options :: CymakeMode -> Verbosity -> Bool -> [FilePath] -> [FilePath] -> FilePath -> Maybe FilePath -> Bool -> Bool -> PrepOpts -> WarnOpts -> [TargetType] -> [KnownExtension] -> DebugOpts -> CaseMode -> CppOpts -> OptimizationOpts -> Options

-- | modus operandi
[optMode] :: Options -> CymakeMode

-- | verbosity level compilation
[optVerbosity] :: Options -> Verbosity

-- | force (re-)compilation of target
[optForce] :: Options -> Bool

-- | directories to search in for libraries
[optLibraryPaths] :: Options -> [FilePath]

-- | directories to search in for imports
[optImportPaths] :: Options -> [FilePath]

-- | output directory for FlatCurry, ...
[optOutDir] :: Options -> FilePath

-- | output directory for HTML
[optHtmlDir] :: Options -> Maybe FilePath

-- | use subdir for output?
[optUseOutDir] :: Options -> Bool

-- | create a FlatCurry interface file?
[optInterface] :: Options -> Bool

-- | preprocessor options
[optPrepOpts] :: Options -> PrepOpts

-- | warning options
[optWarnOpts] :: Options -> WarnOpts

-- | what to generate
[optTargetTypes] :: Options -> [TargetType]

-- | enabled language extensions
[optExtensions] :: Options -> [KnownExtension]

-- | debug options
[optDebugOpts] :: Options -> DebugOpts

-- | case mode
[optCaseMode] :: Options -> CaseMode

-- | C preprocessor options
[optCppOpts] :: Options -> CppOpts

-- | Optimization options
[optOptimizations] :: Options -> OptimizationOpts

-- | C preprocessor options
data CppOpts
CppOpts :: Bool -> Map String Int -> CppOpts

-- | run C preprocessor
[cppRun] :: CppOpts -> Bool

-- | defintions for the C preprocessor
[cppDefinitions] :: CppOpts -> Map String Int

-- | Preprocessor options
data PrepOpts
PrepOpts :: Bool -> String -> [String] -> PrepOpts

-- | apply custom preprocessor
[ppPreprocess] :: PrepOpts -> Bool

-- | preprocessor command
[ppCmd] :: PrepOpts -> String

-- | preprocessor options
[ppOpts] :: PrepOpts -> [String]

-- | Warning options
data WarnOpts
WarnOpts :: Bool -> [WarnFlag] -> Bool -> WarnOpts

-- | show warnings? (legacy option)
[wnWarn] :: WarnOpts -> Bool

-- | Warnings flags (see below)
[wnWarnFlags] :: WarnOpts -> [WarnFlag]

-- | Should warnings be treated as errors?
[wnWarnAsError] :: WarnOpts -> Bool

-- | Debug options
data DebugOpts
DebugOpts :: [DumpLevel] -> Bool -> Bool -> Bool -> Bool -> DebugOpts

-- | dump levels
[dbDumpLevels] :: DebugOpts -> [DumpLevel]

-- | dump compilation environment
[dbDumpEnv] :: DebugOpts -> Bool

-- | dump data structure
[dbDumpRaw] :: DebugOpts -> Bool

-- | dump all bindings instead of just the local bindings
[dbDumpAllBindings] :: DebugOpts -> Bool

-- | print more readable environments
[dbDumpSimple] :: DebugOpts -> Bool
data OptimizationOpts
OptimizationOpts :: Bool -> Bool -> Bool -> OptimizationOpts

-- | Desugar newtypes
[optDesugarNewtypes] :: OptimizationOpts -> Bool

-- | Inline type class dictionaries
[optInlineDictionaries] :: OptimizationOpts -> Bool

-- | Remove unused imports in IL
[optRemoveUnusedImports] :: OptimizationOpts -> Bool
data CaseMode
CaseModeFree :: CaseMode
CaseModeHaskell :: CaseMode
CaseModeProlog :: CaseMode
CaseModeGoedel :: CaseMode

-- | Modus operandi of the program
data CymakeMode

-- | Show help information and exit
ModeHelp :: CymakeMode

-- | Show version and exit
ModeVersion :: CymakeMode

-- | Show numeric version, suitable for later processing
ModeNumericVersion :: CymakeMode

-- | Compile with dependencies
ModeMake :: CymakeMode

-- | Verbosity level
data Verbosity

-- | be quiet
VerbQuiet :: Verbosity

-- | show status of compilation
VerbStatus :: Verbosity

-- | Type of the target file
data TargetType

-- | Source code tokens
Tokens :: TargetType

-- | Source code comments
Comments :: TargetType

-- | Parsed source code
Parsed :: TargetType

-- | FlatCurry
FlatCurry :: TargetType

-- | Annotated FlatCurry
AnnotatedFlatCurry :: TargetType

-- | Typed FlatCurry
TypedFlatCurry :: TargetType

-- | AbstractCurry
AbstractCurry :: TargetType

-- | Untyped AbstractCurry
UntypedAbstractCurry :: TargetType

-- | HTML documentation
Html :: TargetType

-- | Abstract-Syntax-Tree after checks
AST :: TargetType

-- | Abstract-Syntax-Tree with shortened decls
ShortAST :: TargetType

-- | Warnings flags
data WarnFlag

-- | Warn for multiple imports
WarnMultipleImports :: WarnFlag

-- | Warn for disjoined function rules
WarnDisjoinedRules :: WarnFlag

-- | Warn for unused global bindings
WarnUnusedGlobalBindings :: WarnFlag

-- | Warn for unused local bindings
WarnUnusedBindings :: WarnFlag

-- | Warn for name shadowing
WarnNameShadowing :: WarnFlag

-- | Warn for overlapping rules/alternatives
WarnOverlapping :: WarnFlag

-- | Warn for incomplete pattern matching
WarnIncompletePatterns :: WarnFlag

-- | Warn for missing type signatures
WarnMissingSignatures :: WarnFlag

-- | Warn for missing method implementations
WarnMissingMethods :: WarnFlag

-- | Warn for orphan instances
WarnOrphanInstances :: WarnFlag

-- | Warn for irregular case mode
WarnIrregularCaseMode :: WarnFlag

-- | Warn for redundant context in type signatures
WarnRedundantContext :: WarnFlag

-- | Known language extensions of Curry.
data KnownExtension

-- | anonymous free variables
AnonFreeVars :: KnownExtension

-- | C preprocessor
CPP :: KnownExtension

-- | functional patterns
FunctionalPatterns :: KnownExtension

-- | negative literals
NegativeLiterals :: KnownExtension

-- | no implicit import of the prelude
NoImplicitPrelude :: KnownExtension

-- | Dump level
data DumpLevel

-- | dump source code after conditional compiling
DumpCondCompiled :: DumpLevel

-- | dump source code after parsing
DumpParsed :: DumpLevel

-- | dump source code after extension checking
DumpExtensionChecked :: DumpLevel

-- | dump source code after type syntax checking
DumpTypeSyntaxChecked :: DumpLevel

-- | dump source code after kind checking
DumpKindChecked :: DumpLevel

-- | dump source code after syntax checking
DumpSyntaxChecked :: DumpLevel

-- | dump source code after precedence checking
DumpPrecChecked :: DumpLevel

-- | dump source code after derive checking
DumpDeriveChecked :: DumpLevel

-- | dump source code after instance checking
DumpInstanceChecked :: DumpLevel

-- | dump source code after type checking
DumpTypeChecked :: DumpLevel

-- | dump source code after export checking
DumpExportChecked :: DumpLevel

-- | dump source code after qualification
DumpQualified :: DumpLevel

-- | dump source code after deriving
DumpDerived :: DumpLevel

-- | dump source code after desugaring
DumpDesugared :: DumpLevel

-- | dump source code after dictionary transformation
DumpDictionaries :: DumpLevel

-- | dump source code after removing newtype constructors
DumpNewtypes :: DumpLevel

-- | dump source code after simplification
DumpSimplified :: DumpLevel

-- | dump source code after lambda-lifting
DumpLifted :: DumpLevel

-- | dump IL code after translation
DumpTranslated :: DumpLevel

-- | dump IL code after case completion
DumpCaseCompleted :: DumpLevel

-- | dump typed FlatCurry code
DumpTypedFlatCurry :: DumpLevel

-- | dump FlatCurry code
DumpFlatCurry :: DumpLevel

-- | Description and flag of dump levels
dumpLevel :: [(DumpLevel, String, String)]

-- | Default compiler options
defaultOptions :: Options

-- | Default preprocessor options
defaultPrepOpts :: PrepOpts

-- | Default warning options
defaultWarnOpts :: WarnOpts

-- | Default dump options
defaultDebugOpts :: DebugOpts

-- | Retrieve the compiler <a>Options</a>
getCompilerOpts :: IO (String, Options, [String], [String])

-- | Update the <a>Options</a> record by the parsed and processed arguments
updateOpts :: Options -> [String] -> (Options, [String], [String])

-- | Print the usage information of the command line tool.
usage :: String -> String
instance GHC.Show.Show CompilerOpts.Options
instance GHC.Show.Show CompilerOpts.DebugOpts
instance GHC.Show.Show CompilerOpts.DumpLevel
instance GHC.Enum.Enum CompilerOpts.DumpLevel
instance GHC.Enum.Bounded CompilerOpts.DumpLevel
instance GHC.Classes.Eq CompilerOpts.DumpLevel
instance GHC.Show.Show CompilerOpts.WarnOpts
instance GHC.Show.Show CompilerOpts.WarnFlag
instance GHC.Enum.Enum CompilerOpts.WarnFlag
instance GHC.Enum.Bounded CompilerOpts.WarnFlag
instance GHC.Classes.Eq CompilerOpts.WarnFlag
instance GHC.Show.Show CompilerOpts.TargetType
instance GHC.Classes.Eq CompilerOpts.TargetType
instance GHC.Show.Show CompilerOpts.Verbosity
instance GHC.Classes.Ord CompilerOpts.Verbosity
instance GHC.Classes.Eq CompilerOpts.Verbosity
instance GHC.Show.Show CompilerOpts.CymakeMode
instance GHC.Classes.Eq CompilerOpts.CymakeMode
instance GHC.Show.Show CompilerOpts.OptimizationOpts
instance GHC.Show.Show CompilerOpts.CaseMode
instance GHC.Classes.Eq CompilerOpts.CaseMode
instance GHC.Show.Show CompilerOpts.PrepOpts
instance GHC.Show.Show CompilerOpts.CppOpts


-- | TODO
module CondCompile
condCompile :: CppOpts -> FilePath -> String -> CYIO String


-- | This module defines several operations to construct and emit compiler
--   messages to the user.
module Base.Messages

-- | Monads in which <a>IO</a> computations may be embedded. Any monad
--   built by applying a sequence of monad transformers to the <a>IO</a>
--   monad will be an instance of this class.
--   
--   Instances should satisfy the following laws, which state that
--   <a>liftIO</a> is a transformer of monads:
--   
--   <ul>
--   <li><pre><a>liftIO</a> . <a>return</a> = <a>return</a></pre></li>
--   <li><pre><a>liftIO</a> (m &gt;&gt;= f) = <a>liftIO</a> m &gt;&gt;=
--   (<a>liftIO</a> . f)</pre></li>
--   </ul>
class Monad m => MonadIO (m :: Type -> Type)

-- | Lift a computation from the <a>IO</a> monad.
liftIO :: MonadIO m => IO a -> m a

-- | Print a status message, depending on the current verbosity
status :: MonadIO m => Options -> String -> m ()

-- | Print a message on <a>stdout</a>
putMsg :: MonadIO m => String -> m ()

-- | Print an error message on <a>stderr</a>
putErrLn :: MonadIO m => String -> m ()

-- | Print a list of error messages on <a>stderr</a>
putErrsLn :: MonadIO m => [String] -> m ()

-- | Print a list of <a>String</a>s as error messages on <a>stderr</a> and
--   abort the program
abortWith :: [String] -> IO a

-- | Print a single error message on <a>stderr</a> and abort the program
abortWithMessage :: Message -> IO a

-- | Print a list of error messages on <a>stderr</a> and abort the program
abortWithMessages :: [Message] -> IO a

-- | Print a list of warning messages on <a>stderr</a> and abort the
--   program |if the -Werror option is set
warnOrAbort :: WarnOpts -> [Message] -> IO ()

-- | Raise an internal error
internalError :: String -> a

-- | Compiler message
data Message

-- | Construct a <a>Message</a> without a <a>SpanInfo</a>
message :: Doc -> Message

-- | Construct a message from a position.
posMessage :: HasPosition p => p -> Doc -> Message

-- | Construct a message from an entity with a <a>SpanInfo</a> and a text
spanInfoMessage :: HasSpanInfo s => s -> Doc -> Message


-- | The module <a>TopEnv</a> implements environments for qualified and
--   possibly ambiguous identifiers. An identifier is ambiguous if two
--   different entities are imported under the same name or if a local
--   definition uses the same name as an imported entity. Following an idea
--   presented in a paper by Diatchki, Jones and Hallgren (2002), an
--   identifier is associated with a list of entities in order to handle
--   ambiguous names properly.
--   
--   In general, two entities are considered equal if the names of their
--   original definitions match. However, in the case of algebraic data
--   types it is possible to hide some or all of their data constructors on
--   import and export, respectively. In this case we have to merge both
--   imports such that all data constructors which are visible through any
--   import path are visible in the current module. The class Entity is
--   used to handle this merge.
--   
--   The code in this module ensures that the list of entities returned by
--   the functions <a>lookupTopEnv</a> and <a>qualLookupTopEnv</a> contains
--   exactly one element for each imported entity regardless of how many
--   times and from which module(s) it was imported. Thus, the result of
--   these function is a list with exactly one element if and only if the
--   identifier is unambiguous. The module names associated with an
--   imported entity identify the modules from which the entity was
--   imported.
module Base.TopEnv

-- | Top level environment
newtype TopEnv a
TopEnv :: Map QualIdent [(Source, a)] -> TopEnv a
[topEnvMap] :: TopEnv a -> Map QualIdent [(Source, a)]
class Entity a
origName :: Entity a => a -> QualIdent
merge :: Entity a => a -> a -> Maybe a

-- | Empty <a>TopEnv</a>
emptyTopEnv :: TopEnv a

-- | Insert an <a>Entity</a> into a <a>TopEnv</a> as a predefined
--   <a>Entity</a>
predefTopEnv :: QualIdent -> a -> TopEnv a -> TopEnv a

-- | Insert an <a>Entity</a> as unqualified into a <a>TopEnv</a>
importTopEnv :: Entity a => ModuleIdent -> Ident -> a -> TopEnv a -> TopEnv a

-- | Insert an <a>Entity</a> as qualified into a <a>TopEnv</a>
qualImportTopEnv :: Entity a => ModuleIdent -> Ident -> a -> TopEnv a -> TopEnv a
bindTopEnv :: Ident -> a -> TopEnv a -> TopEnv a
qualBindTopEnv :: QualIdent -> a -> TopEnv a -> TopEnv a
rebindTopEnv :: Ident -> a -> TopEnv a -> TopEnv a
qualRebindTopEnv :: QualIdent -> a -> TopEnv a -> TopEnv a
unbindTopEnv :: Ident -> TopEnv a -> TopEnv a
qualUnbindTopEnv :: QualIdent -> TopEnv a -> TopEnv a
lookupTopEnv :: Ident -> TopEnv a -> [a]
qualLookupTopEnv :: QualIdent -> TopEnv a -> [a]
qualElemTopEnv :: QualIdent -> TopEnv a -> Bool
allImports :: TopEnv a -> [(QualIdent, a)]
moduleImports :: ModuleIdent -> TopEnv a -> [(Ident, a)]
localBindings :: TopEnv a -> [(Ident, a)]
allLocalBindings :: TopEnv a -> [(QualIdent, a)]
allBindings :: TopEnv a -> [(QualIdent, a)]
allEntities :: TopEnv a -> [a]
instance GHC.Show.Show a => GHC.Show.Show (Base.TopEnv.TopEnv a)
instance GHC.Show.Show Base.TopEnv.Source
instance GHC.Classes.Eq Base.TopEnv.Source
instance GHC.Base.Functor Base.TopEnv.TopEnv


-- | The <a>NestEnv</a> environment type extends top-level environments to
--   manage nested scopes. Local scopes allow only for a single,
--   unambiguous definition.
--   
--   As a matter of convenience, the module <a>TopEnv</a> is exported by
--   the module <a>NestEnv</a>. Thus, only the latter needs to be imported.
module Base.NestEnv
data NestEnv a
emptyEnv :: NestEnv a
bindNestEnv :: Ident -> a -> NestEnv a -> NestEnv a
qualBindNestEnv :: QualIdent -> a -> NestEnv a -> NestEnv a
lookupNestEnv :: Ident -> NestEnv a -> [a]
qualLookupNestEnv :: QualIdent -> NestEnv a -> [a]
rebindNestEnv :: Ident -> a -> NestEnv a -> NestEnv a
qualRebindNestEnv :: QualIdent -> a -> NestEnv a -> NestEnv a
unnestEnv :: NestEnv a -> NestEnv a
toplevelEnv :: NestEnv a -> TopEnv a
globalEnv :: TopEnv a -> NestEnv a
nestEnv :: NestEnv a -> NestEnv a
elemNestEnv :: Ident -> NestEnv a -> Bool
qualModifyNestEnv :: (a -> a) -> QualIdent -> NestEnv a -> NestEnv a
modifyNestEnv :: (a -> a) -> Ident -> NestEnv a -> NestEnv a
localNestEnv :: NestEnv a -> [(Ident, a)]
qualInLocalNestEnv :: QualIdent -> NestEnv a -> Bool
instance GHC.Show.Show a => GHC.Show.Show (Base.NestEnv.NestEnv a)
instance GHC.Base.Functor Base.NestEnv.NestEnv


module Curry.Syntax.Lexer

-- | Data type for curry lexer tokens
data Token
Token :: Category -> Attributes -> Token

-- | Category of curry tokens
data Category
CharTok :: Category
IntTok :: Category
FloatTok :: Category
StringTok :: Category
Id :: Category
QId :: Category
Sym :: Category
QSym :: Category
LeftParen :: Category
RightParen :: Category
Semicolon :: Category
LeftBrace :: Category
RightBrace :: Category
LeftBracket :: Category
RightBracket :: Category
Comma :: Category
Underscore :: Category
Backquote :: Category
VSemicolon :: Category
VRightBrace :: Category
KW_case :: Category
KW_class :: Category
KW_data :: Category
KW_default :: Category
KW_deriving :: Category
KW_do :: Category
KW_else :: Category
KW_external :: Category
KW_fcase :: Category
KW_free :: Category
KW_if :: Category
KW_import :: Category
KW_in :: Category
KW_infix :: Category
KW_infixl :: Category
KW_infixr :: Category
KW_instance :: Category
KW_let :: Category
KW_module :: Category
KW_newtype :: Category
KW_of :: Category
KW_then :: Category
KW_type :: Category
KW_where :: Category
At :: Category
Colon :: Category
DotDot :: Category
DoubleColon :: Category
Equals :: Category
Backslash :: Category
Bar :: Category

LeftArrow :: Category
RightArrow :: Category
Tilde :: Category
DoubleArrow :: Category
Id_as :: Category
Id_ccall :: Category
Id_forall :: Category
Id_hiding :: Category
Id_interface :: Category
Id_primitive :: Category
Id_qualified :: Category
SymDot :: Category
SymMinus :: Category
SymStar :: Category
PragmaLanguage :: Category
PragmaOptions :: Category
PragmaHiding :: Category
PragmaMethod :: Category
PragmaModule :: Category
PragmaEnd :: Category
LineComment :: Category
NestedComment :: Category
EOF :: Category

-- | Attributes associated to a token
data Attributes
NoAttributes :: Attributes
CharAttributes :: Char -> String -> Attributes
[cval] :: Attributes -> Char
[original] :: Attributes -> String
IntAttributes :: Integer -> String -> Attributes
[ival] :: Attributes -> Integer
[original] :: Attributes -> String
FloatAttributes :: Double -> String -> Attributes
[fval] :: Attributes -> Double
[original] :: Attributes -> String
StringAttributes :: String -> String -> Attributes
[sval] :: Attributes -> String
[original] :: Attributes -> String
IdentAttributes :: [String] -> String -> Attributes
[modulVal] :: Attributes -> [String]
[sval] :: Attributes -> String
OptionsAttributes :: Maybe String -> String -> Attributes
[toolVal] :: Attributes -> Maybe String
[toolArgs] :: Attributes -> String

-- | Lex source code
lexSource :: FilePath -> String -> CYM [(Span, Token)]

-- | CPS-Lexer for Curry
lexer :: Lexer Token a

-- | CPS-Lexer for Curry which also lexes comments. This lexer is useful
--   for documentation tools.
fullLexer :: Lexer Token a
instance GHC.Classes.Ord Curry.Syntax.Lexer.Category
instance GHC.Classes.Eq Curry.Syntax.Lexer.Category
instance GHC.Classes.Eq Curry.Syntax.Lexer.Token
instance GHC.Classes.Ord Curry.Syntax.Lexer.Token
instance Curry.Base.LexComb.Symbol Curry.Syntax.Lexer.Token
instance GHC.Show.Show Curry.Syntax.Lexer.Token
instance GHC.Show.Show Curry.Syntax.Lexer.Attributes


-- | This module provides the necessary data structures to maintain the
--   parsed representation of a Curry program.
module Curry.Syntax.Type

-- | Curry module
data Module a
Module :: SpanInfo -> LayoutInfo -> [ModulePragma] -> ModuleIdent -> Maybe ExportSpec -> [ImportDecl] -> [Decl a] -> Module a

-- | Module pragma
data ModulePragma

-- | language pragma
LanguagePragma :: SpanInfo -> [Extension] -> ModulePragma

-- | options pragma
OptionsPragma :: SpanInfo -> Maybe Tool -> String -> ModulePragma

-- | Specified language extensions, either known or unknown.
data Extension

-- | a known extension
KnownExtension :: SpanInfo -> KnownExtension -> Extension

-- | an unknown extension
UnknownExtension :: SpanInfo -> String -> Extension

-- | Known language extensions of Curry.
data KnownExtension

-- | anonymous free variables
AnonFreeVars :: KnownExtension

-- | C preprocessor
CPP :: KnownExtension

-- | functional patterns
FunctionalPatterns :: KnownExtension

-- | negative literals
NegativeLiterals :: KnownExtension

-- | no implicit import of the prelude
NoImplicitPrelude :: KnownExtension

-- | Different Curry tools which may accept compiler options.
data Tool
KICS2 :: Tool
PAKCS :: Tool
CYMAKE :: Tool
FRONTEND :: Tool
UnknownTool :: String -> Tool

-- | Export specification
data ExportSpec
Exporting :: SpanInfo -> [Export] -> ExportSpec

-- | Single exported entity
data Export
Export :: SpanInfo -> QualIdent -> Export
ExportTypeWith :: SpanInfo -> QualIdent -> [Ident] -> Export
ExportTypeAll :: SpanInfo -> QualIdent -> Export
ExportModule :: SpanInfo -> ModuleIdent -> Export

-- | Import declaration
data ImportDecl
ImportDecl :: SpanInfo -> ModuleIdent -> Qualified -> Maybe ModuleIdent -> Maybe ImportSpec -> ImportDecl

-- | Import specification
data ImportSpec
Importing :: SpanInfo -> [Import] -> ImportSpec
Hiding :: SpanInfo -> [Import] -> ImportSpec

-- | Single imported entity
data Import
Import :: SpanInfo -> Ident -> Import
ImportTypeWith :: SpanInfo -> Ident -> [Ident] -> Import
ImportTypeAll :: SpanInfo -> Ident -> Import

-- | Flag to signal qualified import
type Qualified = Bool

-- | Module interface
--   
--   Interface declarations are restricted to type declarations and
--   signatures. Note that an interface function declaration additionaly
--   contains the function arity (= number of parameters) in order to
--   generate correct FlatCurry function applications.
data Interface
Interface :: ModuleIdent -> [IImportDecl] -> [IDecl] -> Interface

-- | Interface import declaration
data IImportDecl
IImportDecl :: Position -> ModuleIdent -> IImportDecl

-- | Arity of a function
type Arity = Int

-- | Interface declaration
data IDecl
IInfixDecl :: Position -> Infix -> Precedence -> QualIdent -> IDecl
HidingDataDecl :: Position -> QualIdent -> Maybe KindExpr -> [Ident] -> IDecl
IDataDecl :: Position -> QualIdent -> Maybe KindExpr -> [Ident] -> [ConstrDecl] -> [Ident] -> IDecl
INewtypeDecl :: Position -> QualIdent -> Maybe KindExpr -> [Ident] -> NewConstrDecl -> [Ident] -> IDecl
ITypeDecl :: Position -> QualIdent -> Maybe KindExpr -> [Ident] -> TypeExpr -> IDecl
IFunctionDecl :: Position -> QualIdent -> Maybe Ident -> Arity -> QualTypeExpr -> IDecl
HidingClassDecl :: Position -> Context -> QualIdent -> Maybe KindExpr -> Ident -> IDecl
IClassDecl :: Position -> Context -> QualIdent -> Maybe KindExpr -> Ident -> [IMethodDecl] -> [Ident] -> IDecl
IInstanceDecl :: Position -> Context -> QualIdent -> InstanceType -> [IMethodImpl] -> Maybe ModuleIdent -> IDecl

-- | Kind expressions
data KindExpr
Star :: KindExpr
ArrowKind :: KindExpr -> KindExpr -> KindExpr

-- | Class methods
data IMethodDecl
IMethodDecl :: Position -> Ident -> Maybe Arity -> QualTypeExpr -> IMethodDecl

-- | Class method implementations
type IMethodImpl = (Ident, Arity)

-- | Declaration in a module
data Decl a
InfixDecl :: SpanInfo -> Infix -> Maybe Precedence -> [Ident] -> Decl a
DataDecl :: SpanInfo -> Ident -> [Ident] -> [ConstrDecl] -> [QualIdent] -> Decl a
ExternalDataDecl :: SpanInfo -> Ident -> [Ident] -> Decl a
NewtypeDecl :: SpanInfo -> Ident -> [Ident] -> NewConstrDecl -> [QualIdent] -> Decl a
TypeDecl :: SpanInfo -> Ident -> [Ident] -> TypeExpr -> Decl a
TypeSig :: SpanInfo -> [Ident] -> QualTypeExpr -> Decl a
FunctionDecl :: SpanInfo -> a -> Ident -> [Equation a] -> Decl a
ExternalDecl :: SpanInfo -> [Var a] -> Decl a
PatternDecl :: SpanInfo -> Pattern a -> Rhs a -> Decl a
FreeDecl :: SpanInfo -> [Var a] -> Decl a
DefaultDecl :: SpanInfo -> [TypeExpr] -> Decl a
ClassDecl :: SpanInfo -> LayoutInfo -> Context -> Ident -> Ident -> [Decl a] -> Decl a
InstanceDecl :: SpanInfo -> LayoutInfo -> Context -> QualIdent -> InstanceType -> [Decl a] -> Decl a

-- | Operator precedence
type Precedence = Integer

-- | Fixity of operators
data Infix

-- | left-associative
InfixL :: Infix

-- | right-associative
InfixR :: Infix

-- | no associativity
Infix :: Infix

-- | Constructor declaration for algebraic data types
data ConstrDecl
ConstrDecl :: SpanInfo -> Ident -> [TypeExpr] -> ConstrDecl
ConOpDecl :: SpanInfo -> TypeExpr -> Ident -> TypeExpr -> ConstrDecl
RecordDecl :: SpanInfo -> Ident -> [FieldDecl] -> ConstrDecl

-- | Constructor declaration for renaming types (newtypes)
data NewConstrDecl
NewConstrDecl :: SpanInfo -> Ident -> TypeExpr -> NewConstrDecl
NewRecordDecl :: SpanInfo -> Ident -> (Ident, TypeExpr) -> NewConstrDecl

-- | Declaration for labelled fields
data FieldDecl
FieldDecl :: SpanInfo -> [Ident] -> TypeExpr -> FieldDecl

-- | Type expressions
data TypeExpr
ConstructorType :: SpanInfo -> QualIdent -> TypeExpr
ApplyType :: SpanInfo -> TypeExpr -> TypeExpr -> TypeExpr
VariableType :: SpanInfo -> Ident -> TypeExpr
TupleType :: SpanInfo -> [TypeExpr] -> TypeExpr
ListType :: SpanInfo -> TypeExpr -> TypeExpr
ArrowType :: SpanInfo -> TypeExpr -> TypeExpr -> TypeExpr
ParenType :: SpanInfo -> TypeExpr -> TypeExpr
ForallType :: SpanInfo -> [Ident] -> TypeExpr -> TypeExpr

-- | Qualified type expressions
data QualTypeExpr
QualTypeExpr :: SpanInfo -> Context -> TypeExpr -> QualTypeExpr

-- | Function defining equation
data Equation a
Equation :: SpanInfo -> Lhs a -> Rhs a -> Equation a

-- | Left-hand-side of an <a>Equation</a> (function identifier and
--   patterns)
data Lhs a
FunLhs :: SpanInfo -> Ident -> [Pattern a] -> Lhs a
OpLhs :: SpanInfo -> Pattern a -> Ident -> Pattern a -> Lhs a
ApLhs :: SpanInfo -> Lhs a -> [Pattern a] -> Lhs a

-- | Right-hand-side of an <a>Equation</a>
data Rhs a
SimpleRhs :: SpanInfo -> LayoutInfo -> Expression a -> [Decl a] -> Rhs a
GuardedRhs :: SpanInfo -> LayoutInfo -> [CondExpr a] -> [Decl a] -> Rhs a

-- | Conditional expression (expression conditioned by a guard)
data CondExpr a
CondExpr :: SpanInfo -> Expression a -> Expression a -> CondExpr a

-- | Literal
data Literal
Char :: Char -> Literal
Int :: Integer -> Literal
Float :: Double -> Literal
String :: String -> Literal

-- | Constructor term (used for patterns)
data Pattern a
LiteralPattern :: SpanInfo -> a -> Literal -> Pattern a
NegativePattern :: SpanInfo -> a -> Literal -> Pattern a
VariablePattern :: SpanInfo -> a -> Ident -> Pattern a
ConstructorPattern :: SpanInfo -> a -> QualIdent -> [Pattern a] -> Pattern a
InfixPattern :: SpanInfo -> a -> Pattern a -> QualIdent -> Pattern a -> Pattern a
ParenPattern :: SpanInfo -> Pattern a -> Pattern a
RecordPattern :: SpanInfo -> a -> QualIdent -> [Field (Pattern a)] -> Pattern a
TuplePattern :: SpanInfo -> [Pattern a] -> Pattern a
ListPattern :: SpanInfo -> a -> [Pattern a] -> Pattern a
AsPattern :: SpanInfo -> Ident -> Pattern a -> Pattern a
LazyPattern :: SpanInfo -> Pattern a -> Pattern a
FunctionPattern :: SpanInfo -> a -> QualIdent -> [Pattern a] -> Pattern a
InfixFuncPattern :: SpanInfo -> a -> Pattern a -> QualIdent -> Pattern a -> Pattern a

-- | Expression
data Expression a
Literal :: SpanInfo -> a -> Literal -> Expression a
Variable :: SpanInfo -> a -> QualIdent -> Expression a
Constructor :: SpanInfo -> a -> QualIdent -> Expression a
Paren :: SpanInfo -> Expression a -> Expression a
Typed :: SpanInfo -> Expression a -> QualTypeExpr -> Expression a
Record :: SpanInfo -> a -> QualIdent -> [Field (Expression a)] -> Expression a
RecordUpdate :: SpanInfo -> Expression a -> [Field (Expression a)] -> Expression a
Tuple :: SpanInfo -> [Expression a] -> Expression a
List :: SpanInfo -> a -> [Expression a] -> Expression a
ListCompr :: SpanInfo -> Expression a -> [Statement a] -> Expression a
EnumFrom :: SpanInfo -> Expression a -> Expression a
EnumFromThen :: SpanInfo -> Expression a -> Expression a -> Expression a
EnumFromTo :: SpanInfo -> Expression a -> Expression a -> Expression a
EnumFromThenTo :: SpanInfo -> Expression a -> Expression a -> Expression a -> Expression a
UnaryMinus :: SpanInfo -> Expression a -> Expression a
Apply :: SpanInfo -> Expression a -> Expression a -> Expression a
InfixApply :: SpanInfo -> Expression a -> InfixOp a -> Expression a -> Expression a
LeftSection :: SpanInfo -> Expression a -> InfixOp a -> Expression a
RightSection :: SpanInfo -> InfixOp a -> Expression a -> Expression a
Lambda :: SpanInfo -> [Pattern a] -> Expression a -> Expression a
Let :: SpanInfo -> LayoutInfo -> [Decl a] -> Expression a -> Expression a
Do :: SpanInfo -> LayoutInfo -> [Statement a] -> Expression a -> Expression a
IfThenElse :: SpanInfo -> Expression a -> Expression a -> Expression a -> Expression a
Case :: SpanInfo -> LayoutInfo -> CaseType -> Expression a -> [Alt a] -> Expression a

-- | Infix operation
data InfixOp a
InfixOp :: a -> QualIdent -> InfixOp a
InfixConstr :: a -> QualIdent -> InfixOp a

-- | Statement (used for do-sequence and list comprehensions)
data Statement a
StmtExpr :: SpanInfo -> Expression a -> Statement a
StmtDecl :: SpanInfo -> LayoutInfo -> [Decl a] -> Statement a
StmtBind :: SpanInfo -> Pattern a -> Expression a -> Statement a

-- | Type of case expressions
data CaseType
Rigid :: CaseType
Flex :: CaseType

-- | Single case alternative
data Alt a
Alt :: SpanInfo -> Pattern a -> Rhs a -> Alt a

-- | Record field
data Field a
Field :: SpanInfo -> QualIdent -> a -> Field a

-- | Annotated identifier
data Var a
Var :: a -> Ident -> Var a
type Context = [Constraint]
data Constraint
Constraint :: SpanInfo -> QualIdent -> TypeExpr -> Constraint
type InstanceType = TypeExpr

-- | Goal in REPL (expression to evaluate)
data Goal a
Goal :: SpanInfo -> LayoutInfo -> Expression a -> [Decl a] -> Goal a
instance GHC.Show.Show a => GHC.Show.Show (Curry.Syntax.Type.Goal a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.Syntax.Type.Goal a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.Syntax.Type.Goal a)
instance GHC.Show.Show a => GHC.Show.Show (Curry.Syntax.Type.Module a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.Syntax.Type.Module a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.Syntax.Type.Module a)
instance GHC.Show.Show a => GHC.Show.Show (Curry.Syntax.Type.Equation a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.Syntax.Type.Equation a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.Syntax.Type.Equation a)
instance GHC.Show.Show a => GHC.Show.Show (Curry.Syntax.Type.CondExpr a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.Syntax.Type.CondExpr a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.Syntax.Type.CondExpr a)
instance GHC.Show.Show a => GHC.Show.Show (Curry.Syntax.Type.Statement a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.Syntax.Type.Statement a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.Syntax.Type.Statement a)
instance GHC.Show.Show a => GHC.Show.Show (Curry.Syntax.Type.Alt a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.Syntax.Type.Alt a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.Syntax.Type.Alt a)
instance GHC.Show.Show a => GHC.Show.Show (Curry.Syntax.Type.Expression a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.Syntax.Type.Expression a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.Syntax.Type.Expression a)
instance GHC.Show.Show a => GHC.Show.Show (Curry.Syntax.Type.Rhs a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.Syntax.Type.Rhs a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.Syntax.Type.Rhs a)
instance GHC.Show.Show a => GHC.Show.Show (Curry.Syntax.Type.Decl a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.Syntax.Type.Decl a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.Syntax.Type.Decl a)
instance GHC.Show.Show a => GHC.Show.Show (Curry.Syntax.Type.Var a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.Syntax.Type.Var a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.Syntax.Type.Var a)
instance GHC.Show.Show a => GHC.Show.Show (Curry.Syntax.Type.Lhs a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.Syntax.Type.Lhs a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.Syntax.Type.Lhs a)
instance GHC.Show.Show a => GHC.Show.Show (Curry.Syntax.Type.Pattern a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.Syntax.Type.Pattern a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.Syntax.Type.Pattern a)
instance GHC.Show.Show a => GHC.Show.Show (Curry.Syntax.Type.Field a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.Syntax.Type.Field a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.Syntax.Type.Field a)
instance GHC.Show.Show Curry.Syntax.Type.CaseType
instance GHC.Read.Read Curry.Syntax.Type.CaseType
instance GHC.Classes.Eq Curry.Syntax.Type.CaseType
instance GHC.Show.Show a => GHC.Show.Show (Curry.Syntax.Type.InfixOp a)
instance GHC.Read.Read a => GHC.Read.Read (Curry.Syntax.Type.InfixOp a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Curry.Syntax.Type.InfixOp a)
instance GHC.Show.Show Curry.Syntax.Type.Literal
instance GHC.Read.Read Curry.Syntax.Type.Literal
instance GHC.Classes.Eq Curry.Syntax.Type.Literal
instance GHC.Show.Show Curry.Syntax.Type.Interface
instance GHC.Read.Read Curry.Syntax.Type.Interface
instance GHC.Classes.Eq Curry.Syntax.Type.Interface
instance GHC.Show.Show Curry.Syntax.Type.IDecl
instance GHC.Read.Read Curry.Syntax.Type.IDecl
instance GHC.Classes.Eq Curry.Syntax.Type.IDecl
instance GHC.Show.Show Curry.Syntax.Type.IMethodDecl
instance GHC.Read.Read Curry.Syntax.Type.IMethodDecl
instance GHC.Classes.Eq Curry.Syntax.Type.IMethodDecl
instance GHC.Show.Show Curry.Syntax.Type.QualTypeExpr
instance GHC.Read.Read Curry.Syntax.Type.QualTypeExpr
instance GHC.Classes.Eq Curry.Syntax.Type.QualTypeExpr
instance GHC.Show.Show Curry.Syntax.Type.Constraint
instance GHC.Read.Read Curry.Syntax.Type.Constraint
instance GHC.Classes.Eq Curry.Syntax.Type.Constraint
instance GHC.Show.Show Curry.Syntax.Type.ConstrDecl
instance GHC.Read.Read Curry.Syntax.Type.ConstrDecl
instance GHC.Classes.Eq Curry.Syntax.Type.ConstrDecl
instance GHC.Show.Show Curry.Syntax.Type.NewConstrDecl
instance GHC.Read.Read Curry.Syntax.Type.NewConstrDecl
instance GHC.Classes.Eq Curry.Syntax.Type.NewConstrDecl
instance GHC.Show.Show Curry.Syntax.Type.FieldDecl
instance GHC.Read.Read Curry.Syntax.Type.FieldDecl
instance GHC.Classes.Eq Curry.Syntax.Type.FieldDecl
instance GHC.Show.Show Curry.Syntax.Type.TypeExpr
instance GHC.Read.Read Curry.Syntax.Type.TypeExpr
instance GHC.Classes.Eq Curry.Syntax.Type.TypeExpr
instance GHC.Show.Show Curry.Syntax.Type.Infix
instance GHC.Read.Read Curry.Syntax.Type.Infix
instance GHC.Classes.Eq Curry.Syntax.Type.Infix
instance GHC.Show.Show Curry.Syntax.Type.KindExpr
instance GHC.Read.Read Curry.Syntax.Type.KindExpr
instance GHC.Classes.Eq Curry.Syntax.Type.KindExpr
instance GHC.Show.Show Curry.Syntax.Type.IImportDecl
instance GHC.Read.Read Curry.Syntax.Type.IImportDecl
instance GHC.Classes.Eq Curry.Syntax.Type.IImportDecl
instance GHC.Show.Show Curry.Syntax.Type.ImportDecl
instance GHC.Read.Read Curry.Syntax.Type.ImportDecl
instance GHC.Classes.Eq Curry.Syntax.Type.ImportDecl
instance GHC.Show.Show Curry.Syntax.Type.ImportSpec
instance GHC.Read.Read Curry.Syntax.Type.ImportSpec
instance GHC.Classes.Eq Curry.Syntax.Type.ImportSpec
instance GHC.Show.Show Curry.Syntax.Type.Import
instance GHC.Read.Read Curry.Syntax.Type.Import
instance GHC.Classes.Eq Curry.Syntax.Type.Import
instance GHC.Show.Show Curry.Syntax.Type.ExportSpec
instance GHC.Read.Read Curry.Syntax.Type.ExportSpec
instance GHC.Classes.Eq Curry.Syntax.Type.ExportSpec
instance GHC.Show.Show Curry.Syntax.Type.Export
instance GHC.Read.Read Curry.Syntax.Type.Export
instance GHC.Classes.Eq Curry.Syntax.Type.Export
instance GHC.Show.Show Curry.Syntax.Type.ModulePragma
instance GHC.Read.Read Curry.Syntax.Type.ModulePragma
instance GHC.Classes.Eq Curry.Syntax.Type.ModulePragma
instance GHC.Base.Functor Curry.Syntax.Type.Goal
instance Curry.Base.SpanInfo.HasSpanInfo (Curry.Syntax.Type.Goal a)
instance Curry.Base.Position.HasPosition (Curry.Syntax.Type.Goal a)
instance GHC.Base.Functor Curry.Syntax.Type.Module
instance Curry.Base.SpanInfo.HasSpanInfo (Curry.Syntax.Type.Module a)
instance Curry.Base.Position.HasPosition (Curry.Syntax.Type.Module a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.Syntax.Type.Module a)
instance GHC.Base.Functor Curry.Syntax.Type.Decl
instance GHC.Base.Functor Curry.Syntax.Type.Equation
instance GHC.Base.Functor Curry.Syntax.Type.Rhs
instance GHC.Base.Functor Curry.Syntax.Type.CondExpr
instance GHC.Base.Functor Curry.Syntax.Type.Expression
instance GHC.Base.Functor Curry.Syntax.Type.Statement
instance GHC.Base.Functor Curry.Syntax.Type.Alt
instance Curry.Base.SpanInfo.HasSpanInfo (Curry.Syntax.Type.Decl a)
instance Curry.Base.SpanInfo.HasSpanInfo (Curry.Syntax.Type.Equation a)
instance Curry.Base.SpanInfo.HasSpanInfo (Curry.Syntax.Type.Rhs a)
instance Curry.Base.SpanInfo.HasSpanInfo (Curry.Syntax.Type.CondExpr a)
instance Curry.Base.SpanInfo.HasSpanInfo (Curry.Syntax.Type.Expression a)
instance Curry.Base.SpanInfo.HasSpanInfo (Curry.Syntax.Type.Statement a)
instance Curry.Base.SpanInfo.HasSpanInfo (Curry.Syntax.Type.Alt a)
instance Curry.Base.Position.HasPosition (Curry.Syntax.Type.Decl a)
instance Curry.Base.Position.HasPosition (Curry.Syntax.Type.Equation a)
instance Curry.Base.Position.HasPosition (Curry.Syntax.Type.Rhs a)
instance Curry.Base.Position.HasPosition (Curry.Syntax.Type.CondExpr a)
instance Curry.Base.Position.HasPosition (Curry.Syntax.Type.Expression a)
instance Curry.Base.Position.HasPosition (Curry.Syntax.Type.Alt a)
instance Curry.Base.Position.HasPosition (Curry.Syntax.Type.Statement a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.Syntax.Type.Decl a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.Syntax.Type.Equation a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.Syntax.Type.Rhs a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.Syntax.Type.CondExpr a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.Syntax.Type.Expression a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.Syntax.Type.Statement a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.Syntax.Type.Alt a)
instance GHC.Base.Functor Curry.Syntax.Type.Var
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.Syntax.Type.Var a)
instance GHC.Base.Functor Curry.Syntax.Type.Lhs
instance Curry.Base.SpanInfo.HasSpanInfo (Curry.Syntax.Type.Lhs a)
instance Curry.Base.Position.HasPosition (Curry.Syntax.Type.Lhs a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.Syntax.Type.Lhs a)
instance GHC.Base.Functor Curry.Syntax.Type.Pattern
instance Curry.Base.SpanInfo.HasSpanInfo (Curry.Syntax.Type.Pattern a)
instance Curry.Base.Position.HasPosition (Curry.Syntax.Type.Pattern a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.Syntax.Type.Pattern a)
instance GHC.Base.Functor Curry.Syntax.Type.Field
instance Curry.Base.SpanInfo.HasSpanInfo (Curry.Syntax.Type.Field a)
instance Curry.Base.Position.HasPosition (Curry.Syntax.Type.Field a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.Syntax.Type.Field a)
instance Data.Binary.Class.Binary Curry.Syntax.Type.CaseType
instance GHC.Base.Functor Curry.Syntax.Type.InfixOp
instance Curry.Base.Position.HasPosition (Curry.Syntax.Type.InfixOp a)
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Curry.Syntax.Type.InfixOp a)
instance Data.Binary.Class.Binary Curry.Syntax.Type.Literal
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.QualTypeExpr
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.QualTypeExpr
instance Data.Binary.Class.Binary Curry.Syntax.Type.QualTypeExpr
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.Constraint
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.Constraint
instance Data.Binary.Class.Binary Curry.Syntax.Type.Constraint
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.ConstrDecl
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.ConstrDecl
instance Data.Binary.Class.Binary Curry.Syntax.Type.ConstrDecl
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.NewConstrDecl
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.NewConstrDecl
instance Data.Binary.Class.Binary Curry.Syntax.Type.NewConstrDecl
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.FieldDecl
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.FieldDecl
instance Data.Binary.Class.Binary Curry.Syntax.Type.FieldDecl
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.TypeExpr
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.TypeExpr
instance Data.Binary.Class.Binary Curry.Syntax.Type.TypeExpr
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.Infix
instance Data.Binary.Class.Binary Curry.Syntax.Type.Infix
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.ImportDecl
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.ImportDecl
instance Data.Binary.Class.Binary Curry.Syntax.Type.ImportDecl
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.ImportSpec
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.ImportSpec
instance Data.Binary.Class.Binary Curry.Syntax.Type.ImportSpec
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.Import
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.Import
instance Data.Binary.Class.Binary Curry.Syntax.Type.Import
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.ExportSpec
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.ExportSpec
instance Data.Binary.Class.Binary Curry.Syntax.Type.ExportSpec
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.Export
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.Export
instance Data.Binary.Class.Binary Curry.Syntax.Type.Export
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.ModulePragma
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.ModulePragma
instance Data.Binary.Class.Binary Curry.Syntax.Type.ModulePragma


-- | Transform a CurrySyntax module into a string representation without
--   any pretty printing.
--   
--   Behaves like a derived Show instance even on parts with a specific
--   one.
module Curry.Syntax.ShowModule

-- | Show a Curry module like by an devired <a>Show</a> instance
showModule :: Show a => Module a -> String


-- | The Curry parser is implemented using the (mostly) LL(1) parsing
--   combinators implemented in <a>LLParseComb</a>.
module Curry.Syntax.Parser

-- | Parse a <a>Module</a>
parseSource :: FilePath -> String -> CYM (Module ())

-- | Parse a <a>Module</a> header
parseHeader :: FilePath -> String -> CYM (Module ())

-- | Parse only pragmas of a <a>Module</a>
parsePragmas :: FilePath -> String -> CYM (Module ())

-- | Parse an <a>Interface</a>
parseInterface :: FilePath -> String -> CYM Interface

-- | Parse a <a>Goal</a>
parseGoal :: String -> CYM (Goal ())


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

-- | Check whether a <a>Module</a> has a specific <a>KnownExtension</a>
--   enabled by a pragma
hasLanguageExtension :: Module a -> KnownExtension -> Bool

-- | Extract all known extensions from a <a>Module</a>
knownExtensions :: Module a -> [KnownExtension]

-- | Is the declaration a top declaration?
isTopDecl :: Decl a -> Bool

-- | Is the declaration a block declaration?
isBlockDecl :: Decl a -> Bool

-- | Is the declaration a type signature?
isTypeSig :: Decl a -> Bool

-- | Convert an infix operator into an expression
infixOp :: InfixOp a -> Expression a

-- | Is the declaration a type declaration?
isTypeDecl :: Decl a -> Bool

-- | Is the declaration a value declaration?
isValueDecl :: Decl a -> Bool

-- | Is the declaration an infix declaration?
isInfixDecl :: Decl a -> Bool

-- | Is the declaration a default declaration?
isDefaultDecl :: Decl a -> Bool

-- | Is the declaration a class declaration?
isClassDecl :: Decl a -> Bool

-- | Is the declaration a type or a class declaration?
isTypeOrClassDecl :: Decl a -> Bool

-- | Is the declaration an instance declaration?
isInstanceDecl :: Decl a -> Bool

-- | Is the declaration a function declaration?
isFunctionDecl :: Decl a -> Bool

-- | Is the declaration an external declaration?
isExternalDecl :: Decl a -> Bool

-- | Replace the generic module name <tt>main</tt> with the module name
--   derived from the <a>FilePath</a> of the module.
patchModuleId :: FilePath -> Module a -> Module a

-- | Is the pattern semantically equivalent to a variable pattern?
isVariablePattern :: Pattern a -> Bool

-- | Is a type expression a type variable?
isVariableType :: TypeExpr -> Bool

-- | 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?
isSimpleType :: TypeExpr -> Bool

-- | Return the qualified type constructor of a type expression.
typeConstr :: TypeExpr -> QualIdent

-- | Return the list of variables occuring in a type expression.
typeVariables :: TypeExpr -> [Ident]

-- | Return the identifier of a variable.
varIdent :: Var a -> Ident

-- | flatten the left-hand-side to the identifier and all constructor terms
flatLhs :: Lhs a -> (Ident, [Pattern a])

-- | Return the arity of an equation.
eqnArity :: Equation a -> Int

-- | Select the label of a field
fieldLabel :: Field a -> QualIdent

-- | Select the term of a field
fieldTerm :: Field a -> a

-- | Select the label and term of a field
field2Tuple :: Field a -> (QualIdent, a)

-- | Get the operator name of an infix operator
opName :: InfixOp a -> QualIdent
funDecl :: SpanInfo -> a -> Ident -> [Pattern a] -> Expression a -> Decl a
mkEquation :: SpanInfo -> Ident -> [Pattern a] -> Expression a -> Equation a
simpleRhs :: SpanInfo -> Expression a -> Rhs a
patDecl :: SpanInfo -> Pattern a -> Expression a -> Decl a
varDecl :: SpanInfo -> a -> Ident -> Expression a -> Decl a
constrPattern :: a -> QualIdent -> [(a, Ident)] -> Pattern a
caseAlt :: SpanInfo -> Pattern a -> Expression a -> Alt a
mkLet :: [Decl a] -> Expression a -> Expression a
mkVar :: a -> Ident -> Expression a
mkCase :: CaseType -> Expression a -> [Alt a] -> Expression a
mkLambda :: [Pattern a] -> Expression a -> Expression a
apply :: Expression a -> [Expression a] -> Expression a
unapply :: Expression a -> [Expression a] -> (Expression a, [Expression a])

-- | Get the identifier of a constructor declaration
constrId :: ConstrDecl -> Ident

-- | Get the identifier of a newtype constructor declaration
nconstrId :: NewConstrDecl -> Ident

-- | Get the type of a newtype constructor declaration
nconstrType :: NewConstrDecl -> TypeExpr

-- | Get record label identifiers of a constructor declaration
recordLabels :: ConstrDecl -> [Ident]

-- | Get record label identifier of a newtype constructor declaration
nrecordLabels :: NewConstrDecl -> [Ident]

-- | Get the declared method identifiers of a type class method declaration
methods :: Decl a -> [Ident]

-- | Get the method identifiers of a type class method implementations
impls :: Decl a -> [Ident]

-- | Get the declared method identifier of an interface method declaration
imethod :: IMethodDecl -> Ident

-- | Get the arity of an interface method declaration
imethodArity :: IMethodDecl -> Maybe Int
shortenModuleAST :: Module () -> Module ()
instance Curry.Syntax.Utils.ShortenAST (Curry.Syntax.Type.Module a)
instance Curry.Syntax.Utils.ShortenAST (Curry.Syntax.Type.Decl a)


-- | This module implements a pretty printer for Curry expressions. It was
--   derived from the Haskell pretty printer provided in Simon Marlow's
--   Haskell parser.
module Curry.Syntax.Pretty

-- | Pretty-print something in isolation.
pPrint :: Pretty a => a -> Doc

-- | Pretty-print something in a precedence context.
pPrintPrec :: Pretty a => Int -> a -> Doc
ppContext :: Context -> Doc
ppInstanceType :: InstanceType -> Doc
ppIMethodImpl :: IMethodImpl -> Doc

-- | Pretty print an identifier
ppIdent :: Ident -> Doc
ppQIdent :: QualIdent -> Doc
ppInfixOp :: Ident -> Doc
ppQInfixOp :: QualIdent -> Doc
ppMIdent :: ModuleIdent -> Doc
instance Curry.Base.Pretty.Pretty (Curry.Syntax.Type.Module a)
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.ModulePragma
instance Curry.Base.Pretty.Pretty Curry.Syntax.Extension.Extension
instance Curry.Base.Pretty.Pretty Curry.Syntax.Extension.Tool
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.ExportSpec
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.Export
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.ImportDecl
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.ImportSpec
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.Import
instance Curry.Base.Pretty.Pretty (Curry.Syntax.Type.Decl a)
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.Constraint
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.ConstrDecl
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.FieldDecl
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.NewConstrDecl
instance Curry.Base.Pretty.Pretty (Curry.Syntax.Type.Equation a)
instance Curry.Base.Pretty.Pretty (Curry.Syntax.Type.Lhs a)
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.Interface
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.IImportDecl
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.IDecl
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.IMethodDecl
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.KindExpr
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.QualTypeExpr
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.TypeExpr
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.Literal
instance Curry.Base.Pretty.Pretty (Curry.Syntax.Type.Pattern a)
instance Curry.Base.Pretty.Pretty a => Curry.Base.Pretty.Pretty (Curry.Syntax.Type.Field a)
instance Curry.Base.Pretty.Pretty (Curry.Syntax.Type.Expression a)
instance Curry.Base.Pretty.Pretty (Curry.Syntax.Type.Statement a)
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.CaseType
instance Curry.Base.Pretty.Pretty (Curry.Syntax.Type.Alt a)
instance Curry.Base.Pretty.Pretty (Curry.Syntax.Type.Var a)
instance Curry.Base.Pretty.Pretty (Curry.Syntax.Type.InfixOp a)


-- | The functions <tt>tokind</tt> and <a>fromKind</a> convert Curry kind
--   expressions into kinds and vice versa.
--   
--   When Curry kinds are converted with <a>fromKind</a>, kind variables
--   are instantiated with the kind *.
module Base.CurryKinds
toKind :: KindExpr -> Kind
toKind' :: Maybe KindExpr -> Int -> Kind
fromKind :: Kind -> KindExpr
fromKind' :: Kind -> Int -> Maybe KindExpr
ppKind :: Kind -> Doc


-- | TODO
module Base.PrettyKinds
instance Curry.Base.Pretty.Pretty Base.Kinds.Kind


module Curry.Syntax

-- | Data type for curry lexer tokens
data Token
Token :: Category -> Attributes -> Token

-- | Category of curry tokens
data Category
CharTok :: Category
IntTok :: Category
FloatTok :: Category
StringTok :: Category
Id :: Category
QId :: Category
Sym :: Category
QSym :: Category
LeftParen :: Category
RightParen :: Category
Semicolon :: Category
LeftBrace :: Category
RightBrace :: Category
LeftBracket :: Category
RightBracket :: Category
Comma :: Category
Underscore :: Category
Backquote :: Category
VSemicolon :: Category
VRightBrace :: Category
KW_case :: Category
KW_class :: Category
KW_data :: Category
KW_default :: Category
KW_deriving :: Category
KW_do :: Category
KW_else :: Category
KW_external :: Category
KW_fcase :: Category
KW_free :: Category
KW_if :: Category
KW_import :: Category
KW_in :: Category
KW_infix :: Category
KW_infixl :: Category
KW_infixr :: Category
KW_instance :: Category
KW_let :: Category
KW_module :: Category
KW_newtype :: Category
KW_of :: Category
KW_then :: Category
KW_type :: Category
KW_where :: Category
At :: Category
Colon :: Category
DotDot :: Category
DoubleColon :: Category
Equals :: Category
Backslash :: Category
Bar :: Category

LeftArrow :: Category
RightArrow :: Category
Tilde :: Category
DoubleArrow :: Category
Id_as :: Category
Id_ccall :: Category
Id_forall :: Category
Id_hiding :: Category
Id_interface :: Category
Id_primitive :: Category
Id_qualified :: Category
SymDot :: Category
SymMinus :: Category
SymStar :: Category
PragmaLanguage :: Category
PragmaOptions :: Category
PragmaHiding :: Category
PragmaMethod :: Category
PragmaModule :: Category
PragmaEnd :: Category
LineComment :: Category
NestedComment :: Category
EOF :: Category

-- | Attributes associated to a token
data Attributes
NoAttributes :: Attributes
CharAttributes :: Char -> String -> Attributes
[cval] :: Attributes -> Char
[original] :: Attributes -> String
IntAttributes :: Integer -> String -> Attributes
[ival] :: Attributes -> Integer
[original] :: Attributes -> String
FloatAttributes :: Double -> String -> Attributes
[fval] :: Attributes -> Double
[original] :: Attributes -> String
StringAttributes :: String -> String -> Attributes
[sval] :: Attributes -> String
[original] :: Attributes -> String
IdentAttributes :: [String] -> String -> Attributes
[modulVal] :: Attributes -> [String]
[sval] :: Attributes -> String
OptionsAttributes :: Maybe String -> String -> Attributes
[toolVal] :: Attributes -> Maybe String
[toolArgs] :: Attributes -> String

-- | Unliterate a LiterateCurry file, identity on normal Curry file.
unlit :: FilePath -> String -> CYM String

-- | Unliterate and return the result of a lexical analysis of the source
--   program <tt>src</tt>. The result is a list of tuples consisting of a
--   <a>Span</a> and a <tt>Token</tt>.
unlitLexSource :: FilePath -> String -> CYM [(Span, Token)]

-- | Unliterate and parse a Curry <a>Module</a> header
unlitParseHeader :: FilePath -> String -> CYM (Module ())

-- | Unliterate and parse only pragmas of a Curry <a>Module</a>
unlitParsePragmas :: FilePath -> String -> CYM (Module ())

-- | Unliterate and parse a Curry <a>Module</a>
unlitParseModule :: FilePath -> String -> CYM (Module ())

-- | Return the result of a lexical analysis of the source program
--   <tt>src</tt>. The result is a list of tuples consisting of a
--   <a>Span</a> and a <tt>Token</tt>.
lexSource :: FilePath -> String -> CYM [(Span, Token)]

-- | Parse a Curry <a>Interface</a>
parseInterface :: FilePath -> String -> CYM Interface

-- | Parse a Curry <a>Module</a> header
parseHeader :: FilePath -> String -> CYM (Module ())

-- | Parse only pragmas of a Curry <a>Module</a>
parsePragmas :: FilePath -> String -> CYM (Module ())

-- | Parse a Curry <a>Module</a>
parseModule :: FilePath -> String -> CYM (Module ())

-- | Parse a <a>Goal</a>, i.e. an expression with (optional) local
--   declarations
parseGoal :: String -> CYM (Goal ())

-- | Pretty-print something in isolation.
pPrint :: Pretty a => a -> Doc

-- | Pretty-print something in a precedence context.
pPrintPrec :: Pretty a => Int -> a -> Doc

-- | Show a Curry module like by an devired <a>Show</a> instance
showModule :: Show a => Module a -> String


-- | If a module is recompiled, the compiler has to check whether the
--   interface file must be updated. This must be done if any exported
--   entity has been changed, or an export was removed or added. The
--   function <a>intfEquiv</a> checks whether two interfaces are
--   equivalent, i.e., whether they define the same entities.
module Curry.Syntax.InterfaceEquivalence

-- | Disambiguate nullary type constructors and type variables.
fixInterface :: Interface -> Interface

-- | Are two given interfaces equivalent?
intfEquiv :: Interface -> Interface -> Bool
instance Curry.Syntax.InterfaceEquivalence.FixInterface a => Curry.Syntax.InterfaceEquivalence.FixInterface (GHC.Maybe.Maybe a)
instance Curry.Syntax.InterfaceEquivalence.FixInterface a => Curry.Syntax.InterfaceEquivalence.FixInterface [a]
instance Curry.Syntax.InterfaceEquivalence.FixInterface Curry.Syntax.Type.IDecl
instance Curry.Syntax.InterfaceEquivalence.FixInterface Curry.Syntax.Type.ConstrDecl
instance Curry.Syntax.InterfaceEquivalence.FixInterface Curry.Syntax.Type.FieldDecl
instance Curry.Syntax.InterfaceEquivalence.FixInterface Curry.Syntax.Type.NewConstrDecl
instance Curry.Syntax.InterfaceEquivalence.FixInterface Curry.Syntax.Type.IMethodDecl
instance Curry.Syntax.InterfaceEquivalence.FixInterface Curry.Syntax.Type.QualTypeExpr
instance Curry.Syntax.InterfaceEquivalence.FixInterface Curry.Syntax.Type.Constraint
instance Curry.Syntax.InterfaceEquivalence.FixInterface Curry.Syntax.Type.TypeExpr
instance Curry.Syntax.InterfaceEquivalence.Equiv a => Curry.Syntax.InterfaceEquivalence.Equiv (GHC.Maybe.Maybe a)
instance Curry.Syntax.InterfaceEquivalence.Equiv a => Curry.Syntax.InterfaceEquivalence.Equiv [a]
instance Curry.Syntax.InterfaceEquivalence.Equiv Curry.Syntax.Type.Interface
instance Curry.Syntax.InterfaceEquivalence.Equiv Curry.Syntax.Type.IImportDecl
instance Curry.Syntax.InterfaceEquivalence.Equiv Curry.Syntax.Type.IDecl
instance Curry.Syntax.InterfaceEquivalence.Equiv Curry.Syntax.Type.ConstrDecl
instance Curry.Syntax.InterfaceEquivalence.Equiv Curry.Syntax.Type.FieldDecl
instance Curry.Syntax.InterfaceEquivalence.Equiv Curry.Syntax.Type.NewConstrDecl
instance Curry.Syntax.InterfaceEquivalence.Equiv Curry.Syntax.Type.IMethodDecl
instance Curry.Syntax.InterfaceEquivalence.Equiv Curry.Base.Ident.Ident


-- | This module provides the function <a>importCheck</a> to check and
--   expand the import specifications of all import declarations.
module Checks.ImportSyntaxCheck
importCheck :: Interface -> Maybe ImportSpec -> (Maybe ImportSpec, [Message])
instance GHC.Show.Show Checks.ImportSyntaxCheck.IValueInfo
instance GHC.Show.Show Checks.ImportSyntaxCheck.ITypeInfo
instance Base.TopEnv.Entity Checks.ImportSyntaxCheck.IValueInfo
instance Base.TopEnv.Entity Checks.ImportSyntaxCheck.ITypeInfo


-- | First of all, the compiler scans a source file for file-header pragmas
--   that may activate language extensions.
module Checks.ExtensionCheck
extensionCheck :: Options -> Module a -> ([KnownExtension], [Message])


-- | The compiler needs to compute the lists of free and bound variables
--   for various different entities. We will devote three type classes to
--   that purpose. The <a>QualExpr</a> class is expected to take into
--   account that it is possible to use a qualified name to refer to a
--   function defined in the current module and therefore <tt>M.x</tt> and
--   <tt>x</tt>, where <tt>M</tt> is the current module name, should be
--   considered the same name. However, note that this is correct only
--   after renaming all local definitions as <tt>M.x</tt> always denotes an
--   entity defined at the top-level.
module Base.Expr
class Expr e

-- | Free variables in an <a>Expr</a>
fv :: Expr e => e -> [Ident]
class QualExpr e

-- | Free qualified variables in an <a>Expr</a>
qfv :: QualExpr e => ModuleIdent -> e -> [Ident]
class QuantExpr e

-- | Bounded variables in an <a>Expr</a>
bv :: QuantExpr e => e -> [Ident]
instance Base.Expr.QuantExpr e => Base.Expr.QuantExpr [e]
instance Base.Expr.QuantExpr (Curry.Syntax.Type.Decl a)
instance Base.Expr.QuantExpr (Curry.Syntax.Type.Lhs a)
instance Base.Expr.QuantExpr (Curry.Syntax.Type.Var a)
instance Base.Expr.QuantExpr a => Base.Expr.QuantExpr (Curry.Syntax.Type.Field a)
instance Base.Expr.QuantExpr (Curry.Syntax.Type.Statement a)
instance Base.Expr.QuantExpr (Curry.Syntax.Type.Pattern a)
instance Base.Expr.QuantExpr Curry.Syntax.Type.Constraint
instance Base.Expr.QuantExpr Curry.Syntax.Type.QualTypeExpr
instance Base.Expr.QuantExpr Curry.Syntax.Type.TypeExpr
instance Base.Expr.QualExpr e => Base.Expr.QualExpr [e]
instance Base.Expr.QualExpr (Curry.Syntax.Type.Decl a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.Equation a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.Lhs a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.Rhs a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.CondExpr a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.Expression a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.Statement a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.Alt a)
instance Base.Expr.QualExpr a => Base.Expr.QualExpr (Curry.Syntax.Type.Field a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.InfixOp a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.Pattern a)
instance Base.Expr.Expr e => Base.Expr.Expr [e]
instance Base.Expr.Expr Curry.Syntax.Type.Constraint
instance Base.Expr.Expr Curry.Syntax.Type.QualTypeExpr
instance Base.Expr.Expr Curry.Syntax.Type.TypeExpr


-- | This module implements the functions to compute the dependency
--   information between Curry modules. This is used to create Makefile
--   dependencies and to update programs composed of multiple modules.
module CurryDeps

-- | Different types of source files
data Source

-- | A source file with pragmas and module imports
Source :: FilePath -> [ModulePragma] -> [ModuleIdent] -> Source

-- | An interface file
Interface :: FilePath -> Source

-- | An unknown file
Unknown :: Source

-- | Retrieve the dependencies of a source file in topological order and
--   possible errors during flattering
flatDeps :: Options -> FilePath -> CYIO [(ModuleIdent, Source)]

-- | Retrieve the dependencies of a source file as a <a>SourceEnv</a>
deps :: Options -> SourceEnv -> FilePath -> CYIO SourceEnv
flattenDeps :: SourceEnv -> ([(ModuleIdent, Source)], [Message])

-- | Retrieve the dependencies of a given source file
sourceDeps :: Options -> SourceEnv -> FilePath -> CYIO SourceEnv

-- | Retrieve the dependencies of a given module
moduleDeps :: Options -> SourceEnv -> FilePath -> Module a -> CYIO SourceEnv
instance GHC.Show.Show CurryDeps.Source
instance GHC.Classes.Eq CurryDeps.Source


-- | The compiler maintains information about all type classes in an
--   environment that maps type classes to a sorted list of their direct
--   superclasses and all their associated class methods with an additional
--   flag stating whether an default implementation has been provided or
--   not. For both the type class identifier and the list of super classes
--   original names are used. Thus, the use of a flat environment is
--   sufficient.
module Env.Class
type ClassEnv = Map QualIdent ClassInfo
initClassEnv :: ClassEnv
type ClassInfo = ([QualIdent], [(Ident, Bool)])
bindClassInfo :: QualIdent -> ClassInfo -> ClassEnv -> ClassEnv
mergeClassInfo :: ClassInfo -> ClassInfo -> ClassInfo
lookupClassInfo :: QualIdent -> ClassEnv -> Maybe ClassInfo
superClasses :: QualIdent -> ClassEnv -> [QualIdent]
allSuperClasses :: QualIdent -> ClassEnv -> [QualIdent]
classMethods :: QualIdent -> ClassEnv -> [Ident]
hasDefaultImpl :: QualIdent -> Ident -> ClassEnv -> Bool


-- | This module modules provides the definitions for the internal
--   representation of types in the compiler along with some helper
--   functions.
module Base.Types
data Type
TypeConstructor :: QualIdent -> Type
TypeVariable :: Int -> Type
TypeConstrained :: [Type] -> Int -> Type
TypeApply :: Type -> Type -> Type
TypeArrow :: Type -> Type -> Type
TypeForall :: [Int] -> Type -> Type
applyType :: Type -> [Type] -> Type
unapplyType :: Bool -> Type -> (Type, [Type])
rootOfType :: Type -> QualIdent
isArrowType :: Type -> Bool
arrowArity :: Type -> Int
arrowArgs :: Type -> [Type]
arrowBase :: Type -> Type
arrowUnapply :: Type -> ([Type], Type)
class IsType t
typeVars :: IsType t => t -> [Int]
typeConstrs :: Type -> [QualIdent]
qualifyType :: ModuleIdent -> Type -> Type
unqualifyType :: ModuleIdent -> Type -> Type
qualifyTC :: ModuleIdent -> QualIdent -> QualIdent
data Pred
Pred :: QualIdent -> Type -> Pred
qualifyPred :: ModuleIdent -> Pred -> Pred
unqualifyPred :: ModuleIdent -> Pred -> Pred
type PredSet = Set Pred
emptyPredSet :: PredSet
partitionPredSet :: PredSet -> (PredSet, PredSet)
minPredSet :: ClassEnv -> PredSet -> PredSet
maxPredSet :: ClassEnv -> PredSet -> PredSet
qualifyPredSet :: ModuleIdent -> PredSet -> PredSet
unqualifyPredSet :: ModuleIdent -> PredSet -> PredSet
data PredType
PredType :: PredSet -> Type -> PredType
predType :: Type -> PredType
unpredType :: PredType -> Type
qualifyPredType :: ModuleIdent -> PredType -> PredType
unqualifyPredType :: ModuleIdent -> PredType -> PredType
data DataConstr
DataConstr :: Ident -> [Type] -> DataConstr
RecordConstr :: Ident -> [Ident] -> [Type] -> DataConstr
constrIdent :: DataConstr -> Ident
constrTypes :: DataConstr -> [Type]
recLabels :: DataConstr -> [Ident]
recLabelTypes :: DataConstr -> [Type]
tupleData :: [DataConstr]
data ClassMethod
ClassMethod :: Ident -> Maybe Int -> PredType -> ClassMethod
methodName :: ClassMethod -> Ident
methodArity :: ClassMethod -> Maybe Int
methodType :: ClassMethod -> PredType
data TypeScheme
ForAll :: Int -> PredType -> TypeScheme
monoType :: Type -> TypeScheme
polyType :: Type -> TypeScheme
typeScheme :: PredType -> TypeScheme
rawType :: TypeScheme -> Type
arrowType :: Type -> Type -> Type
unitType :: Type
predUnitType :: PredType
boolType :: Type
predBoolType :: PredType
charType :: Type
intType :: Type
predIntType :: PredType
floatType :: Type
predFloatType :: PredType
stringType :: Type
predStringType :: PredType
listType :: Type -> Type
consType :: Type -> Type
ioType :: Type -> Type
tupleType :: [Type] -> Type
numTypes :: [Type]
fractionalTypes :: [Type]
predefTypes :: [(Type, [DataConstr])]
instance GHC.Show.Show Base.Types.TypeScheme
instance GHC.Classes.Eq Base.Types.TypeScheme
instance GHC.Show.Show Base.Types.ClassMethod
instance GHC.Classes.Eq Base.Types.ClassMethod
instance GHC.Show.Show Base.Types.DataConstr
instance GHC.Classes.Eq Base.Types.DataConstr
instance GHC.Show.Show Base.Types.PredType
instance GHC.Classes.Eq Base.Types.PredType
instance GHC.Show.Show Base.Types.Pred
instance GHC.Classes.Eq Base.Types.Pred
instance GHC.Show.Show Base.Types.Type
instance GHC.Classes.Ord Base.Types.Type
instance GHC.Classes.Eq Base.Types.Type
instance Base.Types.IsType Base.Types.TypeScheme
instance Base.Types.IsType Base.Types.PredType
instance GHC.Classes.Ord Base.Types.Pred
instance Base.Types.IsType Base.Types.Pred
instance Base.Types.IsType Base.Types.Type
instance (Base.Types.IsType a, GHC.Classes.Ord a) => Base.Types.IsType (Data.Set.Internal.Set a)


-- | The functions <a>toType</a>, <a>toTypes</a>, and <a>fromType</a>
--   convert Curry type expressions into types and vice versa. The
--   functions <a>qualifyType</a> and <a>unqualifyType</a> add and remove
--   module qualifiers in a type, respectively.
--   
--   When Curry type expression are converted with <a>toType</a> or
--   <a>toTypes</a>, type variables are assigned ascending indices in the
--   order of their occurrence. It is possible to pass a list of additional
--   type variables to both functions which are assigned indices before
--   those variables occurring in the type. This allows preserving the
--   order of type variables in the left hand side of a type declaration.
module Base.CurryTypes
toType :: [Ident] -> TypeExpr -> Type
toTypes :: [Ident] -> [TypeExpr] -> [Type]
toQualType :: ModuleIdent -> [Ident] -> TypeExpr -> Type
toQualTypes :: ModuleIdent -> [Ident] -> [TypeExpr] -> [Type]
toPred :: [Ident] -> Constraint -> Pred
toQualPred :: ModuleIdent -> [Ident] -> Constraint -> Pred
toPredSet :: [Ident] -> Context -> PredSet
toQualPredSet :: ModuleIdent -> [Ident] -> Context -> PredSet
toPredType :: [Ident] -> QualTypeExpr -> PredType
toQualPredType :: ModuleIdent -> [Ident] -> QualTypeExpr -> PredType
toConstrType :: QualIdent -> [Ident] -> [TypeExpr] -> PredType
toMethodType :: QualIdent -> Ident -> QualTypeExpr -> PredType
fromType :: [Ident] -> Type -> TypeExpr
fromQualType :: ModuleIdent -> [Ident] -> Type -> TypeExpr
fromPred :: [Ident] -> Pred -> Constraint
fromQualPred :: ModuleIdent -> [Ident] -> Pred -> Constraint
fromPredSet :: [Ident] -> PredSet -> Context
fromQualPredSet :: ModuleIdent -> [Ident] -> PredSet -> Context
fromPredType :: [Ident] -> PredType -> QualTypeExpr
fromQualPredType :: ModuleIdent -> [Ident] -> PredType -> QualTypeExpr
ppType :: ModuleIdent -> Type -> Doc
ppPred :: ModuleIdent -> Pred -> Doc
ppPredType :: ModuleIdent -> PredType -> Doc
ppTypeScheme :: ModuleIdent -> TypeScheme -> Doc


-- | TODO
module Base.PrettyTypes
instance Curry.Base.Pretty.Pretty Base.Types.Type
instance Curry.Base.Pretty.Pretty Base.Types.Pred
instance Curry.Base.Pretty.Pretty a => Curry.Base.Pretty.Pretty (Data.Set.Internal.Set a)
instance Curry.Base.Pretty.Pretty Base.Types.PredType
instance Curry.Base.Pretty.Pretty Base.Types.DataConstr
instance Curry.Base.Pretty.Pretty Base.Types.ClassMethod
instance Curry.Base.Pretty.Pretty Base.Types.TypeScheme


-- | The compiler maintains information about defined instances in an
--   environment that maps pairs of type classes and type constructors to
--   the name of the module where the instance is declared, the context as
--   given in the instance declaration, and a list of the class methods
--   implemented in the specific instance along with their arity. A flat
--   environment is sufficient because instances are visible globally and
--   cannot be hidden. Instances are recorded only with the original names
--   of the type class and type constructor involved. The context also uses
--   original names and is already minimized.
module Env.Instance
type InstIdent = (QualIdent, QualIdent)
ppInstIdent :: InstIdent -> Doc
type InstInfo = (ModuleIdent, PredSet, [(Ident, Int)])
type InstEnv = Map InstIdent InstInfo
initInstEnv :: InstEnv
bindInstInfo :: InstIdent -> InstInfo -> InstEnv -> InstEnv
removeInstInfo :: InstIdent -> InstEnv -> InstEnv
lookupInstInfo :: InstIdent -> InstEnv -> Maybe InstInfo


-- | This module provides an environment for imported interfaces.
module Env.Interface

-- | Environment which maps the <a>ModuleIdent</a> of an imported module to
--   the corresponding <a>Interface</a>.
type InterfaceEnv = Map ModuleIdent Interface

-- | Initial <a>InterfaceEnv</a>.
initInterfaceEnv :: InterfaceEnv

-- | Lookup the <a>Interface</a> for an imported module.
lookupInterface :: ModuleIdent -> InterfaceEnv -> Maybe Interface


-- | This module provides an environment for resolving module aliases.
--   
--   For example, if module <tt>FiniteMap</tt> is imported via
--   
--   <pre>
--   import FiniteMap as FM
--   </pre>
--   
--   then <tt>FM</tt> is an alias for <tt>FiniteMap</tt>, and
--   <tt>FiniteMap</tt> is aliased by <tt>FM</tt>.
module Env.ModuleAlias

-- | Mapping from the original name of an imported module to its alias.
type AliasEnv = Map ModuleIdent ModuleIdent

-- | Initial alias environment
initAliasEnv :: AliasEnv

-- | Create an alias environment from a list of import declarations
importAliases :: [ImportDecl] -> AliasEnv


-- | In order to parse infix expressions correctly, the compiler must know
--   the precedence and fixity of each operator. Operator precedences are
--   associated with entities and will be checked after renaming was
--   applied. Nevertheless, we need to save precedences for ambiguous names
--   in order to handle them correctly while computing the exported
--   interface of a module.
--   
--   If no fixity is assigned to an operator, it will be given the default
--   precedence 9 and assumed to be a left-associative operator.
--   
--   <i>Note:</i> this modified version uses Haskell type <a>Integer</a>
--   for representing the precedence. This change had to be done due to the
--   introduction of unlimited integer constants in the parser / lexer.
module Env.OpPrec

-- | Operator precedence.
data OpPrec
OpPrec :: Infix -> Precedence -> OpPrec

-- | Default operator declaration (associativity and precedence).
defaultP :: OpPrec

-- | Default operator associativity.
defaultAssoc :: Infix

-- | Default operator precedence.
defaultPrecedence :: Precedence
mkPrec :: Maybe Precedence -> Precedence

-- | Environment mapping identifiers to their operator precedence.
type OpPrecEnv = TopEnv PrecInfo

-- | Precedence information for an identifier.
data PrecInfo
PrecInfo :: QualIdent -> OpPrec -> PrecInfo

-- | Bind an operator precedence.
bindP :: ModuleIdent -> Ident -> OpPrec -> OpPrecEnv -> OpPrecEnv

-- | Lookup the operator precedence for an <a>Ident</a>.
lookupP :: Ident -> OpPrecEnv -> [PrecInfo]

-- | Lookup the operator precedence for an <a>QualIdent</a>.
qualLookupP :: QualIdent -> OpPrecEnv -> [PrecInfo]

-- | Initial <a>OpPrecEnv</a>.
initOpPrecEnv :: OpPrecEnv
instance GHC.Show.Show Env.OpPrec.PrecInfo
instance GHC.Classes.Eq Env.OpPrec.PrecInfo
instance GHC.Classes.Eq Env.OpPrec.OpPrec
instance Base.TopEnv.Entity Env.OpPrec.PrecInfo
instance Curry.Base.Pretty.Pretty Env.OpPrec.PrecInfo
instance GHC.Show.Show Env.OpPrec.OpPrec
instance Curry.Base.Pretty.Pretty Env.OpPrec.OpPrec


-- | The parser does not know the relative precedences of infix operators
--   and therefore parses them as if they all associate to the right and
--   have the same precedence. After performing the definition checks, the
--   compiler is going to process the infix applications in the module and
--   rearrange infix applications according to the relative precedences of
--   the operators involved.
module Checks.PrecCheck
precCheck :: ModuleIdent -> OpPrecEnv -> [Decl a] -> ([Decl a], OpPrecEnv, [Message])


-- | For all defined types the compiler must maintain kind information. For
--   algebraic data types and renaming types the compiler also records all
--   data constructors belonging to that type, for alias types the type
--   expression to be expanded is saved. Futhermore, recording the arity is
--   necessary for alias types because the right hand side, i.e., the type
--   expression, can have arbitrary kind and therefore the type alias'
--   arity cannot be determined from its own kind. For instance, the type
--   alias type List = [] has the kind * -&gt; *, but its arity is 0. In
--   order to manage the import and export of types, the names of the
--   original definitions are also recorded. On import two types are
--   considered equal if their original names match.
--   
--   The information for a data constructor comprises the number of
--   existentially quantified type variables, the context and the list of
--   the argument types. Note that renaming type constructors have only one
--   type argument.
--   
--   For type classes the all their methods are saved. Type classes are
--   recorded in the type constructor environment because type constructors
--   and type classes share a common name space.
--   
--   For type variables only their kind is recorded in the environment.
--   
--   Importing and exporting algebraic data types and renaming types is
--   complicated by the fact that the constructors of the type may be
--   (partially) hidden in the interface. This facilitates the definition
--   of abstract data types. An abstract type is always represented as a
--   data type without constructors in the interface regardless of whether
--   it is defined as a data type or as a renaming type. When only some
--   constructors of a data type are hidden, those constructors are
--   replaced by underscores in the interface. Furthermore, if the
--   right-most constructors of a data type are hidden, they are not
--   exported at all in order to make the interface more stable against
--   changes which are private to the module.
module Env.TypeConstructor
data TypeInfo
DataType :: QualIdent -> Kind -> [DataConstr] -> TypeInfo
RenamingType :: QualIdent -> Kind -> DataConstr -> TypeInfo
AliasType :: QualIdent -> Kind -> Int -> Type -> TypeInfo
TypeClass :: QualIdent -> Kind -> [ClassMethod] -> TypeInfo
TypeVar :: Kind -> TypeInfo
tcKind :: ModuleIdent -> QualIdent -> TCEnv -> Kind
clsKind :: ModuleIdent -> QualIdent -> TCEnv -> Kind
varKind :: Ident -> TCEnv -> Kind
clsMethods :: ModuleIdent -> QualIdent -> TCEnv -> [Ident]
type TCEnv = TopEnv TypeInfo
initTCEnv :: TCEnv
bindTypeInfo :: ModuleIdent -> Ident -> TypeInfo -> TCEnv -> TCEnv
rebindTypeInfo :: ModuleIdent -> Ident -> TypeInfo -> TCEnv -> TCEnv
lookupTypeInfo :: Ident -> TCEnv -> [TypeInfo]
qualLookupTypeInfo :: QualIdent -> TCEnv -> [TypeInfo]
qualLookupTypeInfoUnique :: ModuleIdent -> QualIdent -> TCEnv -> [TypeInfo]
getOrigName :: ModuleIdent -> QualIdent -> TCEnv -> QualIdent
reverseLookupByOrigName :: QualIdent -> TCEnv -> [QualIdent]
instance GHC.Show.Show Env.TypeConstructor.TypeInfo
instance Base.TopEnv.Entity Env.TypeConstructor.TypeInfo
instance Curry.Base.Pretty.Pretty Env.TypeConstructor.TypeInfo


-- | At the type level, we distinguish data and renaming types, synonym
--   types, and type classes. Type variables are not recorded. Type
--   synonyms use a kind of their own so that the compiler can verify that
--   no type synonyms are used in type expressions in interface files.
module Env.Type
data TypeKind
Data :: QualIdent -> [Ident] -> TypeKind
Alias :: QualIdent -> TypeKind
Class :: QualIdent -> [Ident] -> TypeKind
toTypeKind :: TypeInfo -> TypeKind
type TypeEnv = TopEnv TypeKind
bindTypeKind :: ModuleIdent -> Ident -> TypeKind -> TypeEnv -> TypeEnv
lookupTypeKind :: Ident -> TypeEnv -> [TypeKind]
qualLookupTypeKind :: QualIdent -> TypeEnv -> [TypeKind]
instance GHC.Show.Show Env.Type.TypeKind
instance GHC.Classes.Eq Env.Type.TypeKind
instance Base.TopEnv.Entity Env.Type.TypeKind


-- | After the source file has been parsed and all modules have been
--   imported, the compiler first checks all type definitions and
--   signatures. In particular, this module disambiguates nullary type
--   constructors and type variables, which -- in contrast to Haskell -- is
--   not possible on purely syntactic criteria. In addition it is checked
--   that all type constructors and type variables occurring on the right
--   hand side of a type declaration are actually defined and no identifier
--   is defined more than once.
module Checks.TypeSyntaxCheck
typeSyntaxCheck :: TCEnv -> Module a -> (Module a, [Message])


-- | Similar to Curry source files, some post-processing has to be applied
--   to parsed interface files. In particular, the compiler must
--   disambiguate nullary type constructors and type variables. In
--   addition, the compiler also checks that all type constructor
--   applications are saturated. Since interface files are closed -- i.e.,
--   they include declarations of all entities which are defined in other
--   modules -- the compiler can perform this check without reference to
--   the global environments.
module Checks.InterfaceSyntaxCheck
intfSyntaxCheck :: Interface -> (Interface, [Message])


-- | Before entering derived instances into the instance environment, the
--   compiler has to ensure that it is not asked for other instances than
--   those of supported type classes.
module Checks.DeriveCheck
deriveCheck :: TCEnv -> Module a -> [Message]


-- | This module implements substitutions on kinds.
module Base.KindSubst
class SubstKind a
subst :: SubstKind a => KindSubst -> a -> a
type KindSubst = Subst Int Kind
bindVar :: Int -> Kind -> KindSubst -> KindSubst
substVar :: KindSubst -> Int -> Kind

-- | Identity substitution
idSubst :: Subst a b

-- | Create a substitution for a single replacement
singleSubst :: Ord v => v -> e -> Subst v e

-- | Extend a substitution with a single replacement
bindSubst :: Ord v => v -> e -> Subst v e -> Subst v e

-- | Compose two substitutions
compose :: Ord v => Subst v e -> Subst v e -> Subst v e
instance Base.KindSubst.SubstKind Base.Kinds.Kind
instance Base.KindSubst.SubstKind Env.TypeConstructor.TypeInfo
instance Base.KindSubst.SubstKind a => Base.KindSubst.SubstKind (Base.TopEnv.TopEnv a)


-- | In order to test the type correctness of a module, the compiler needs
--   to determine the type of every data constructor, function and variable
--   in the module. For the purpose of type checking there is no need for
--   distinguishing between variables and functions. For all objects their
--   original names and their types are saved. In addition, the compiler
--   also saves the (optional) list of field labels for data and newtype
--   constructors. Data constructors and functions also contain arity
--   information. On import two values are considered equal if their
--   original names match.
module Env.Value
type ValueEnv = TopEnv ValueInfo
data ValueInfo

-- | Data constructor with original name, arity, list of record labels and
--   type
DataConstructor :: QualIdent -> Int -> [Ident] -> TypeScheme -> ValueInfo

-- | Newtype constructor with original name, record label and type (arity
--   is always 1)
NewtypeConstructor :: QualIdent -> Ident -> TypeScheme -> ValueInfo

-- | Value with original name, class method name, arity and type
Value :: QualIdent -> Maybe QualIdent -> Int -> TypeScheme -> ValueInfo

-- | Record label with original name, list of constructors for which label
--   is a valid field and type (arity is always 1)
Label :: QualIdent -> [QualIdent] -> TypeScheme -> ValueInfo
bindGlobalInfo :: (QualIdent -> a -> ValueInfo) -> ModuleIdent -> Ident -> a -> ValueEnv -> ValueEnv
bindFun :: ModuleIdent -> Ident -> Maybe QualIdent -> Int -> TypeScheme -> ValueEnv -> ValueEnv
qualBindFun :: ModuleIdent -> Ident -> Maybe QualIdent -> Int -> TypeScheme -> ValueEnv -> ValueEnv
rebindFun :: ModuleIdent -> Ident -> Maybe QualIdent -> Int -> TypeScheme -> ValueEnv -> ValueEnv
unbindFun :: Ident -> ValueEnv -> ValueEnv
lookupValue :: Ident -> ValueEnv -> [ValueInfo]
qualLookupValue :: QualIdent -> ValueEnv -> [ValueInfo]
qualLookupValueUnique :: ModuleIdent -> QualIdent -> ValueEnv -> [ValueInfo]
initDCEnv :: ValueEnv
class ValueType t
toValueType :: ValueType t => Type -> t
fromValueType :: ValueType t => t -> PredType
bindLocalVars :: ValueType t => [(Ident, Int, t)] -> ValueEnv -> ValueEnv
bindLocalVar :: ValueType t => (Ident, Int, t) -> ValueEnv -> ValueEnv
instance GHC.Show.Show Env.Value.ValueInfo
instance Env.Value.ValueType Base.Types.Type
instance Env.Value.ValueType Base.Types.PredType
instance Base.TopEnv.Entity Env.Value.ValueInfo
instance Curry.Base.Pretty.Pretty Env.Value.ValueInfo


-- | This module defines the compilation environment for a single module,
--   containing the information needed throughout the compilation process.
module CompilerEnv
type CompEnv a = (CompilerEnv, a)

-- | A compiler environment contains information about the module currently
--   compiled. The information is updated during the different stages of
--   compilation.
data CompilerEnv
CompilerEnv :: ModuleIdent -> FilePath -> [KnownExtension] -> [(Span, Token)] -> InterfaceEnv -> AliasEnv -> TCEnv -> ClassEnv -> InstEnv -> ValueEnv -> OpPrecEnv -> CompilerEnv

-- | identifier of the module
[moduleIdent] :: CompilerEnv -> ModuleIdent

-- | <a>FilePath</a> of compilation target
[filePath] :: CompilerEnv -> FilePath

-- | enabled language extensions
[extensions] :: CompilerEnv -> [KnownExtension]

-- | token list of module
[tokens] :: CompilerEnv -> [(Span, Token)]

-- | declarations of imported interfaces
[interfaceEnv] :: CompilerEnv -> InterfaceEnv

-- | aliases for imported modules
[aliasEnv] :: CompilerEnv -> AliasEnv

-- | type constructors and type classes
[tyConsEnv] :: CompilerEnv -> TCEnv

-- | all type classes with their super classes
[classEnv] :: CompilerEnv -> ClassEnv

-- | instances
[instEnv] :: CompilerEnv -> InstEnv

-- | functions and data constructors
[valueEnv] :: CompilerEnv -> ValueEnv

-- | operator precedences
[opPrecEnv] :: CompilerEnv -> OpPrecEnv

-- | Initial <a>CompilerEnv</a>
initCompilerEnv :: ModuleIdent -> CompilerEnv

-- | Show the <a>CompilerEnv</a>
showCompilerEnv :: CompilerEnv -> Bool -> Bool -> String

-- | Pretty print a <tt>Map</tt>
ppMap :: (Show a, Pretty a, Show b, Pretty b) => Bool -> Map a b -> Doc
ppMapShow :: (Show a, Show b) => Map a b -> Doc
ppMapPretty :: (Pretty a, Pretty b) => Map a b -> Doc

-- | Pretty print an association list
ppAL :: (Show a, Pretty a, Show b, Pretty b) => Bool -> [(a, b)] -> Doc
ppALShow :: (Show a, Show b) => [(a, b)] -> Doc
ppALPretty :: (Pretty a, Pretty b) => [(a, b)] -> Doc


-- | This module searches for potentially irregular code and generates
--   warning messages.
module Checks.WarnCheck
warnCheck :: WarnOpts -> CaseMode -> AliasEnv -> ValueEnv -> TCEnv -> ClassEnv -> Module a -> [Message]
instance GHC.Show.Show Checks.WarnCheck.IdInfo


-- | After the type declarations have been checked, the compiler performs a
--   syntax check on the remaining declarations. This check disambiguates
--   nullary data constructors and variables which -- in contrast to
--   Haskell -- is not possible on purely syntactic criteria. In addition,
--   this pass checks for undefined as well as ambiguous variables and
--   constructors. In order to allow lifting of local definitions in later
--   phases, all local variables are renamed by adding a key identifying
--   their scope. Therefore, all variables defined in the same scope share
--   the same key so that multiple definitions can be recognized. Finally,
--   all (adjacent) equations of a function are merged into a single
--   definition.
module Checks.SyntaxCheck
syntaxCheck :: [KnownExtension] -> TCEnv -> ValueEnv -> Module () -> ((Module (), [KnownExtension]), [Message])
instance GHC.Show.Show Checks.SyntaxCheck.RenameInfo
instance GHC.Classes.Eq Checks.SyntaxCheck.RenameInfo


-- | Interface files include declarations of all entities that are exported
--   by the module, but defined in another module. Since these declarations
--   can become inconsistent if client modules are not recompiled properly,
--   the compiler checks that all imported declarations in an interface
--   agree with their original definitions.
--   
--   One may ask why we include imported declarations at all, if the
--   compiler always has to compare those declarations with the original
--   definitions. The main reason for this is that it helps to avoid
--   unnecessary recompilations of client modules. As an example, consider
--   the three modules:
--   
--   module A where { data T = C } module B(T(..)) where { import A }
--   module C where { import B; f = C }
--   
--   where module B could be considered as a public interface of module A,
--   which restricts access to type A.T and its constructor C. The client
--   module C imports this type via the public interface B. If now module A
--   is changed by adding a definition of a new global function
--   
--   module A where { data T = C; f = C }
--   
--   module B must be recompiled because A's interface is changed. On the
--   other hand, module C need not be recompiled because the change in A
--   does not affect B's interface. By including the declaration of type
--   A.T in B's interface, the compiler can trivially check that B's
--   interface remains unchanged and therefore the client module C is not
--   recompiled.
--   
--   Another reason for including imported declarations in interfaces is
--   that the compiler in principle could avoid loading interfaces of
--   modules that are imported only indirectly, which would save processing
--   time and allow distributing binary packages of a library with a public
--   interface module only. However, this has not been implemented yet.
module Checks.InterfaceCheck
interfaceCheck :: OpPrecEnv -> TCEnv -> ClassEnv -> InstEnv -> ValueEnv -> Interface -> [Message]


-- | This module implements a check and expansion of the export
--   specification. Any errors in the specification are reported, and if
--   there are no errors, the specification is expanded. The expansion does
--   the following: * If there is no export specification, a specification
--   exporting the entire module is generated. * Otherwise, (re)exports of
--   modules are replaced by an export of all respective entities. * The
--   export of a type with all constructors and fields is replaced by an
--   enumeration of all constructors and fields. * The export of types
--   without sub-entities is extended with an empty list of sub-entities.
module Checks.ExportCheck
exportCheck :: ModuleIdent -> AliasEnv -> TCEnv -> ValueEnv -> Maybe ExportSpec -> [Message]
expandExports :: ModuleIdent -> AliasEnv -> TCEnv -> ValueEnv -> Maybe ExportSpec -> ExportSpec


-- | This module implements substitutions on types.
module Base.TypeSubst
class ExpandAliasType a
expandAliasType :: ExpandAliasType a => [Type] -> a -> a
class SubstType a
subst :: SubstType a => TypeSubst -> a -> a
type TypeSubst = Subst Int Type
bindVar :: Int -> Type -> TypeSubst -> TypeSubst
substVar :: TypeSubst -> Int -> Type
subst' :: TypeSubst -> Type -> [Type] -> Type
expandAliasType' :: [Type] -> Type -> [Type] -> Type
normalize :: Int -> PredType -> PredType
instanceType :: ExpandAliasType a => Type -> a -> a

-- | Identity substitution
idSubst :: Subst a b

-- | Create a substitution for a single replacement
singleSubst :: Ord v => v -> e -> Subst v e

-- | Extend a substitution with a single replacement
bindSubst :: Ord v => v -> e -> Subst v e -> Subst v e

-- | Compose two substitutions
compose :: Ord v => Subst v e -> Subst v e -> Subst v e
instance Base.TypeSubst.ExpandAliasType a => Base.TypeSubst.ExpandAliasType [a]
instance (GHC.Classes.Ord a, Base.TypeSubst.ExpandAliasType a) => Base.TypeSubst.ExpandAliasType (Data.Set.Internal.Set a)
instance Base.TypeSubst.ExpandAliasType Base.Types.Type
instance Base.TypeSubst.ExpandAliasType Base.Types.Pred
instance Base.TypeSubst.ExpandAliasType Base.Types.PredType
instance (GHC.Classes.Ord a, Base.TypeSubst.SubstType a) => Base.TypeSubst.SubstType (Data.Set.Internal.Set a)
instance Base.TypeSubst.SubstType a => Base.TypeSubst.SubstType [a]
instance Base.TypeSubst.SubstType Base.Types.Type
instance Base.TypeSubst.SubstType Base.Types.Pred
instance Base.TypeSubst.SubstType Base.Types.PredType
instance Base.TypeSubst.SubstType Base.Types.TypeScheme
instance Base.TypeSubst.SubstType Env.Value.ValueInfo
instance Base.TypeSubst.SubstType a => Base.TypeSubst.SubstType (Base.TopEnv.TopEnv a)


-- | After the compiler has attributed patterns and expressions with type
--   information during type inference, it is straightforward to recompute
--   the type of every pattern and expression. Since all annotated types
--   are monomorphic, there is no need to instantiate any variables or
--   perform any (non-trivial) unifications.
module Base.Typing
class Typeable a
typeOf :: Typeable a => a -> Type
withType :: (Functor f, Typeable (f Type)) => Type -> f Type -> f Type
matchType :: Type -> Type -> TypeSubst -> TypeSubst
bindDecls :: (Eq t, Typeable t, ValueType t) => [Decl t] -> ValueEnv -> ValueEnv
bindDecl :: (Eq t, Typeable t, ValueType t) => Decl t -> ValueEnv -> ValueEnv
bindPatterns :: (Eq t, Typeable t, ValueType t) => [Pattern t] -> ValueEnv -> ValueEnv
bindPattern :: (Eq t, Typeable t, ValueType t) => Pattern t -> ValueEnv -> ValueEnv
declVars :: (Eq t, Typeable t, ValueType t) => Decl t -> [(Ident, Int, t)]
patternVars :: (Eq t, Typeable t, ValueType t) => Pattern t -> [(Ident, Int, t)]
instance Base.Typing.Typeable Base.Types.Type
instance Base.Typing.Typeable Base.Types.PredType
instance Base.Typing.Typeable a => Base.Typing.Typeable (Curry.Syntax.Type.Rhs a)
instance Base.Typing.Typeable a => Base.Typing.Typeable (Curry.Syntax.Type.Pattern a)
instance Base.Typing.Typeable a => Base.Typing.Typeable (Curry.Syntax.Type.Expression a)
instance Base.Typing.Typeable a => Base.Typing.Typeable (Curry.Syntax.Type.Alt a)


-- | TODO
module Base.AnnotExpr
class QualAnnotExpr e

-- | Free qualified annotated variables in an <a>Expr</a>
qafv :: QualAnnotExpr e => ModuleIdent -> e Type -> [(Type, Ident)]
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.Decl
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.Equation
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.Lhs
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.Rhs
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.CondExpr
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.Expression
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.Statement
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.Alt
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.InfixOp
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.Pattern


-- | This module implements expansion of alias types in types and
--   predicates.
module Base.TypeExpansion
expandType :: ModuleIdent -> TCEnv -> Type -> Type
expandType' :: ModuleIdent -> TCEnv -> Type -> [Type] -> Type
expandPred :: ModuleIdent -> TCEnv -> Pred -> Pred
expandPredSet :: ModuleIdent -> TCEnv -> ClassEnv -> PredSet -> PredSet
expandPredType :: ModuleIdent -> TCEnv -> ClassEnv -> PredType -> PredType
expandMonoType :: ModuleIdent -> TCEnv -> [Ident] -> TypeExpr -> Type
expandPolyType :: ModuleIdent -> TCEnv -> ClassEnv -> QualTypeExpr -> PredType
expandConstrType :: ModuleIdent -> TCEnv -> ClassEnv -> QualIdent -> [Ident] -> [TypeExpr] -> PredType
expandMethodType :: ModuleIdent -> TCEnv -> ClassEnv -> QualIdent -> Ident -> QualTypeExpr -> PredType


-- | This module implements the type checker of the Curry compiler. The
--   type checker is invoked after the syntactic correctness of the program
--   has been verified and kind checking has been applied to all type
--   expressions. Local variables have been renamed already. Thus the
--   compiler can maintain a flat type environment. The type checker now
--   checks the correct typing of all expressions and also verifies that
--   the type signatures given by the user match the inferred types. The
--   type checker uses the algorithm by Damas and Milner (1982) for
--   inferring the types of unannotated declarations, but allows for
--   polymorphic recursion when a type annotation is present.
--   
--   The result of type checking is a (flat) top-level environment
--   containing the types of all constructors, variables, and functions
--   defined at the top level of a module. In addition, a type annotated
--   source module is returned. Note that type annotations on the left hand
--   side of a declaration hold the function or variable's generalized type
--   with the type scheme's universal quantifier left implicit. Type
--   annotations on the right hand side of a declaration hold the
--   particular instance at which a polymorphic function or variable is
--   used.
module Checks.TypeCheck
typeCheck :: ModuleIdent -> TCEnv -> ValueEnv -> ClassEnv -> InstEnv -> [Decl a] -> ([Decl PredType], ValueEnv, [Message])
instance Checks.TypeCheck.Binding a => Checks.TypeCheck.Binding [a]
instance Checks.TypeCheck.Binding (Curry.Syntax.Type.Decl a)
instance Checks.TypeCheck.Binding (Curry.Syntax.Type.Rhs a)
instance Checks.TypeCheck.Binding (Curry.Syntax.Type.Expression a)
instance Checks.TypeCheck.Binding a => Checks.TypeCheck.Binding (Curry.Syntax.Type.Field a)


-- | After the type syntax has been checked und nullary type constructors
--   and type variables have been disambiguated, the compiler infers kinds
--   for all type constructors and type classes defined in the current
--   module and performs kind checking on all type definitions and type
--   signatures.
module Checks.KindCheck
kindCheck :: TCEnv -> ClassEnv -> Module a -> ((TCEnv, ClassEnv), [Message])
instance Checks.KindCheck.HasType a => Checks.KindCheck.HasType [a]
instance Checks.KindCheck.HasType a => Checks.KindCheck.HasType (GHC.Maybe.Maybe a)
instance Checks.KindCheck.HasType (Curry.Syntax.Type.Decl a)
instance Checks.KindCheck.HasType Curry.Syntax.Type.ConstrDecl
instance Checks.KindCheck.HasType Curry.Syntax.Type.FieldDecl
instance Checks.KindCheck.HasType Curry.Syntax.Type.NewConstrDecl
instance Checks.KindCheck.HasType Curry.Syntax.Type.Constraint
instance Checks.KindCheck.HasType Curry.Syntax.Type.QualTypeExpr
instance Checks.KindCheck.HasType Curry.Syntax.Type.TypeExpr
instance Checks.KindCheck.HasType (Curry.Syntax.Type.Equation a)
instance Checks.KindCheck.HasType (Curry.Syntax.Type.Rhs a)
instance Checks.KindCheck.HasType (Curry.Syntax.Type.CondExpr a)
instance Checks.KindCheck.HasType (Curry.Syntax.Type.Expression a)
instance Checks.KindCheck.HasType (Curry.Syntax.Type.Statement a)
instance Checks.KindCheck.HasType (Curry.Syntax.Type.Alt a)
instance Checks.KindCheck.HasType a => Checks.KindCheck.HasType (Curry.Syntax.Type.Field a)
instance Checks.KindCheck.HasType Curry.Base.Ident.QualIdent


-- | Before type checking, the compiler checks for every instance
--   declaration that all necessary super class instances exist.
--   Furthermore, the compiler infers the contexts of the implicit instance
--   declarations introduced by deriving clauses in data and newtype
--   declarations. The instances declared explicitly and automatically
--   derived by the compiler are added to the instance environment . It is
--   also checked that there are no duplicate instances and that all types
--   specified in a default declaration are instances of the Num class.
module Checks.InstanceCheck
instanceCheck :: ModuleIdent -> TCEnv -> ClassEnv -> InstEnv -> [Decl a] -> (InstEnv, [Message])
instance GHC.Classes.Eq Checks.InstanceCheck.InstSource


-- | This module subsumes the different checks to be performed on a Curry
--   module during compilation, e.g. type checking.
module Checks
type Check m a = Options -> CompEnv a -> CYT m (CompEnv a)
interfaceCheck :: Monad m => Check m Interface
importCheck :: Monad m => Interface -> Maybe ImportSpec -> CYT m (Maybe ImportSpec)

-- | Check for enabled language extensions.
--   
--   <ul>
--   <li>Declarations: remain unchanged</li>
--   <li>Environment: The enabled language extensions are updated</li>
--   </ul>
extensionCheck :: Monad m => Check m (Module a)

-- | Check the type syntax of type definitions and signatures.
--   
--   <ul>
--   <li>Declarations: Nullary type constructors and type variables are
--   disambiguated</li>
--   <li>Environment: remains unchanged</li>
--   </ul>
typeSyntaxCheck :: Monad m => Check m (Module a)

-- | Check the kinds of type definitions and signatures.
--   
--   <ul>
--   <li>Declarations: remain unchanged</li>
--   <li>Environment: The type constructor and class environment are
--   updated</li>
--   </ul>
kindCheck :: Monad m => Check m (Module a)

-- | Check for a correct syntax.
--   
--   <ul>
--   <li>Declarations: Nullary data constructors and variables are
--   disambiguated, variables are renamed</li>
--   <li>Environment: remains unchanged</li>
--   </ul>
syntaxCheck :: Monad m => Check m (Module ())

-- | Check the precedences of infix operators.
--   
--   <ul>
--   <li>Declarations: Expressions are reordered according to the specified
--   precedences</li>
--   <li>Environment: The operator precedence environment is updated</li>
--   </ul>
precCheck :: Monad m => Check m (Module a)

-- | Check the deriving clauses.
--   
--   <ul>
--   <li>Declarations: remain unchanged</li>
--   <li>Environment: remain unchanged</li>
--   </ul>
deriveCheck :: Monad m => Check m (Module a)

-- | Check the instances.
--   
--   <ul>
--   <li>Declarations: remain unchanged</li>
--   <li>Environment: The instance environment is updated</li>
--   </ul>
instanceCheck :: Monad m => Check m (Module a)

-- | Apply the correct typing of the module.
--   
--   <ul>
--   <li>Declarations: Type annotations are added to all expressions.</li>
--   <li>Environment: The value environment is updated.</li>
--   </ul>
typeCheck :: Monad m => Options -> CompEnv (Module a) -> CYT m (CompEnv (Module PredType))

-- | Check the export specification
exportCheck :: Monad m => Check m (Module a)

-- | Check the export specification
expandExports :: Monad m => Options -> CompEnv (Module a) -> m (CompEnv (Module a))

-- | Check for warnings.
warnCheck :: Options -> CompilerEnv -> Module a -> [Message]


-- | This module provides the computation of the exported interface of a
--   compiled module. The function <a>exportInterface</a> uses the expanded
--   export specifications and the corresponding environments in order to
--   compute the interface of the module.
module Exports
exportInterface :: CompilerEnv -> Module a -> Interface
instance GHC.Classes.Ord Exports.IInfo
instance GHC.Classes.Eq Exports.IInfo
instance Exports.HasType a => Exports.HasType (GHC.Maybe.Maybe a)
instance Exports.HasType a => Exports.HasType [a]
instance Exports.HasType Curry.Syntax.Type.IDecl
instance Exports.HasType Curry.Syntax.Type.ConstrDecl
instance Exports.HasType Curry.Syntax.Type.FieldDecl
instance Exports.HasType Curry.Syntax.Type.NewConstrDecl
instance Exports.HasType Curry.Syntax.Type.IMethodDecl
instance Exports.HasType Curry.Syntax.Type.Constraint
instance Exports.HasType Curry.Syntax.Type.TypeExpr
instance Exports.HasType Curry.Syntax.Type.QualTypeExpr
instance Exports.HasModule a => Exports.HasModule (GHC.Maybe.Maybe a)
instance Exports.HasModule a => Exports.HasModule [a]
instance Exports.HasModule Curry.Syntax.Type.IDecl
instance Exports.HasModule Curry.Syntax.Type.ConstrDecl
instance Exports.HasModule Curry.Syntax.Type.FieldDecl
instance Exports.HasModule Curry.Syntax.Type.NewConstrDecl
instance Exports.HasModule Curry.Syntax.Type.IMethodDecl
instance Exports.HasModule Curry.Syntax.Type.Constraint
instance Exports.HasModule Curry.Syntax.Type.TypeExpr
instance Exports.HasModule Curry.Syntax.Type.QualTypeExpr
instance Exports.HasModule Curry.Base.Ident.QualIdent
instance Exports.HasModule Curry.Base.Ident.ModuleIdent


-- | This module contains the generation of an <tt>AbstractCurry</tt>
--   program term for a given <tt>Curry</tt> module.
module Generators.GenAbstractCurry

-- | Generate an AbstractCurry program term from the syntax tree when uacy
--   flag is set untype AbstractCurry is generated
genAbstractCurry :: Bool -> CompilerEnv -> Module PredType -> CurryProg
instance GHC.Show.Show Generators.GenAbstractCurry.AbstractEnv


-- | This module contains the generation of a <tt>FlatCurry</tt> program
--   term or a <tt>FlatCurry</tt> interface out of an 'Annotated FlatCurry'
--   module.
module Generators.GenFlatCurry
genFlatCurry :: AProg TypeExpr -> Prog
genFlatInterface :: Prog -> Prog


-- | This module contains the generation of a typed <tt>FlatCurry</tt>
--   program term for a given module in the intermediate language.
module Generators.GenTypedFlatCurry
genTypedFlatCurry :: AProg TypeExpr -> TProg


-- | This module arranges the tokens of the module into different code
--   categories for HTML presentation. The parsed and qualified module is
--   used to establish links between used identifiers and their
--   definitions.
--   
--   The fully qualified module is traversed to generate a list of code
--   elements. Code elements representing identifiers are distinguished by
--   their kind (type constructor, data constructor, function, (type)
--   variable). They include information about their usage (i.e.,
--   declaration, call etc.) and whether the identifier occurs fully
--   qualified in the source code or not. Initially, all identifier codes
--   are fully qualified.
--   
--   In a next step, the token stream of the given program and the code
--   list are traversed sequentially (see <a>encodeToks</a>). The
--   information in the token stream is used to:
--   
--   <ul>
--   <li>add code elements for newlines, spaces and pragmas</li>
--   <li>update the qualification information of identifiers in the code
--   list.</li>
--   </ul>
module Html.SyntaxColoring

-- | Type of codes which are distinguished for HTML output the boolean
--   flags indicate whether the corresponding identifier occurs qualified
--   in the source module
data Code
Keyword :: String -> Code
Space :: Int -> Code
NewLine :: Code
Pragma :: String -> Code
TypeCons :: TypeUsage -> Bool -> QualIdent -> Code
DataCons :: ConsUsage -> Bool -> QualIdent -> Code
Function :: FuncUsage -> Bool -> QualIdent -> Code
Identifier :: IdentUsage -> Bool -> QualIdent -> Code
ModuleName :: ModuleIdent -> Code
Commentary :: String -> Code
NumberCode :: String -> Code
StringCode :: String -> Code
CharCode :: String -> Code
Symbol :: String -> Code
data TypeUsage
TypeDeclare :: TypeUsage
TypeRefer :: TypeUsage
TypeExport :: TypeUsage
TypeImport :: TypeUsage
data ConsUsage
ConsDeclare :: ConsUsage
ConsPattern :: ConsUsage
ConsCall :: ConsUsage
ConsInfix :: ConsUsage
ConsExport :: ConsUsage
ConsImport :: ConsUsage
data IdentUsage
IdDeclare :: IdentUsage
IdRefer :: IdentUsage
IdUnknown :: IdentUsage
data FuncUsage
FuncDeclare :: FuncUsage
FuncTypeSig :: FuncUsage
FuncCall :: FuncUsage
FuncInfix :: FuncUsage
FuncExport :: FuncUsage
FuncImport :: FuncUsage
genProgram :: Module a -> [(Position, Token)] -> [Code]
code2string :: Code -> String
getQualIdent :: Code -> Maybe QualIdent
instance GHC.Show.Show Html.SyntaxColoring.Code
instance GHC.Show.Show Html.SyntaxColoring.IdentUsage
instance GHC.Show.Show Html.SyntaxColoring.FuncUsage
instance GHC.Show.Show Html.SyntaxColoring.ConsUsage
instance GHC.Show.Show Html.SyntaxColoring.TypeUsage


-- | This module defines a function for generating HTML documentation pages
--   for Curry source modules.
module Html.CurryHtml

-- | Translate source file into HTML file with syntaxcoloring
source2html :: Options -> ModuleIdent -> [(Position, Token)] -> Module a -> CYIO ()


-- | The module <tt>IL</tt> defines the intermediate language which will be
--   compiled into abstract machine code. The intermediate language removes
--   a lot of syntactic sugar from the Curry source language. Top-level
--   declarations are restricted to data type and function definitions. A
--   newtype definition serves mainly as a hint to the backend that it must
--   provide an auxiliary function for partial applications of the
--   constructor (Newtype constructors must not occur in patterns and may
--   be used in expressions only as partial applications.).
--   
--   Type declarations use a de-Bruijn indexing scheme (starting at 0) for
--   type variables. In the type of a function, all type variables are
--   numbered in the order of their occurence from left to right, i.e., a
--   type '(Int -&gt; b) -&gt; (a,b) -&gt; c -&gt; (a,c)' is translated
--   into the type (using integer numbers to denote the type variables)
--   '(Int -&gt; 0) -&gt; (1,0) -&gt; 2 -&gt; (1,2)'.
--   
--   Pattern matching in an equation is handled via flexible and rigid
--   <a>Case</a> expressions. Overlapping rules are translated with the
--   help of <a>Or</a> expressions. The intermediate language has three
--   kinds of binding expressions, <a>Exist</a> expressions introduce a new
--   logical variable, <a>Let</a> expression support a single non-recursive
--   variable binding, and <a>Letrec</a> expressions introduce multiple
--   variables with recursive initializer expressions. The intermediate
--   language explicitly distinguishes (local) variables and (global)
--   functions in expressions.
--   
--   Note: this modified version uses haskell type <a>Integer</a> instead
--   of <a>Int</a> for representing integer values. This provides an
--   unlimited range of integer constants in Curry programs.
module IL.Type
type TypeVariableWithKind = (Int, Kind)
data Module
Module :: ModuleIdent -> [ModuleIdent] -> [Decl] -> Module
data Decl
DataDecl :: QualIdent -> [Kind] -> [ConstrDecl] -> Decl
NewtypeDecl :: QualIdent -> [Kind] -> NewConstrDecl -> Decl
ExternalDataDecl :: QualIdent -> [Kind] -> Decl
FunctionDecl :: QualIdent -> [(Type, Ident)] -> Type -> Expression -> Decl
ExternalDecl :: QualIdent -> Int -> Type -> Decl
data ConstrDecl
ConstrDecl :: QualIdent -> [Type] -> ConstrDecl
data NewConstrDecl
NewConstrDecl :: QualIdent -> Type -> NewConstrDecl
data Type
TypeConstructor :: QualIdent -> [Type] -> Type
TypeVariable :: Int -> Type
TypeArrow :: Type -> Type -> Type
TypeForall :: [TypeVariableWithKind] -> Type -> Type
data Kind
KindStar :: Kind
KindVariable :: Int -> Kind
KindArrow :: Kind -> Kind -> Kind
data Literal
Char :: Char -> Literal
Int :: Integer -> Literal
Float :: Double -> Literal
data ConstrTerm

-- | literal patterns
LiteralPattern :: Type -> Literal -> ConstrTerm

-- | constructors
ConstructorPattern :: Type -> QualIdent -> [(Type, Ident)] -> ConstrTerm

-- | default
VariablePattern :: Type -> Ident -> ConstrTerm
data Expression

-- | literal constants
Literal :: Type -> Literal -> Expression

-- | variables
Variable :: Type -> Ident -> Expression

-- | functions
Function :: Type -> QualIdent -> Int -> Expression

-- | constructors
Constructor :: Type -> QualIdent -> Int -> Expression

-- | applications
Apply :: Expression -> Expression -> Expression

-- | case expressions
Case :: Eval -> Expression -> [Alt] -> Expression

-- | non-deterministic or
Or :: Expression -> Expression -> Expression

-- | exist binding (introduction of a free variable)
Exist :: Ident -> Type -> Expression -> Expression

-- | let binding
Let :: Binding -> Expression -> Expression

-- | letrec binding
Letrec :: [Binding] -> Expression -> Expression

-- | typed expression
Typed :: Expression -> Type -> Expression
data Eval
Rigid :: Eval
Flex :: Eval
data Alt
Alt :: ConstrTerm -> Expression -> Alt
data Binding
Binding :: Ident -> Expression -> Binding
instance GHC.Show.Show IL.Type.Module
instance GHC.Classes.Eq IL.Type.Module
instance GHC.Show.Show IL.Type.Decl
instance GHC.Classes.Eq IL.Type.Decl
instance GHC.Show.Show IL.Type.Alt
instance GHC.Classes.Eq IL.Type.Alt
instance GHC.Show.Show IL.Type.Expression
instance GHC.Classes.Eq IL.Type.Expression
instance GHC.Show.Show IL.Type.Binding
instance GHC.Classes.Eq IL.Type.Binding
instance GHC.Show.Show IL.Type.Eval
instance GHC.Classes.Eq IL.Type.Eval
instance GHC.Show.Show IL.Type.ConstrTerm
instance GHC.Classes.Eq IL.Type.ConstrTerm
instance GHC.Show.Show IL.Type.Literal
instance GHC.Classes.Eq IL.Type.Literal
instance GHC.Show.Show IL.Type.NewConstrDecl
instance GHC.Classes.Eq IL.Type.NewConstrDecl
instance GHC.Show.Show IL.Type.ConstrDecl
instance GHC.Classes.Eq IL.Type.ConstrDecl
instance GHC.Show.Show IL.Type.Type
instance GHC.Classes.Eq IL.Type.Type
instance GHC.Show.Show IL.Type.Kind
instance GHC.Classes.Ord IL.Type.Kind
instance GHC.Classes.Eq IL.Type.Kind
instance Base.Expr.Expr IL.Type.Expression
instance Base.Expr.Expr IL.Type.Alt


-- | This module implements a generic show function comparable to the one
--   obtained by <tt>deriving Show</tt>. However, the internal
--   representation of identifiers is hidden to avoid syntactic clutter.
module IL.ShowModule

-- | Show a IL module like by an devired <a>Show</a> instance
showModule :: Module -> String


-- | This module implements just another pretty printer, this time for the
--   intermediate language. It was mainly adapted from the Curry pretty
--   printer which, in turn, is based on Simon Marlow's pretty printer for
--   Haskell.
module IL.Pretty
ppModule :: Module -> Doc


-- | TODO
module IL.Typing
class Typeable a
typeOf :: Typeable a => a -> Type
instance IL.Typing.Typeable IL.Type.ConstrTerm
instance IL.Typing.Typeable IL.Type.Expression
instance IL.Typing.Typeable IL.Type.Alt


-- | This module is a simple re-export of the definition of the AST of IL
--   and the pretty-printing of IL modules.
module IL
ppModule :: Module -> Doc

-- | Show a IL module like by an devired <a>Show</a> instance
showModule :: Module -> String


-- | This module contains the generation of a type-annotated
--   <tt>FlatCurry</tt> program term for a given module in the intermediate
--   language.
module Generators.GenAnnotatedFlatCurry
genAnnotatedFlatCurry :: CompilerEnv -> Module Type -> Module -> AProg TypeExpr
instance Generators.GenAnnotatedFlatCurry.Normalize a => Generators.GenAnnotatedFlatCurry.Normalize [a]
instance Generators.GenAnnotatedFlatCurry.Normalize GHC.Types.Int
instance Generators.GenAnnotatedFlatCurry.Normalize Curry.FlatCurry.Type.TypeExpr
instance Generators.GenAnnotatedFlatCurry.Normalize a => Generators.GenAnnotatedFlatCurry.Normalize (Curry.FlatCurry.Annotated.Type.AFuncDecl a)
instance Generators.GenAnnotatedFlatCurry.Normalize a => Generators.GenAnnotatedFlatCurry.Normalize (Curry.FlatCurry.Annotated.Type.ARule a)
instance Generators.GenAnnotatedFlatCurry.Normalize a => Generators.GenAnnotatedFlatCurry.Normalize (Curry.FlatCurry.Annotated.Type.AExpr a)
instance Generators.GenAnnotatedFlatCurry.Normalize a => Generators.GenAnnotatedFlatCurry.Normalize (Curry.FlatCurry.Annotated.Type.ABranchExpr a)
instance Generators.GenAnnotatedFlatCurry.Normalize a => Generators.GenAnnotatedFlatCurry.Normalize (Curry.FlatCurry.Annotated.Type.APattern a)


-- | This module subsumes the different code generators.
module Generators

-- | Generate typed AbstractCurry
genTypedAbstractCurry :: CompilerEnv -> Module PredType -> CurryProg

-- | Generate untyped AbstractCurry
genUntypedAbstractCurry :: CompilerEnv -> Module PredType -> CurryProg

-- | Generate typed FlatCurry
genTypedFlatCurry :: AProg TypeExpr -> TProg

-- | Generate type-annotated FlatCurry
genAnnotatedFlatCurry :: CompilerEnv -> Module Type -> Module -> AProg TypeExpr

-- | Generate FlatCurry
genFlatCurry :: AProg TypeExpr -> Prog

-- | Generate a FlatCurry interface
genFlatInterface :: Prog -> Prog


-- | This module provides the function <a>importModules</a> to bring the
--   imported entities into the module's scope, and the function
--   <a>qualifyEnv</a> to qualify the environment prior to computing the
--   export interface.
module Imports

-- | The function <a>importInterfaces</a> brings the declarations of all
--   imported interfaces into scope for the current <a>Interface</a>.
importInterfaces :: Interface -> InterfaceEnv -> CompilerEnv
importModules :: Monad m => Module a -> InterfaceEnv -> [ImportDecl] -> CYT m CompilerEnv

qualifyEnv :: CompilerEnv -> CompilerEnv


-- | The compiler maintains a global environment holding all (directly or
--   indirectly) imported interface declarations for a module.
--   
--   This module contains a function to load *all* interface declarations
--   declared by the (directly or indirectly) imported modules, regardless
--   whether they are included by the import specification or not.
--   
--   The declarations are later brought into the scope of the module via
--   the function <tt>importModules</tt>, see module <a>Imports</a>.
--   
--   Interface files are updated by the Curry builder when necessary, see
--   module <a>CurryBuilder</a>.
module Interfaces

-- | Load the interfaces needed by a given module. This function returns an
--   <a>InterfaceEnv</a> containing the <a>Interface</a>s which were
--   successfully loaded.
loadInterfaces :: [FilePath] -> Module a -> CYIO InterfaceEnv

module Paths_curry_frontend
version :: Version
getBinDir :: IO FilePath
getLibDir :: IO FilePath
getDynLibDir :: IO FilePath
getDataDir :: IO FilePath
getLibexecDir :: IO FilePath
getDataFileName :: FilePath -> IO FilePath
getSysconfDir :: IO FilePath


-- | This module contains functions to obtain the version number and path
--   of the front end binary.
module Files.CymakePath

-- | Retrieve the location of the front end executable
getCymake :: IO String

-- | Show a greeting of the current front end
cymakeGreeting :: String

-- | Retrieve the version number of cymake
cymakeVersion :: String


-- | This module defines a function for writing the list of tokens and
--   spans of a Curry source module into a separate file.
module TokenStream

-- | Show a list of <a>Span</a> and <a>Token</a> tuples. The list is split
--   into one tuple on each line to increase readability.
showTokenStream :: [(Span, Token)] -> String

-- | Show a list of <a>Span</a> and <a>Token</a> tuples filtered by
--   CommentTokens. The list is split into one tuple on each line to
--   increase readability.
showCommentTokenStream :: [(Span, Token)] -> String


-- | After desugaring and lifting have been performed, the source code is
--   translated into the intermediate language. Besides translating from
--   source terms and expressions into intermediate language terms and
--   expressions, this phase in particular has to implement the pattern
--   matching algorithm for equations and case expressions.
--   
--   Because of name conflicts between the source and intermediate language
--   data structures, we can use only a qualified import for the
--   <tt>IL</tt> module.
module Transformations.CurryToIL
ilTrans :: Bool -> ValueEnv -> TCEnv -> Module Type -> Module
transType :: TCEnv -> Type -> Type
instance GHC.Show.Show Transformations.CurryToIL.NestedTerm


-- | TODO
module Transformations.Derive
derive :: TCEnv -> ValueEnv -> InstEnv -> OpPrecEnv -> Module PredType -> Module PredType


-- | The desugaring pass removes all syntactic sugar from the module. In
--   particular, the output of the desugarer will have the following
--   properties.
--   
--   <ul>
--   <li>No guarded right hand sides occur in equations, pattern
--   declarations, and case alternatives. In addition, the declaration
--   lists (`where`-blocks) of the right hand sides are empty; local
--   declarations are transformed into let expressions.</li>
--   <li>Patterns in equations and case alternatives are composed only
--   of</li>
--   <li>literals,</li>
--   <li>variables,</li>
--   <li>constructor applications, and</li>
--   <li>as patterns applied to literals or constructor applications.</li>
--   <li>Expressions are composed only of</li>
--   <li>literals,</li>
--   <li>variables,</li>
--   <li>constructors,</li>
--   <li>(binary) applications,</li>
--   <li>case expressions,</li>
--   <li>let expressions, and</li>
--   <li>expressions with a type signature.</li>
--   <li>Functional patterns are replaced by variables and are integrated
--   in a guarded right hand side using the (=:&lt;=) operator.</li>
--   <li>Records are transformed into ordinary data types by removing the
--   fields. Record construction and pattern matching are represented using
--   solely the record constructor. Record selections are represented using
--   selector functions which are generated for each record declaration,
--   and record updated are represented using case-expressions that perform
--   the update.</li>
--   <li>The type environment will be extended by new function declarations
--   for:</li>
--   <li>Record selections, and</li>
--   <li>Converted lambda expressions.</li>
--   </ul>
--   
--   As we are going to insert references to real prelude entities, all
--   names must be properly qualified before calling this module.
module Transformations.Desugar
desugar :: [KnownExtension] -> ValueEnv -> TCEnv -> Module PredType -> (Module PredType, ValueEnv)


-- | TODO
module Transformations.Dictionary
insertDicts :: Bool -> InterfaceEnv -> TCEnv -> ValueEnv -> ClassEnv -> InstEnv -> OpPrecEnv -> Module PredType -> (Module Type, InterfaceEnv, TCEnv, ValueEnv, OpPrecEnv)
dictTypeId :: QualIdent -> Ident
qDictTypeId :: QualIdent -> QualIdent
dictConstrId :: QualIdent -> Ident
qDictConstrId :: QualIdent -> QualIdent
defaultMethodId :: QualIdent -> Ident -> Ident
qDefaultMethodId :: QualIdent -> Ident -> QualIdent
superDictStubId :: QualIdent -> QualIdent -> Ident
qSuperDictStubId :: QualIdent -> QualIdent -> QualIdent
instFunId :: QualIdent -> Type -> Ident
qInstFunId :: ModuleIdent -> QualIdent -> Type -> QualIdent
implMethodId :: QualIdent -> Type -> Ident -> Ident
qImplMethodId :: ModuleIdent -> QualIdent -> Type -> Ident -> QualIdent
instance Transformations.Dictionary.Specialize Curry.Syntax.Type.Module
instance Transformations.Dictionary.Specialize Curry.Syntax.Type.Decl
instance Transformations.Dictionary.Specialize Curry.Syntax.Type.Equation
instance Transformations.Dictionary.Specialize Curry.Syntax.Type.Rhs
instance Transformations.Dictionary.Specialize Curry.Syntax.Type.Expression
instance Transformations.Dictionary.Specialize Curry.Syntax.Type.Alt
instance Transformations.Dictionary.DictTrans Curry.Syntax.Type.Module
instance Transformations.Dictionary.DictTrans Curry.Syntax.Type.Decl
instance Transformations.Dictionary.DictTrans Curry.Syntax.Type.Equation
instance Transformations.Dictionary.DictTrans Curry.Syntax.Type.Rhs
instance Transformations.Dictionary.DictTrans Curry.Syntax.Type.Pattern
instance Transformations.Dictionary.DictTrans Curry.Syntax.Type.Expression
instance Transformations.Dictionary.DictTrans Curry.Syntax.Type.Alt


-- | This module expands case branches with missing constructors.
--   
--   The MCC translates case expressions into the intermediate language
--   representation (IL) without completing them (i.e. without generating
--   case branches for missing contructors), because the intermediate
--   language supports variable patterns for the fallback case. In
--   contrast, the FlatCurry representation of patterns only allows literal
--   and constructor patterns, which requires the expansion default
--   branches to all missing constructors.
--   
--   This is only necessary for *rigid* case expressions, because any
--   *flexible* case expression with more than one branch and a variable
--   pattern is non-deterministic. In consequence, these overlapping
--   patterns have already been eliminated in the pattern matching
--   compilation process (see module CurryToIL).
--   
--   To summarize, this module expands all rigid case expressions.
module Transformations.CaseCompletion
completeCase :: InterfaceEnv -> TCEnv -> Module -> Module
instance Transformations.CaseCompletion.SubstType a => Transformations.CaseCompletion.SubstType [a]
instance Transformations.CaseCompletion.SubstType IL.Type.Type


-- | After desugaring and simplifying the code, the compiler lifts all
--   local function declarations to the top-level keeping only local
--   variable declarations. The algorithm used here is similar to
--   Johnsson's, consisting of two phases. First, we abstract each local
--   function declaration, adding its free variables as initial parameters
--   and update all calls to take these variables into account. Second, all
--   local function declarations are collected and lifted to the top-level.
module Transformations.Lift
lift :: ValueEnv -> Module Type -> (Module Type, ValueEnv)


-- | After inserting dictionaries, the compiler removes all occurences of
--   newtype declarations. Applications 'N x' in patterns and expressions,
--   where <tt>N</tt> is a newtype constructor, are replaced by a
--   <tt>x</tt>. The newtype declarations are replaced by type synonyms and
--   partial applications of newtype constructors are changed into calls to
--   <a>id</a>.
module Transformations.Newtypes
removeNewtypes :: Bool -> ValueEnv -> Module Type -> Module Type
instance Transformations.Newtypes.Newtypes a => Transformations.Newtypes.Newtypes [a]
instance GHC.Show.Show a => Transformations.Newtypes.Newtypes (Curry.Syntax.Type.Module a)
instance GHC.Show.Show a => Transformations.Newtypes.Newtypes (Curry.Syntax.Type.Decl a)
instance GHC.Show.Show a => Transformations.Newtypes.Newtypes (Curry.Syntax.Type.Equation a)
instance GHC.Show.Show a => Transformations.Newtypes.Newtypes (Curry.Syntax.Type.Lhs a)
instance GHC.Show.Show a => Transformations.Newtypes.Newtypes (Curry.Syntax.Type.Rhs a)
instance GHC.Show.Show a => Transformations.Newtypes.Newtypes (Curry.Syntax.Type.Pattern a)
instance GHC.Show.Show a => Transformations.Newtypes.Newtypes (Curry.Syntax.Type.Expression a)
instance GHC.Show.Show a => Transformations.Newtypes.Newtypes (Curry.Syntax.Type.Alt a)


-- | After checking the module and before starting the translation into the
--   intermediate language, the compiler properly qualifies all type
--   constructors, data constructors and (global) functions occurring in a
--   pattern or expression such that their module prefix matches the module
--   of their definition. This is done also for functions and constructors
--   declared in the current module. Only functions and variables declared
--   in local declarations groups as well as function arguments remain
--   unchanged.
module Transformations.Qual
qual :: ModuleIdent -> TCEnv -> ValueEnv -> Module a -> Module a


-- | After desugaring the source code, but before lifting local
--   declarations, the compiler performs a few simple optimizations to
--   improve the efficiency of the generated code. In addition, the
--   optimizer replaces pattern bindings with simple variable bindings and
--   selector functions.
--   
--   Currently, the following optimizations are implemented:
--   
--   <ul>
--   <li>Under certain conditions, inline local function definitions.</li>
--   <li>Remove unused declarations.</li>
--   <li>Compute minimal binding groups for let expressions.</li>
--   <li>Remove pattern bindings to constructor terms</li>
--   <li>Inline simple constants.</li>
--   </ul>
module Transformations.Simplify
simplify :: ValueEnv -> Module Type -> (Module Type, ValueEnv)


-- | This module subsumes the different transformations of the source code.
module Transformations

-- | Fully qualify used constructors and functions.
qual :: CompEnv (Module a) -> CompEnv (Module a)

-- | Automatically derive instances.
derive :: CompEnv (Module PredType) -> CompEnv (Module PredType)

-- | Remove any syntactic sugar, changes the value environment.
desugar :: CompEnv (Module PredType) -> CompEnv (Module PredType)

-- | Insert dictionaries, changes the type constructor and value
--   environments.
insertDicts :: Bool -> CompEnv (Module PredType) -> CompEnv (Module Type)

-- | Remove newtype constructors.
removeNewtypes :: Bool -> CompEnv (Module Type) -> CompEnv (Module Type)

-- | Simplify the source code, changes the value environment.
simplify :: CompEnv (Module Type) -> CompEnv (Module Type)

-- | Lift local declarations, changes the value environment.
lift :: CompEnv (Module Type) -> CompEnv (Module Type)

-- | Translate into the intermediate language
ilTrans :: Bool -> CompEnv (Module Type) -> CompEnv Module
transType :: TCEnv -> Type -> Type

-- | Add missing case branches
completeCase :: CompEnv Module -> CompEnv Module


-- | This module controls the compilation of modules.
module Modules
compileModule :: Options -> ModuleIdent -> FilePath -> CYIO ()
loadAndCheckModule :: Options -> ModuleIdent -> FilePath -> CYIO (CompEnv (Module PredType))
loadModule :: Options -> ModuleIdent -> FilePath -> CYIO (CompEnv (Module ()))
checkModule :: Options -> CompEnv (Module ()) -> CYIO (CompEnv (Module PredType))
parseModule :: Options -> ModuleIdent -> FilePath -> CYIO ([(Span, Token)], Module ())
checkModuleHeader :: Monad m => ModuleIdent -> FilePath -> Module () -> CYT m (Module ())


-- | This module contains functions to generate Curry representations for a
--   Curry source file including all imported modules.
module CurryBuilder

-- | Compile the Curry module in the given source file including all
--   imported modules w.r.t. the given <a>Options</a>.
buildCurry :: Options -> String -> CYIO ()

-- | Search for a compilation target identified by the given <a>String</a>.
findCurry :: Options -> String -> CYIO FilePath
