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


-- | Functions for manipulating Curry programs
--   
--   This package serves as a foundation for Curry compilers. It defines
--   the intermediate language formats FlatCurry. Additionally, it provides
--   functionality for the smooth integration of compiler frontends and
--   backends.
@package curry-base
@version 1.1.1


-- | 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 a list of existentially
--   quantified type variables, a context, 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 :: [CTVarIName] -> CContext -> QName -> CVisibility -> [CTypeExpr] -> CConsDecl
CRecord :: [CTVarIName] -> CContext -> 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 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


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

-- | Compiler message
data Message
Message :: Maybe Position -> Doc -> Message

-- | optional source code position
[msgPos] :: Message -> Maybe Position

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

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

-- | Construct a message from an entity with a <a>Position</a> and a text
posMessage :: HasPosition p => p -> 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
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.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 position and a <a>String</a>
--   indicating the cause of failure.
failMessageAt :: Monad m => Position -> 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 => Position -> 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 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 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 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


-- | 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>|?</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 <tt>$</tt>. 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 <tt>$</tt> 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><tt>Maybe</tt> <tt>Int</tt></tt> to a
--   <tt><tt>Maybe</tt> <tt>String</tt></tt> using <tt>show</tt>:
--   
--   <pre>
--   &gt;&gt;&gt; show &lt;$&gt; Nothing
--   Nothing
--   
--   &gt;&gt;&gt; show &lt;$&gt; Just 3
--   Just "3"
--   </pre>
--   
--   Convert from an <tt><tt>Either</tt> <tt>Int</tt> <tt>Int</tt></tt> to
--   an <tt><tt>Either</tt> <tt>Int</tt></tt> <tt>String</tt> using
--   <tt>show</tt>:
--   
--   <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 <tt>even</tt> 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 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
class HasPosition a => HasSpanInfo a
getSpanInfo :: HasSpanInfo a => a -> SpanInfo
setSpanInfo :: HasSpanInfo a => SpanInfo -> a -> a
updateEndPos :: HasSpanInfo a => a -> a
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.SpanInfo
instance GHC.Read.Read Curry.Base.SpanInfo.SpanInfo
instance GHC.Classes.Eq Curry.Base.SpanInfo.SpanInfo
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Base.SpanInfo.SpanInfo
instance Curry.Base.Position.HasPosition Curry.Base.SpanInfo.SpanInfo


-- | 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 ('()')
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 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

-- | <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 ('()')
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 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

-- | 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 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 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


-- | 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
currySubdir :: String

-- | Does the given <a>FilePath</a> contain the <a>currySubdir</a> as its
--   last directory component?
hasCurrySubdir :: FilePath -> Bool

-- | Add the <a>currySubdir</a> 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.
addCurrySubdir :: Bool -> FilePath -> FilePath

-- | Add the <a>currySubdir</a> 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.
addCurrySubdirModule :: Bool -> ModuleIdent -> FilePath -> FilePath

-- | Ensure that the <a>currySubdir</a> 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.
ensureCurrySubdir :: 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 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
typeAnnFlatName :: 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)

-- | 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

-- | 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 -> [TVarIndex] -> [ConsDecl] -> TypeDecl
TypeSyn :: QName -> Visibility -> [TVarIndex] -> TypeExpr -> 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 :: [TVarIndex] -> TypeExpr -> TypeExpr

-- | 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

-- | 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>,"if_then_else") [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.TypeExpr
instance GHC.Read.Read Curry.FlatCurry.Type.TypeExpr
instance GHC.Classes.Eq Curry.FlatCurry.Type.TypeExpr
instance GHC.Show.Show Curry.FlatCurry.Type.Visibility
instance GHC.Read.Read Curry.FlatCurry.Type.Visibility
instance GHC.Classes.Eq Curry.FlatCurry.Type.Visibility


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

-- | pretty-print a FlatCurry module
ppProg :: Prog -> Doc

-- | pretty-print the module header
ppHeader :: String -> [TypeDecl] -> [FuncDecl] -> Doc

-- | pretty-print the export list
ppExports :: [TypeDecl] -> [FuncDecl] -> Doc

-- | pretty-print an import statement
ppImport :: String -> Doc

-- | pretty-print a type declaration
ppTypeDecl :: TypeDecl -> Doc

-- | pretty-print a type expression
ppTypeExpr :: Int -> TypeExpr -> Doc

-- | pretty-print a function declaration
ppFuncDecl :: FuncDecl -> Doc

-- | pretty-print an expression
ppExpr :: Int -> Expr -> Doc

-- | pretty-print a literal
ppLiteral :: Literal -> Doc

-- | pretty-print a operator fixity declaration
ppOpDecl :: OpDecl -> Doc


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 -> [TVarIndex] -> [ConsDecl] -> a) -> (QName -> Visibility -> [TVarIndex] -> TypeExpr -> 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 -> [TVarIndex]

-- | 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) -> ([TVarIndex] -> [TVarIndex]) -> ([ConsDecl] -> [ConsDecl]) -> (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 [TVarIndex]

-- | 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

-- | 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) -> ([TVarIndex] -> 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 :: ([TVarIndex] -> 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

-- | 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 :: [TVarIndex] -> TypeExpr -> TypeExpr

-- | 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 -> [TVarIndex] -> [ConsDecl] -> TypeDecl
TypeSyn :: QName -> Visibility -> [TVarIndex] -> TypeExpr -> 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 Curry.FlatCurry.Typeable.Typeable a => Curry.FlatCurry.Typeable.Typeable (Curry.FlatCurry.Annotated.Type.AExpr a)
instance Curry.FlatCurry.Typeable.Typeable a => Curry.FlatCurry.Typeable.Typeable (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 ()


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 -> [TVarIndex] -> [ConsDecl] -> a) -> (QName -> Visibility -> [TVarIndex] -> TypeExpr -> 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 -> [TVarIndex]

-- | 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) -> ([TVarIndex] -> [TVarIndex]) -> ([ConsDecl] -> [ConsDecl]) -> (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 [TVarIndex]

-- | 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

-- | 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) -> ([TVarIndex] -> 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

-- | 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 :: [TVarIndex] -> TypeExpr -> TypeExpr

-- | 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 -> [TVarIndex] -> [ConsDecl] -> TypeDecl
TypeSyn :: QName -> Visibility -> [TVarIndex] -> TypeExpr -> 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 Curry.FlatCurry.Typeable.Typeable 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 Curry.FlatCurry.Typeable.Typeable 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 -> [TVarIndex] -> [ConsDecl] -> a) -> (QName -> Visibility -> [TVarIndex] -> TypeExpr -> 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 -> [TVarIndex]

-- | 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) -> ([TVarIndex] -> [TVarIndex]) -> ([ConsDecl] -> [ConsDecl]) -> (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 [TVarIndex]

-- | 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

-- | 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) -> ([TVarIndex] -> 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 :: Position -> KnownExtension -> Extension

-- | an unknown extension
UnknownExtension :: Position -> 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 Curry.Base.Position.HasPosition Curry.Syntax.Extension.Extension


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 -> [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 :: Position -> KnownExtension -> Extension

-- | an unknown extension
UnknownExtension :: Position -> 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 -> Context -> Ident -> Ident -> [Decl a] -> Decl a
InstanceDecl :: SpanInfo -> 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 -> Expression a -> [Decl a] -> Rhs a
GuardedRhs :: SpanInfo -> [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 -> [Decl a] -> Expression a -> Expression a
Do :: SpanInfo -> [Statement a] -> Expression a -> Expression a
IfThenElse :: SpanInfo -> Expression a -> Expression a -> Expression a -> Expression a
Case :: SpanInfo -> 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 -> [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 -> 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 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 GHC.Base.Functor Curry.Syntax.Type.Var
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 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 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 GHC.Base.Functor Curry.Syntax.Type.InfixOp
instance Curry.Base.Position.HasPosition (Curry.Syntax.Type.InfixOp a)
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.QualTypeExpr
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.QualTypeExpr
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.Constraint
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.Constraint
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.ConstrDecl
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.ConstrDecl
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.NewConstrDecl
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.NewConstrDecl
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.FieldDecl
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.FieldDecl
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.TypeExpr
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.TypeExpr
instance Curry.Base.Pretty.Pretty Curry.Syntax.Type.Infix
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.ImportDecl
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.ImportDecl
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.ImportSpec
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.ImportSpec
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.Import
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.Import
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.ExportSpec
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.ExportSpec
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.Export
instance Curry.Base.Position.HasPosition Curry.Syntax.Type.Export
instance Curry.Base.SpanInfo.HasSpanInfo Curry.Syntax.Type.ModulePragma
instance Curry.Base.Position.HasPosition 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>Extension</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
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 a module
ppModule :: Module a -> Doc

-- | Pretty print an interface
ppInterface :: Interface -> Doc

-- | Pretty print an interface declaration
ppIDecl :: IDecl -> Doc

-- | Pretty print a declaration
ppDecl :: Decl a -> Doc

-- | Pretty print an identifier
ppIdent :: Ident -> Doc

-- | Pretty print a constructor term
ppPattern :: Int -> Pattern a -> Doc

-- | Pretty print a record field pattern
ppFieldPatt :: Field (Pattern a) -> Doc

-- | Pretty print an expression
ppExpr :: Int -> Expression a -> Doc

-- | Pretty print an operator
ppOp :: InfixOp a -> Doc

-- | Pretty print a statement
ppStmt :: Statement a -> Doc

-- | Pretty print a record field expression (Haskell syntax)
ppFieldExpr :: Field (Expression a) -> Doc

-- | Pretty print a qualified type expression
ppQualTypeExpr :: QualTypeExpr -> Doc

-- | Pretty print a type expression
ppTypeExpr :: Int -> TypeExpr -> Doc
ppKindExpr :: Int -> KindExpr -> Doc

-- | Pretty print an alternative in a case expression
ppAlt :: Alt a -> Doc
ppQIdent :: QualIdent -> Doc
ppConstraint :: Constraint -> Doc
ppInstanceType :: InstanceType -> Doc
ppConstr :: ConstrDecl -> Doc
ppNewConstr :: NewConstrDecl -> Doc
ppFieldDecl :: FieldDecl -> Doc
ppEquation :: Equation a -> Doc
ppMIdent :: ModuleIdent -> Doc


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 a module
ppModule :: Module a -> Doc

-- | Pretty print an interface
ppInterface :: Interface -> Doc

-- | Pretty print an interface declaration
ppIDecl :: IDecl -> 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
