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


-- | Lexer, parser, type checker, etc. for the Curry language
--   
--   The Curry Frontend consists of the executable program
--   "curry-frontend". It is used by various backends to compile programs
--   written in the functional logic language Curry to various intermediate
--   representations.
--   
--   For further information, please check http://currry-language.org
@package curry-frontend
@version 0.4.2


-- | This module defines a function for writing the list of tokens and
--   spans of a Curry source module into a separate file.
module TokenStream

-- | Show a list of <a>Span</a> and <a>Token</a> tuples. The list is split
--   into one tuple on each line to increase readability.
showTokenStream :: [(Span, Token)] -> String


-- | This module contains functions to obtain the version number and path
--   of the cymake binary.
module Files.CymakePath

-- | Retrieve the location of the cymake executable
getCymake :: IO String

-- | Show a greeting of the current cymake
cymakeGreeting :: String

-- | Retrieve the version number of cymake
cymakeVersion :: String


-- | This module provides an environment for imported interfaces.
module Env.Interface

-- | Environment which maps the <a>ModuleIdent</a> of an imported module to
--   the corresponding <a>Interface</a>.
type InterfaceEnv = Map ModuleIdent Interface

-- | Initial <a>InterfaceEnv</a>.
initInterfaceEnv :: InterfaceEnv

-- | Lookup the <a>Interface</a> for an imported module.
lookupInterface :: ModuleIdent -> InterfaceEnv -> Maybe Interface


-- | This module provides an environment for resolving module aliases.
--   
--   For example, if module <tt>FiniteMap</tt> is imported via
--   
--   <pre>
--   import FiniteMap as FM
--   </pre>
--   
--   then <tt>FM</tt> is an alias for <tt>FiniteMap</tt>, and
--   <tt>FiniteMap</tt> is aliased by <tt>FM</tt>.
module Env.ModuleAlias

-- | Mapping from the original name of an imported module to its alias.
type AliasEnv = Map ModuleIdent ModuleIdent

-- | Initial alias environment
initAliasEnv :: AliasEnv

-- | Create an alias environment from a list of import declarations
importAliases :: [ImportDecl] -> AliasEnv


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


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

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

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

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

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

-- | Identity substitution
idSubst :: Subst a b

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

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

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

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

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

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

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

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


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

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


-- | This module defines data structures holding options for the
--   compilation of Curry programs, and utility functions for printing help
--   information as well as parsing the command line arguments.
module CompilerOpts

-- | Compiler options
data Options
Options :: CymakeMode -> Verbosity -> Bool -> [FilePath] -> [FilePath] -> Maybe FilePath -> Bool -> Bool -> PrepOpts -> WarnOpts -> [TargetType] -> [KnownExtension] -> DebugOpts -> Options

-- | modus operandi
[optMode] :: Options -> CymakeMode

-- | verbosity level compilation
[optVerbosity] :: Options -> Verbosity

-- | force (re-)compilation of target
[optForce] :: Options -> Bool

-- | directories to search in for libraries
[optLibraryPaths] :: Options -> [FilePath]

-- | directories to search in for imports
[optImportPaths] :: Options -> [FilePath]

-- | output directory for HTML
[optHtmlDir] :: Options -> Maybe FilePath

-- | use subdir for output?
[optUseSubdir] :: Options -> Bool

-- | create a FlatCurry interface file?
[optInterface] :: Options -> Bool

-- | preprocessor options
[optPrepOpts] :: Options -> PrepOpts

-- | warning options
[optWarnOpts] :: Options -> WarnOpts

-- | what to generate
[optTargetTypes] :: Options -> [TargetType]

-- | enabled language extensions
[optExtensions] :: Options -> [KnownExtension]

-- | debug options
[optDebugOpts] :: Options -> DebugOpts

-- | Preprocessor options
data PrepOpts
PrepOpts :: Bool -> String -> [String] -> PrepOpts

-- | apply custom preprocessor
[ppPreprocess] :: PrepOpts -> Bool

-- | preprocessor command
[ppCmd] :: PrepOpts -> String

-- | preprocessor options
[ppOpts] :: PrepOpts -> [String]

-- | Warning options
data WarnOpts
WarnOpts :: Bool -> [WarnFlag] -> Bool -> WarnOpts

-- | show warnings? (legacy option)
[wnWarn] :: WarnOpts -> Bool

-- | Warnings flags (see below)
[wnWarnFlags] :: WarnOpts -> [WarnFlag]

-- | Should warnings be treated as errors?
[wnWarnAsError] :: WarnOpts -> Bool

-- | Debug options
data DebugOpts
DebugOpts :: [DumpLevel] -> Bool -> Bool -> DebugOpts

-- | dump levels
[dbDumpLevels] :: DebugOpts -> [DumpLevel]

-- | dump compilation environment
[dbDumpEnv] :: DebugOpts -> Bool

-- | dump data structure
[dbDumpRaw] :: DebugOpts -> Bool

-- | Modus operandi of the program
data CymakeMode

-- | Show help information and exit
ModeHelp :: CymakeMode

-- | Show version and exit
ModeVersion :: CymakeMode

-- | Show numeric version, suitable for later processing
ModeNumericVersion :: CymakeMode

-- | Compile with dependencies
ModeMake :: CymakeMode

-- | Verbosity level
data Verbosity

-- | be quiet
VerbQuiet :: Verbosity

-- | show status of compilation
VerbStatus :: Verbosity

-- | Type of the target file
data TargetType

-- | Source code tokens
Tokens :: TargetType

-- | Parsed source code
Parsed :: TargetType

-- | FlatCurry
FlatCurry :: TargetType

-- | Extended FlatCurry
ExtendedFlatCurry :: TargetType

-- | AbstractCurry
AbstractCurry :: TargetType

-- | Untyped AbstractCurry
UntypedAbstractCurry :: TargetType

-- | HTML documentation
Html :: TargetType

-- | Warnings flags
data WarnFlag

-- | Warn for multiple imports
WarnMultipleImports :: WarnFlag

-- | Warn for disjoined function rules
WarnDisjoinedRules :: WarnFlag

-- | Warn for unused global bindings
WarnUnusedGlobalBindings :: WarnFlag

-- | Warn for unused local bindings
WarnUnusedBindings :: WarnFlag

-- | Warn for name shadowing
WarnNameShadowing :: WarnFlag

-- | Warn for overlapping rules/alternatives
WarnOverlapping :: WarnFlag

-- | Warn for incomplete pattern matching
WarnIncompletePatterns :: WarnFlag

-- | Warn for missing type signatures
WarnMissingSignatures :: WarnFlag

-- | Known language extensions of Curry.
data KnownExtension :: *

-- | anonymous free variables
AnonFreeVars :: KnownExtension

-- | functional patterns
FunctionalPatterns :: KnownExtension

-- | negative literals
NegativeLiterals :: KnownExtension

-- | no implicit import of the prelude
NoImplicitPrelude :: KnownExtension

-- | Dump level
data DumpLevel

-- | dump source code after parsing
DumpParsed :: DumpLevel

-- | dump source code after kind checking
DumpKindChecked :: DumpLevel

-- | dump source code after syntax checking
DumpSyntaxChecked :: DumpLevel

-- | dump source code after precedence checking
DumpPrecChecked :: DumpLevel

-- | dump source code after type checking
DumpTypeChecked :: DumpLevel

-- | dump source code after export checking
DumpExportChecked :: DumpLevel

-- | dump source after qualification
DumpQualified :: DumpLevel

-- | dump source after desugaring
DumpDesugared :: DumpLevel

-- | dump source after simplification
DumpSimplified :: DumpLevel

-- | dump source after lambda-lifting
DumpLifted :: DumpLevel

-- | dump IL code after translation
DumpTranslated :: DumpLevel

-- | dump IL code after case completion
DumpCaseCompleted :: DumpLevel

-- | dump FlatCurry code (pretty-printed)
DumpFlatCurry :: DumpLevel

-- | Description and flag of dump levels
dumpLevel :: [(DumpLevel, String, String)]

-- | Default compiler options
defaultOptions :: Options

-- | Default preprocessor options
defaultPrepOpts :: PrepOpts

-- | Default warning options
defaultWarnOpts :: WarnOpts

-- | Default dump options
defaultDebugOpts :: DebugOpts

-- | Retrieve the compiler <a>Options</a>
getCompilerOpts :: IO (String, Options, [String], [String])

-- | Update the <a>Options</a> record by the parsed and processed arguments
updateOpts :: Options -> [String] -> (Options, [String], [String])

-- | Print the usage information of the command line tool.
usage :: String -> String
instance GHC.Show.Show CompilerOpts.Options
instance GHC.Show.Show CompilerOpts.DebugOpts
instance GHC.Show.Show CompilerOpts.DumpLevel
instance GHC.Enum.Enum CompilerOpts.DumpLevel
instance GHC.Enum.Bounded CompilerOpts.DumpLevel
instance GHC.Classes.Eq CompilerOpts.DumpLevel
instance GHC.Show.Show CompilerOpts.WarnOpts
instance GHC.Show.Show CompilerOpts.WarnFlag
instance GHC.Enum.Enum CompilerOpts.WarnFlag
instance GHC.Enum.Bounded CompilerOpts.WarnFlag
instance GHC.Classes.Eq CompilerOpts.WarnFlag
instance GHC.Show.Show CompilerOpts.TargetType
instance GHC.Classes.Eq CompilerOpts.TargetType
instance GHC.Show.Show CompilerOpts.Verbosity
instance GHC.Classes.Ord CompilerOpts.Verbosity
instance GHC.Classes.Eq CompilerOpts.Verbosity
instance GHC.Show.Show CompilerOpts.CymakeMode
instance GHC.Classes.Eq CompilerOpts.CymakeMode
instance GHC.Show.Show CompilerOpts.PrepOpts


-- | This module modules provides the definitions for the internal
--   representation of types in the compiler.
module Base.Types
data Type
TypeVariable :: Int -> Type
TypeConstructor :: QualIdent -> [Type] -> Type
TypeArrow :: Type -> Type -> Type
TypeConstrained :: [Type] -> Int -> Type
TypeSkolem :: Int -> Type
isArrowType :: Type -> Bool
arrowArity :: Type -> Int
arrowArgs :: Type -> [Type]
arrowBase :: Type -> Type
arrowUnapply :: Type -> ([Type], Type)
typeVars :: Type -> [Int]
typeConstrs :: Type -> [QualIdent]
typeSkolems :: Type -> [Int]
equTypes :: Type -> Type -> Bool
qualifyType :: ModuleIdent -> Type -> Type
unqualifyType :: ModuleIdent -> Type -> Type
data DataConstr
DataConstr :: Ident -> Int -> [Type] -> DataConstr
RecordConstr :: Ident -> Int -> [Ident] -> [Type] -> DataConstr
constrIdent :: DataConstr -> Ident
constrTypes :: DataConstr -> [Type]
recLabels :: DataConstr -> [Ident]
recLabelTypes :: DataConstr -> [Type]
tupleData :: [DataConstr]
data TypeScheme
ForAll :: Int -> Type -> TypeScheme
data ExistTypeScheme
ForAllExist :: Int -> Int -> Type -> ExistTypeScheme
monoType :: Type -> TypeScheme
polyType :: Type -> TypeScheme
unitType :: Type
boolType :: Type
charType :: Type
intType :: Type
floatType :: Type
stringType :: Type
listType :: Type -> Type
ioType :: Type -> Type
tupleType :: [Type] -> Type
typeVar :: Int -> Type
predefTypes :: [(Type, [DataConstr])]
instance GHC.Show.Show Base.Types.ExistTypeScheme
instance GHC.Classes.Eq Base.Types.ExistTypeScheme
instance GHC.Show.Show Base.Types.TypeScheme
instance GHC.Classes.Eq Base.Types.TypeScheme
instance GHC.Show.Show Base.Types.DataConstr
instance GHC.Classes.Eq Base.Types.DataConstr
instance GHC.Show.Show Base.Types.Type
instance GHC.Classes.Eq Base.Types.Type


-- | This module defines several operations to construct and emit compiler
--   messages to the user.
module Base.Messages

-- | Monads in which <a>IO</a> computations may be embedded. Any monad
--   built by applying a sequence of monad transformers to the <a>IO</a>
--   monad will be an instance of this class.
--   
--   Instances should satisfy the following laws, which state that
--   <a>liftIO</a> is a transformer of monads:
--   
--   <ul>
--   <li><pre><a>liftIO</a> . <a>return</a> = <a>return</a></pre></li>
--   <li><pre><a>liftIO</a> (m &gt;&gt;= f) = <a>liftIO</a> m &gt;&gt;=
--   (<a>liftIO</a> . f)</pre></li>
--   </ul>
class Monad m => MonadIO (m :: * -> *)

-- | Lift a computation from the <a>IO</a> monad.
liftIO :: IO a -> m a

-- | Print a status message, depending on the current verbosity
status :: MonadIO m => Options -> String -> m ()

-- | Print a message on <a>stdout</a>
putMsg :: MonadIO m => String -> m ()

-- | Print an error message on <a>stderr</a>
putErrLn :: MonadIO m => String -> m ()

-- | Print a list of error messages on <a>stderr</a>
putErrsLn :: MonadIO m => [String] -> m ()

-- | Print a list of <a>String</a>s as error messages on <a>stderr</a> and
--   abort the program
abortWith :: [String] -> IO a

-- | Print a single error message on <a>stderr</a> and abort the program
abortWithMessage :: Message -> IO a

-- | Print a list of error messages on <a>stderr</a> and abort the program
abortWithMessages :: [Message] -> IO a

-- | Print a list of warning messages on <a>stderr</a> and abort the
--   program |if the -Werror option is set
warnOrAbort :: WarnOpts -> [Message] -> IO ()

-- | Raise an internal error
internalError :: String -> a

-- | Compiler message
data Message :: *

-- | Construct a <a>Message</a> without a <a>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


-- | The module <a>TopEnv</a> implements environments for qualified and
--   possibly ambiguous identifiers. An identifier is ambiguous if two
--   different entities are imported under the same name or if a local
--   definition uses the same name as an imported entity. Following an idea
--   presented in a paper by Diatchki, Jones and Hallgren (2002), an
--   identifier is associated with a list of entities in order to handle
--   ambiguous names properly.
--   
--   In general, two entities are considered equal if the names of their
--   original definitions match. However, in the case of algebraic data
--   types it is possible to hide some or all of their data constructors on
--   import and export, respectively. In this case we have to merge both
--   imports such that all data constructors which are visible through any
--   import path are visible in the current module. The class Entity is
--   used to handle this merge.
--   
--   The code in this module ensures that the list of entities returned by
--   the functions <a>lookupTopEnv</a> and <a>qualLookupTopEnv</a> contains
--   exactly one element for each imported entity regardless of how many
--   times and from which module(s) it was imported. Thus, the result of
--   these function is a list with exactly one element if and only if the
--   identifier is unambiguous. The module names associated with an
--   imported entity identify the modules from which the entity was
--   imported.
module Base.TopEnv

-- | Top level environment
newtype TopEnv a
TopEnv :: Map QualIdent [(Source, a)] -> TopEnv a
[topEnvMap] :: TopEnv a -> Map QualIdent [(Source, a)]
class Entity a where merge x y | origName x == origName y = Just x | otherwise = Nothing
origName :: Entity a => a -> QualIdent
merge :: Entity a => a -> a -> Maybe a

-- | Empty <a>TopEnv</a>
emptyTopEnv :: TopEnv a

-- | Insert an <a>Entity</a> into a <a>TopEnv</a> as a predefined
--   <a>Entity</a>
predefTopEnv :: QualIdent -> a -> TopEnv a -> TopEnv a

-- | Insert an <a>Entity</a> as unqualified into a <a>TopEnv</a>
importTopEnv :: Entity a => ModuleIdent -> Ident -> a -> TopEnv a -> TopEnv a

-- | Insert an <a>Entity</a> as qualified into a <a>TopEnv</a>
qualImportTopEnv :: Entity a => ModuleIdent -> Ident -> a -> TopEnv a -> TopEnv a
bindTopEnv :: Ident -> a -> TopEnv a -> TopEnv a
qualBindTopEnv :: QualIdent -> a -> TopEnv a -> TopEnv a
rebindTopEnv :: Ident -> a -> TopEnv a -> TopEnv a
qualRebindTopEnv :: QualIdent -> a -> TopEnv a -> TopEnv a
unbindTopEnv :: Ident -> TopEnv a -> TopEnv a
lookupTopEnv :: Ident -> TopEnv a -> [a]
qualLookupTopEnv :: QualIdent -> TopEnv a -> [a]
allImports :: TopEnv a -> [(QualIdent, a)]
moduleImports :: ModuleIdent -> TopEnv a -> [(Ident, a)]
localBindings :: TopEnv a -> [(Ident, a)]
allLocalBindings :: TopEnv a -> [(QualIdent, a)]
allEntities :: TopEnv a -> [a]
qualElemTopEnv :: QualIdent -> TopEnv a -> Bool
instance GHC.Show.Show a => GHC.Show.Show (Base.TopEnv.TopEnv a)
instance GHC.Show.Show Base.TopEnv.Source
instance GHC.Classes.Eq Base.TopEnv.Source
instance GHC.Base.Functor Base.TopEnv.TopEnv


-- | The <a>NestEnv</a> environment type extends top-level environments to
--   manage nested scopes. Local scopes allow only for a single,
--   unambiguous definition.
--   
--   As a matter of convenience, the module <a>TopEnv</a> is exported by
--   the module <a>NestEnv</a>. Thus, only the latter needs to be imported.
module Base.NestEnv
data NestEnv a
emptyEnv :: NestEnv a
bindNestEnv :: Ident -> a -> NestEnv a -> NestEnv a
qualBindNestEnv :: QualIdent -> a -> NestEnv a -> NestEnv a
lookupNestEnv :: Ident -> NestEnv a -> [a]
qualLookupNestEnv :: QualIdent -> NestEnv a -> [a]
rebindNestEnv :: Ident -> a -> NestEnv a -> NestEnv a
qualRebindNestEnv :: QualIdent -> a -> NestEnv a -> NestEnv a
unnestEnv :: NestEnv a -> NestEnv a
toplevelEnv :: NestEnv a -> TopEnv a
globalEnv :: TopEnv a -> NestEnv a
nestEnv :: NestEnv a -> NestEnv a
elemNestEnv :: Ident -> NestEnv a -> Bool
qualModifyNestEnv :: (a -> a) -> QualIdent -> NestEnv a -> NestEnv a
modifyNestEnv :: (a -> a) -> Ident -> NestEnv a -> NestEnv a
localNestEnv :: NestEnv a -> [(Ident, a)]
qualInLocalNestEnv :: QualIdent -> NestEnv a -> Bool
instance GHC.Show.Show a => GHC.Show.Show (Base.NestEnv.NestEnv a)
instance GHC.Base.Functor Base.NestEnv.NestEnv


-- | In order to parse infix expressions correctly, the compiler must know
--   the precedence and fixity of each operator. Operator precedences are
--   associated with entities and will be checked after renaming was
--   applied. Nevertheless, we need to save precedences for ambiguous names
--   in order to handle them correctly while computing the exported
--   interface of a module.
--   
--   If no fixity is assigned to an operator, it will be given the default
--   precedence 9 and assumed to be a left-associative operator.
--   
--   <i>Note:</i> this modified version uses Haskell type <a>Integer</a>
--   for representing the precedence. This change had to be done due to the
--   introduction of unlimited integer constants in the parser / lexer.
module Env.OpPrec

-- | Operator precedence.
data OpPrec
OpPrec :: Infix -> Precedence -> OpPrec

-- | Default operator declaration (associativity and precedence).
defaultP :: OpPrec

-- | Default operator associativity.
defaultAssoc :: Infix

-- | Default operator precedence.
defaultPrecedence :: Precedence
mkPrec :: Maybe Precedence -> Precedence

-- | Environment mapping identifiers to their operator precedence.
type OpPrecEnv = TopEnv PrecInfo

-- | Precedence information for an identifier.
data PrecInfo
PrecInfo :: QualIdent -> OpPrec -> PrecInfo

-- | Bind an operator precedence.
bindP :: ModuleIdent -> Ident -> OpPrec -> OpPrecEnv -> OpPrecEnv

-- | Lookup the operator precedence for an <a>Ident</a>.
lookupP :: Ident -> OpPrecEnv -> [PrecInfo]

-- | Lookup the operator precedence for an <a>QualIdent</a>.
qualLookupP :: QualIdent -> OpPrecEnv -> [PrecInfo]

-- | Initial <a>OpPrecEnv</a>.
initOpPrecEnv :: OpPrecEnv
instance GHC.Show.Show Env.OpPrec.PrecInfo
instance GHC.Classes.Eq Env.OpPrec.PrecInfo
instance GHC.Classes.Eq Env.OpPrec.OpPrec
instance GHC.Show.Show Env.OpPrec.OpPrec
instance Base.TopEnv.Entity Env.OpPrec.PrecInfo


-- | For all defined types the compiler must maintain kind information. At
--   present, Curry does not support type classes. Therefore its type
--   language is first order and the only information that must be recorded
--   is the arity of each type. For algebraic data types and renaming types
--   the compiler also records all data constructors belonging to that
--   type, for alias types the type expression to be expanded is saved. In
--   order to manage the import and export of types, the names of the
--   original definitions are also recorded. On import two types are
--   considered equal if their original names match.
--   
--   The information for a data constructor comprises the number of
--   existentially quantified type variables and the list of the argument
--   types. Note that renaming type constructors have only one type
--   argument.
--   
--   Importing and exporting algebraic data types and renaming types is
--   complicated by the fact that the constructors of the type may be
--   (partially) hidden in the interface. This facilitates the definition
--   of abstract data types. An abstract type is always represented as a
--   data type without constructors in the interface regardless of whether
--   it is defined as a data type or as a renaming type. When only some
--   constructors of a data type are hidden, those constructors are
--   replaced by underscores in the interface. Furthermore, if the
--   right-most constructors of a data type are hidden, they are not
--   exported at all in order to make the interface more stable against
--   changes which are private to the module.
module Env.TypeConstructor
type TCEnv = TopEnv TypeInfo
data TypeInfo
DataType :: QualIdent -> Int -> [DataConstr] -> TypeInfo
RenamingType :: QualIdent -> Int -> DataConstr -> TypeInfo
AliasType :: QualIdent -> Int -> Type -> TypeInfo
initTCEnv :: TCEnv
tcArity :: TypeInfo -> Int
bindTypeInfo :: (QualIdent -> Int -> a -> TypeInfo) -> ModuleIdent -> Ident -> [Ident] -> a -> TCEnv -> TCEnv
lookupTC :: Ident -> TCEnv -> [TypeInfo]
qualLookupTC :: QualIdent -> TCEnv -> [TypeInfo]
qualLookupTCUnique :: ModuleIdent -> QualIdent -> TCEnv -> [TypeInfo]
type TypeEnv = TopEnv TypeKind
data TypeKind
Data :: QualIdent -> [Ident] -> TypeKind
Alias :: QualIdent -> TypeKind
typeKind :: TypeInfo -> TypeKind
instance GHC.Show.Show Env.TypeConstructor.TypeKind
instance GHC.Classes.Eq Env.TypeConstructor.TypeKind
instance GHC.Show.Show Env.TypeConstructor.TypeInfo
instance Base.TopEnv.Entity Env.TypeConstructor.TypeInfo
instance Base.TopEnv.Entity Env.TypeConstructor.TypeKind


-- | This module provides the function <a>importCheck</a> to check and
--   expand the import specifications of all import declarations.
module Checks.ImportSyntaxCheck
importCheck :: Interface -> Maybe ImportSpec -> (Maybe ImportSpec, [Message])
instance GHC.Show.Show Checks.ImportSyntaxCheck.IValueInfo
instance GHC.Show.Show Checks.ImportSyntaxCheck.ITypeInfo
instance Base.TopEnv.Entity Checks.ImportSyntaxCheck.ITypeInfo
instance Base.TopEnv.Entity Checks.ImportSyntaxCheck.IValueInfo


-- | After the source file has been parsed and all modules have been
--   imported, the compiler first performs kind checking on all type
--   definitions and signatures. Because Curry currently does not support
--   type classes, kind checking is rather trivial. All types must be of
--   first order kind (*), i.e., all type constructor applications must be
--   saturated.
--   
--   During kind checking, this module will also disambiguate nullary type
--   constructors and type variables which -- in contrast to Haskell -- is
--   not possible on purely syntactic criteria. In addition it is checked
--   that all type constructors and type variables occurring on the right
--   hand side of a type declaration are actually defined and no identifier
--   is defined more than once.
module Checks.KindCheck
kindCheck :: TCEnv -> Module -> (Module, [Message])


-- | This module implements the functions to compute the dependency
--   information between Curry modules. This is used to create Makefile
--   dependencies and to update programs composed of multiple modules.
module CurryDeps

-- | Different types of source files
data Source

-- | A source file with pragmas and module imports
Source :: FilePath -> [ModulePragma] -> [ModuleIdent] -> Source

-- | An interface file
Interface :: FilePath -> Source

-- | An unknown file
Unknown :: Source

-- | Retrieve the dependencies of a source file in topological order and
--   possible errors during flattering
flatDeps :: Options -> FilePath -> CYIO [(ModuleIdent, Source)]

-- | Retrieve the dependencies of a source file as a <a>SourceEnv</a>
deps :: Options -> SourceEnv -> FilePath -> CYIO SourceEnv
flattenDeps :: SourceEnv -> ([(ModuleIdent, Source)], [Message])

-- | Retrieve the dependencies of a given source file
sourceDeps :: Options -> SourceEnv -> FilePath -> CYIO SourceEnv

-- | Retrieve the dependencies of a given module
moduleDeps :: Options -> SourceEnv -> FilePath -> Module -> CYIO SourceEnv
instance GHC.Show.Show CurryDeps.Source
instance GHC.Classes.Eq CurryDeps.Source


-- | This module arranges the tokens of the module into different code
--   categories for HTML presentation. The parsed and qualified module is
--   used to establish links between used identifiers and their
--   definitions.
--   
--   The fully qualified module is traversed to generate a list of code
--   elements. Code elements representing identifiers are distinguished by
--   their kind (type constructor, data constructor, function, (type)
--   variable). They include information about their usage (i.e.,
--   declaration, call etc.) and whether the identifier occurs fully
--   qualified in the source code or not. Initially, all identifier codes
--   are fully qualified.
--   
--   In a next step, the token stream of the given program and the code
--   list are traversed sequentially (see <a>encodeToks</a>). The
--   information in the token stream is used to:
--   
--   <ul>
--   <li>add code elements for newlines, spaces and pragmas</li>
--   <li>update the qualification information of identifiers in the code
--   list.</li>
--   </ul>
module Html.SyntaxColoring

-- | Type of codes which are distinguished for HTML output the boolean
--   flags indicate whether the corresponding identifier occurs qualified
--   in the source module
data Code
Keyword :: String -> Code
Space :: Int -> Code
NewLine :: Code
Pragma :: String -> Code
TypeCons :: TypeUsage -> Bool -> QualIdent -> Code
DataCons :: ConsUsage -> Bool -> QualIdent -> Code
Function :: FuncUsage -> Bool -> QualIdent -> Code
Identifier :: IdentUsage -> Bool -> QualIdent -> Code
ModuleName :: ModuleIdent -> Code
Commentary :: String -> Code
NumberCode :: String -> Code
StringCode :: String -> Code
CharCode :: String -> Code
Symbol :: String -> Code
data TypeUsage
TypeDeclare :: TypeUsage
TypeRefer :: TypeUsage
TypeExport :: TypeUsage
TypeImport :: TypeUsage
data ConsUsage
ConsDeclare :: ConsUsage
ConsPattern :: ConsUsage
ConsCall :: ConsUsage
ConsInfix :: ConsUsage
ConsExport :: ConsUsage
ConsImport :: ConsUsage
data IdentUsage
IdDeclare :: IdentUsage
IdRefer :: IdentUsage
IdUnknown :: IdentUsage
data FuncUsage
FuncDeclare :: FuncUsage
FuncTypeSig :: FuncUsage
FuncCall :: FuncUsage
FuncInfix :: FuncUsage
FuncExport :: FuncUsage
FuncImport :: FuncUsage
genProgram :: Module -> [(Position, Token)] -> [Code]
code2string :: Code -> String
getQualIdent :: Code -> Maybe QualIdent
instance GHC.Show.Show Html.SyntaxColoring.Code
instance GHC.Show.Show Html.SyntaxColoring.IdentUsage
instance GHC.Show.Show Html.SyntaxColoring.FuncUsage
instance GHC.Show.Show Html.SyntaxColoring.ConsUsage
instance GHC.Show.Show Html.SyntaxColoring.TypeUsage


-- | This module defines a function for generating HTML documentation pages
--   for Curry source modules.
module Html.CurryHtml

-- | Translate source file into HTML file with syntaxcoloring
source2html :: Options -> ModuleIdent -> [(Position, Token)] -> Module -> CYIO ()


-- | The compiler needs to compute the lists of free and bound variables
--   for various different entities. We will devote three type classes to
--   that purpose. The <a>QualExpr</a> class is expected to take into
--   account that it is possible to use a qualified name to refer to a
--   function defined in the current module and therefore <tt>M.x</tt> and
--   <tt>x</tt>, where <tt>M</tt> is the current module name, should be
--   considered the same name. However, note that this is correct only
--   after renaming all local definitions as <tt>M.x</tt> always denotes an
--   entity defined at the top-level.
module Base.Expr
class Expr e

-- | Free variables in an <a>Expr</a>
fv :: Expr e => e -> [Ident]
class QualExpr e

-- | Free qualified variables in an <a>Expr</a>
qfv :: QualExpr e => ModuleIdent -> e -> [Ident]
class QuantExpr e

-- | Bounded variables in an <a>Expr</a>
bv :: QuantExpr e => e -> [Ident]
instance Base.Expr.Expr e => Base.Expr.Expr [e]
instance Base.Expr.QualExpr e => Base.Expr.QualExpr [e]
instance Base.Expr.QuantExpr e => Base.Expr.QuantExpr [e]
instance Base.Expr.QualExpr Curry.Syntax.Type.Decl
instance Base.Expr.QuantExpr Curry.Syntax.Type.Decl
instance Base.Expr.QualExpr Curry.Syntax.Type.Equation
instance Base.Expr.QuantExpr Curry.Syntax.Type.Lhs
instance Base.Expr.QualExpr Curry.Syntax.Type.Lhs
instance Base.Expr.QualExpr Curry.Syntax.Type.Rhs
instance Base.Expr.QualExpr Curry.Syntax.Type.CondExpr
instance Base.Expr.QualExpr Curry.Syntax.Type.Expression
instance Base.Expr.QualExpr Curry.Syntax.Type.Statement
instance Base.Expr.QualExpr Curry.Syntax.Type.Alt
instance Base.Expr.QuantExpr a => Base.Expr.QuantExpr (Curry.Syntax.Type.Field a)
instance Base.Expr.QualExpr a => Base.Expr.QualExpr (Curry.Syntax.Type.Field a)
instance Base.Expr.QuantExpr Curry.Syntax.Type.Statement
instance Base.Expr.QualExpr Curry.Syntax.Type.InfixOp
instance Base.Expr.QuantExpr Curry.Syntax.Type.Pattern
instance Base.Expr.QualExpr Curry.Syntax.Type.Pattern
instance Base.Expr.Expr Curry.Syntax.Type.TypeExpr


-- | The parser does not know the relative precedences of infix operators
--   and therefore parses them as if they all associate to the right and
--   have the same precedence. After performing the definition checks, the
--   compiler is going to process the infix applications in the module and
--   rearrange infix applications according to the relative precedences of
--   the operators involved.
module Checks.PrecCheck
precCheck :: ModuleIdent -> OpPrecEnv -> [Decl] -> ([Decl], OpPrecEnv, [Message])


-- | Similar to Curry source files, some post-processing has to be applied
--   to parsed interface files. In particular, the compiler must
--   disambiguate nullary type constructors and type variables. In
--   addition, the compiler also checks that all type constructor
--   applications are saturated. Since interface files are closed -- i.e.,
--   they include declarations of all entities which are defined in other
--   modules -- the compiler can perform this check without reference to
--   the global environments.
module Checks.InterfaceSyntaxCheck
intfSyntaxCheck :: Interface -> (Interface, [Message])


-- | The compiler maintains a global environment holding all (directly or
--   indirectly) imported interface declarations for a module.
--   
--   This module contains a function to load *all* interface declarations
--   declared by the (directly or indirectly) imported modules, regardless
--   whether they are included by the import specification or not.
--   
--   The declarations are later brought into the scope of the module via
--   the function <tt>importModules</tt>, see module <a>Imports</a>.
--   
--   Interface files are updated by the Curry builder when necessary, see
--   module <a>CurryBuilder</a>.
module Interfaces

-- | Load the interfaces needed by a given module. This function returns an
--   <a>InterfaceEnv</a> containing the <a>Interface</a>s which were
--   successfully loaded.
loadInterfaces :: [FilePath] -> Module -> CYIO InterfaceEnv


-- | The module <tt>IL</tt> defines the intermediate language which will be
--   compiled into abstract machine code. The intermediate language removes
--   a lot of syntactic sugar from the Curry source language. Top-level
--   declarations are restricted to data type and function definitions. A
--   newtype definition serves mainly as a hint to the backend that it must
--   provide an auxiliary function for partial applications of the
--   constructor (Newtype constructors must not occur in patterns and may
--   be used in expressions only as partial applications.).
--   
--   Type declarations use a de-Bruijn indexing scheme (starting at 0) for
--   type variables. In the type of a function, all type variables are
--   numbered in the order of their occurence from left to right, i.e., a
--   type '(Int -&gt; b) -&gt; (a,b) -&gt; c -&gt; (a,c)' is translated
--   into the type (using integer numbers to denote the type variables)
--   '(Int -&gt; 0) -&gt; (1,0) -&gt; 2 -&gt; (1,2)'.
--   
--   Pattern matching in an equation is handled via flexible and rigid
--   <a>Case</a> expressions. Overlapping rules are translated with the
--   help of <a>Or</a> expressions. The intermediate language has three
--   kinds of binding expressions, <a>Exist</a> expressions introduce a new
--   logical variable, <a>Let</a> expression support a single non-recursive
--   variable binding, and <a>Letrec</a> expressions introduce multiple
--   variables with recursive initializer expressions. The intermediate
--   language explicitly distinguishes (local) variables and (global)
--   functions in expressions.
--   
--   Note: this modified version uses haskell type <a>Integer</a> instead
--   of <a>Int</a> for representing integer values. This provides an
--   unlimited range of integer constants in Curry programs.
module IL.Type
data Module
Module :: ModuleIdent -> [ModuleIdent] -> [Decl] -> Module
data Decl
DataDecl :: QualIdent -> Int -> [ConstrDecl [Type]] -> Decl
NewtypeDecl :: QualIdent -> Int -> (ConstrDecl Type) -> Decl
FunctionDecl :: QualIdent -> [Ident] -> Type -> Expression -> Decl
ExternalDecl :: QualIdent -> CallConv -> String -> Type -> Decl
data ConstrDecl a
ConstrDecl :: QualIdent -> a -> ConstrDecl a
data CallConv
Primitive :: CallConv
CCall :: CallConv
data Type
TypeConstructor :: QualIdent -> [Type] -> Type
TypeVariable :: Int -> Type
TypeArrow :: Type -> Type -> Type
data Literal
Char :: SrcRef -> Char -> Literal
Int :: SrcRef -> Integer -> Literal
Float :: SrcRef -> Double -> Literal
data ConstrTerm

-- | literal patterns
LiteralPattern :: Literal -> ConstrTerm

-- | constructors
ConstructorPattern :: QualIdent -> [Ident] -> ConstrTerm

-- | default
VariablePattern :: Ident -> ConstrTerm
data Expression

-- | literal constants
Literal :: Literal -> Expression

-- | variables
Variable :: Ident -> Expression

-- | functions
Function :: QualIdent -> Int -> Expression

-- | constructors
Constructor :: QualIdent -> Int -> Expression

-- | applications
Apply :: Expression -> Expression -> Expression

-- | case expressions
Case :: SrcRef -> Eval -> Expression -> [Alt] -> Expression

-- | non-deterministic or
Or :: Expression -> Expression -> Expression

-- | exist binding (introduction of a free variable)
Exist :: Ident -> Expression -> Expression

-- | let binding
Let :: Binding -> Expression -> Expression

-- | letrec binding
Letrec :: [Binding] -> Expression -> Expression

-- | typed expression
Typed :: Expression -> Type -> Expression
data Eval
Rigid :: Eval
Flex :: Eval
data Alt
Alt :: ConstrTerm -> Expression -> Alt
data Binding
Binding :: Ident -> Expression -> Binding
instance Data.Data.Data IL.Type.Module
instance GHC.Show.Show IL.Type.Module
instance GHC.Classes.Eq IL.Type.Module
instance Data.Data.Data IL.Type.Decl
instance GHC.Show.Show IL.Type.Decl
instance GHC.Classes.Eq IL.Type.Decl
instance Data.Data.Data IL.Type.Alt
instance GHC.Show.Show IL.Type.Alt
instance GHC.Classes.Eq IL.Type.Alt
instance Data.Data.Data IL.Type.Expression
instance GHC.Show.Show IL.Type.Expression
instance GHC.Classes.Eq IL.Type.Expression
instance Data.Data.Data IL.Type.Binding
instance GHC.Show.Show IL.Type.Binding
instance GHC.Classes.Eq IL.Type.Binding
instance Data.Data.Data IL.Type.Eval
instance GHC.Show.Show IL.Type.Eval
instance GHC.Classes.Eq IL.Type.Eval
instance Data.Data.Data IL.Type.ConstrTerm
instance GHC.Show.Show IL.Type.ConstrTerm
instance GHC.Classes.Eq IL.Type.ConstrTerm
instance Data.Data.Data IL.Type.Literal
instance GHC.Show.Show IL.Type.Literal
instance GHC.Classes.Eq IL.Type.Literal
instance Data.Data.Data IL.Type.Type
instance GHC.Show.Show IL.Type.Type
instance GHC.Classes.Eq IL.Type.Type
instance Data.Data.Data IL.Type.CallConv
instance GHC.Show.Show IL.Type.CallConv
instance GHC.Classes.Eq IL.Type.CallConv
instance Data.Data.Data a => Data.Data.Data (IL.Type.ConstrDecl a)
instance GHC.Show.Show a => GHC.Show.Show (IL.Type.ConstrDecl a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (IL.Type.ConstrDecl a)
instance Base.Expr.Expr IL.Type.Expression
instance Base.Expr.Expr IL.Type.Alt
instance Curry.Base.Position.SrcRefOf IL.Type.ConstrTerm
instance Curry.Base.Position.SrcRefOf IL.Type.Literal


-- | This module implements just another pretty printer, this time for the
--   intermediate language. It was mainly adapted from the Curry pretty
--   printer which, in turn, is based on Simon Marlow's pretty printer for
--   Haskell.
module IL.Pretty
ppModule :: Module -> Doc


-- | This module implements a generic show function comparable to the one
--   obtained by <tt>deriving Show</tt>. However, the internal
--   representation of identifiers is hidden to avoid syntactic clutter.
module IL.ShowModule
showModule :: Module -> String


-- | This module is a simple re-export of the definition of the AST of IL
--   and the pretty-printing of IL modules.
module IL
ppModule :: Module -> Doc
showModule :: Module -> String


-- | This module expands case branches with missing constructors.
--   
--   The MCC translates case expressions into the intermediate language
--   representation (IL) without completing them (i.e. without generating
--   case branches for missing contructors), because the intermediate
--   language supports variable patterns for the fallback case. In
--   contrast, the FlatCurry representation of patterns only allows literal
--   and constructor patterns, which requires the expansion default
--   branches to all missing constructors.
--   
--   This is only necessary for *rigid* case expressions, because any
--   *flexible* case expression with more than one branch and a variable
--   pattern is non-deterministic. In consequence, these overlapping
--   patterns have already been eliminated in the pattern matching
--   compilation process (see module CurryToIL).
--   
--   To summarize, this module expands all rigid case expressions.
module Transformations.CaseCompletion
completeCase :: InterfaceEnv -> Module -> Module


-- | The functions <a>toType</a>, <a>toTypes</a>, and <a>fromType</a>
--   convert Curry type expressions into types and vice versa. The
--   functions <a>qualifyType</a> and <a>unqualifyType</a> add and remove
--   module qualifiers in a type, respectively.
--   
--   When Curry type expression are converted with <a>toType</a> or
--   <a>toTypes</a>, type variables are assigned ascending indices in the
--   order of their occurrence. It is possible to pass a list of additional
--   type variables to both functions which are assigned indices before
--   those variables occurring in the type. This allows preserving the
--   order of type variables in the left hand side of a type declaration.
module Base.CurryTypes
toQualType :: ModuleIdent -> [Ident] -> TypeExpr -> Type
toQualTypes :: ModuleIdent -> [Ident] -> [TypeExpr] -> [Type]
toType :: [Ident] -> TypeExpr -> Type
toTypes :: [Ident] -> [TypeExpr] -> [Type]
fromQualType :: ModuleIdent -> Type -> TypeExpr
fromType :: Type -> TypeExpr
ppType :: ModuleIdent -> Type -> Doc
ppTypeScheme :: ModuleIdent -> TypeScheme -> Doc


-- | In order to test the type correctness of a module, the compiler needs
--   to determine the type of every data constructor, function and variable
--   in the module. For the purpose of type checking there is no need for
--   distinguishing between variables and functions. For all objects their
--   original names and their types are saved. In addition, the compiler
--   also saves the (optional) list of field labels for data and newtype
--   constructors. Data constructors and functions also contain arity
--   information. On import two values are considered equal if their
--   original names match.
module Env.Value
type ValueEnv = TopEnv ValueInfo
data ValueInfo

-- | Data constructor with original name, arity, list of record labels and
--   type
DataConstructor :: QualIdent -> Int -> [Ident] -> ExistTypeScheme -> ValueInfo

-- | Newtype constructor with original name, record label and type (arity
--   is always 1)
NewtypeConstructor :: QualIdent -> Ident -> ExistTypeScheme -> ValueInfo

-- | Value with original name, arity and type
Value :: QualIdent -> Int -> TypeScheme -> ValueInfo

-- | Record label with original name, list of constructors for which label
--   is valid field and type (arity is always 1)
Label :: QualIdent -> [QualIdent] -> TypeScheme -> ValueInfo
bindGlobalInfo :: (QualIdent -> a -> ValueInfo) -> ModuleIdent -> Ident -> a -> ValueEnv -> ValueEnv
bindFun :: ModuleIdent -> Ident -> Int -> TypeScheme -> ValueEnv -> ValueEnv
qualBindFun :: ModuleIdent -> Ident -> Int -> TypeScheme -> ValueEnv -> ValueEnv
rebindFun :: ModuleIdent -> Ident -> Int -> TypeScheme -> ValueEnv -> ValueEnv
unbindFun :: Ident -> ValueEnv -> ValueEnv
lookupValue :: Ident -> ValueEnv -> [ValueInfo]
qualLookupValue :: QualIdent -> ValueEnv -> [ValueInfo]
qualLookupValueUnique :: ModuleIdent -> QualIdent -> ValueEnv -> [ValueInfo]
initDCEnv :: ValueEnv

-- | Pretty-printing the types from the type environment
ppTypes :: ModuleIdent -> ValueEnv -> Doc
conType :: QualIdent -> ValueEnv -> ([Ident], ExistTypeScheme)
instance GHC.Show.Show Env.Value.ValueInfo
instance Base.TopEnv.Entity Env.Value.ValueInfo


-- | This module implements substitutions on types.
module Base.TypeSubst
type TypeSubst = Subst Int Type
class SubstType a
subst :: SubstType a => TypeSubst -> a -> a
bindVar :: Int -> Type -> TypeSubst -> TypeSubst
substVar :: TypeSubst -> Int -> Type
expandType :: TCEnv -> Type -> Type
expandAliasType :: [Type] -> Type -> Type
normalize :: Type -> Type

-- | Identity substitution
idSubst :: Subst a b

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

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

-- | Compose two substitutions
compose :: Ord v => Subst v e -> Subst v e -> Subst v e
instance Base.TypeSubst.SubstType Base.Types.Type
instance Base.TypeSubst.SubstType Base.Types.TypeScheme
instance Base.TypeSubst.SubstType Base.Types.ExistTypeScheme
instance Base.TypeSubst.SubstType Env.Value.ValueInfo
instance Base.TypeSubst.SubstType a => Base.TypeSubst.SubstType (Base.TopEnv.TopEnv a)


module Base.Typing
class Typeable a
typeOf :: Typeable a => ValueEnv -> a -> Type
instance Base.Typing.Typeable Base.Types.Type
instance Base.Typing.Typeable Curry.Base.Ident.Ident
instance Base.Typing.Typeable Curry.Syntax.Type.Pattern
instance Base.Typing.Typeable Curry.Syntax.Type.Expression
instance Base.Typing.Typeable Curry.Syntax.Type.Rhs


-- | This module implements a check and expansion of the export
--   specification. Any errors in the specification are reported, and if
--   there are no errors, the specification is expanded. The expansion does
--   the following: * If there is no export specification, a specification
--   exporting the entire module is generated. * Otherwise, (re)exports of
--   modules are replaced by an export of all respective entities. * The
--   export of a type with all constructors and fields is replaced by an
--   enumeration of all constructors and fields. * The export of types
--   without sub-entities is extended with an empty list of sub-entities.
module Checks.ExportCheck
exportCheck :: ModuleIdent -> AliasEnv -> TCEnv -> ValueEnv -> Maybe ExportSpec -> [Message]
expandExports :: ModuleIdent -> AliasEnv -> TCEnv -> ValueEnv -> Maybe ExportSpec -> ExportSpec


-- | After the type declarations have been checked, the compiler performs a
--   syntax check on the remaining declarations. This check disambiguates
--   nullary data constructors and variables which -- in contrast to
--   Haskell -- is not possible on purely syntactic criteria. In addition,
--   this pass checks for undefined as well as ambiguous variables and
--   constructors. In order to allow lifting of local definitions in later
--   phases, all local variables are renamed by adding a key identifying
--   their scope. Therefore, all variables defined in the same scope share
--   the same key so that multiple definitions can be recognized. Finally,
--   all (adjacent) equations of a function are merged into a single
--   definition.
module Checks.SyntaxCheck
syntaxCheck :: Options -> ValueEnv -> Module -> ((Module, [KnownExtension]), [Message])
instance GHC.Show.Show Checks.SyntaxCheck.RenameInfo
instance GHC.Classes.Eq Checks.SyntaxCheck.RenameInfo


-- | This module defines the compilation environment for a single module,
--   containing the information needed throughout the compilation process.
module CompilerEnv
type CompEnv a = (CompilerEnv, a)

-- | A compiler environment contains information about the module currently
--   compiled. The information is updated during the different stages of
--   compilation.
data CompilerEnv
CompilerEnv :: ModuleIdent -> FilePath -> [KnownExtension] -> [(Span, Token)] -> InterfaceEnv -> AliasEnv -> TCEnv -> ValueEnv -> OpPrecEnv -> CompilerEnv

-- | identifier of the module
[moduleIdent] :: CompilerEnv -> ModuleIdent

-- | <a>FilePath</a> of compilation target
[filePath] :: CompilerEnv -> FilePath

-- | enabled language extensions
[extensions] :: CompilerEnv -> [KnownExtension]

-- | token list of module
[tokens] :: CompilerEnv -> [(Span, Token)]

-- | declarations of imported interfaces
[interfaceEnv] :: CompilerEnv -> InterfaceEnv

-- | aliases for imported modules
[aliasEnv] :: CompilerEnv -> AliasEnv

-- | type constructors
[tyConsEnv] :: CompilerEnv -> TCEnv

-- | functions and data constructors
[valueEnv] :: CompilerEnv -> ValueEnv

-- | operator precedences
[opPrecEnv] :: CompilerEnv -> OpPrecEnv

-- | Initial <a>CompilerEnv</a>
initCompilerEnv :: ModuleIdent -> CompilerEnv

-- | Show the <a>CompilerEnv</a>
showCompilerEnv :: CompilerEnv -> String

-- | Pretty print a <tt>Map</tt>
ppMap :: (Show a, Show b) => Map a b -> Doc

-- | Pretty print an association list
ppAL :: (Show a, Show b) => [(a, b)] -> Doc


-- | After desugaring and simplifying the code, the compiler lifts all
--   local function declarations to the top-level keeping only local
--   variable declarations. The algorithm used here is similar to
--   Johnsson's, consisting of two phases. First, we abstract each local
--   function declaration, adding its free variables as initial parameters
--   and update all calls to take these variables into account. Second, all
--   local function declarations are collected and lifted to the top-level.
module Transformations.Lift
lift :: ValueEnv -> Module -> (Module, ValueEnv)


-- | After checking the module and before starting the translation into the
--   intermediate language, the compiler properly qualifies all type
--   constructors, data constructors and (global) functions occurring in a
--   pattern or expression such that their module prefix matches the module
--   of their definition. This is done also for functions and constructors
--   declared in the current module. Only functions and variables declared
--   in local declarations groups as well as function arguments remain
--   unchanged.
module Transformations.Qual
qual :: ModuleIdent -> TCEnv -> ValueEnv -> Module -> Module


-- | After desugaring the source code, but before lifting local
--   declarations, the compiler performs a few simple optimizations to
--   improve the efficiency of the generated code. In addition, the
--   optimizer replaces pattern bindings with simple variable bindings and
--   selector functions.
--   
--   Currently, the following optimizations are implemented:
--   
--   <ul>
--   <li>Under certain conditions, inline local function definitions.</li>
--   <li>Remove unused declarations.</li>
--   <li>Compute minimal binding groups for let expressions.</li>
--   <li>Remove pattern bindings to constructor terms</li>
--   <li>Inline simple constants.</li>
--   </ul>
module Transformations.Simplify
simplify :: ValueEnv -> Module -> (Module, ValueEnv)


-- | Interface files include declarations of all entities that are exported
--   by the module, but defined in another module. Since these declarations
--   can become inconsistent if client modules are not recompiled properly,
--   the compiler checks that all imported declarations in an interface
--   agree with their original definitions.
--   
--   One may ask why we include imported declarations at all, if the
--   compiler always has to compare those declarations with the original
--   definitions. The main reason for this is that it helps to avoid
--   unnecessary recompilations of client modules. As an example, consider
--   the three modules:
--   
--   module A where { data T = C } module B(T(..)) where { import A }
--   module C where { import B; f = C }
--   
--   where module B could be considered as a public interface of module A,
--   which restricts access to type A.T and its constructor C. The client
--   module C imports this type via the public interface B. If now module A
--   is changed by adding a definition of a new global function
--   
--   module A where { data T = C; f = C }
--   
--   module B must be recompiled because A's interface is changed. On the
--   other hand, module C need not be recompiled because the change in A
--   does not affect B's interface. By including the declaration of type
--   A.T in B's interface, the compiler can trivially check that B's
--   interface remains unchanged and therefore the client module C is not
--   recompiled.
--   
--   Another reason for including imported declarations in interfaces is
--   that the compiler in principle could avoid loading interfaces of
--   modules that are imported only indirectly, which would save processing
--   time and allow distributing binary packages of a library with a public
--   interface module only. However, this has not been implemented yet.
module Checks.InterfaceCheck
interfaceCheck :: OpPrecEnv -> TCEnv -> ValueEnv -> Interface -> [Message]


-- | This module implements the type checker of the Curry compiler. The
--   type checker is invoked after the syntactic correctness of the program
--   has been verified. Local variables have been renamed already. Thus the
--   compiler can maintain a flat type environment (which is necessary in
--   order to pass the type information to later phases of the compiler).
--   The type checker now checks the correct typing of all expressions and
--   also verifies that the type signatures given by the user match the
--   inferred types. The type checker uses the algorithm by Damas and
--   Milner (1982) for inferring the types of unannotated declarations, but
--   allows for polymorphic recursion when a type annotation is present.
module Checks.TypeCheck
typeCheck :: ModuleIdent -> TCEnv -> ValueEnv -> [Decl] -> (TCEnv, ValueEnv, [Message])


-- | This module searches for potentially irregular code and generates
--   warning messages.
module Checks.WarnCheck
warnCheck :: WarnOpts -> AliasEnv -> ValueEnv -> TCEnv -> Module -> [Message]
instance GHC.Show.Show Checks.WarnCheck.IdInfo


-- | This module subsumes the different checks to be performed on a Curry
--   module during compilation, e.g. type checking.
module Checks
type Check m a = Options -> CompEnv a -> CYT m (CompEnv a)
interfaceCheck :: Monad m => Check m Interface
importCheck :: Monad m => Interface -> Maybe ImportSpec -> CYT m (Maybe ImportSpec)

-- | Check the kinds of type definitions and signatures.
--   
--   <ul>
--   <li>Declarations: Nullary type constructors and type variables are
--   disambiguated</li>
--   <li>Environment: remains unchanged</li>
--   </ul>
kindCheck :: Monad m => Check m Module

-- | Check for a correct syntax.
--   
--   <ul>
--   <li>Declarations: Nullary data constructors and variables are
--   disambiguated, variables are renamed</li>
--   <li>Environment: remains unchanged</li>
--   </ul>
syntaxCheck :: Monad m => Check m Module

-- | Check the precedences of infix operators.
--   
--   <ul>
--   <li>Declarations: Expressions are reordered according to the specified
--   precedences</li>
--   <li>Environment: The operator precedence environment is updated</li>
--   </ul>
precCheck :: Monad m => Check m Module

-- | Apply the correct typing of the module. The declarations remain
--   unchanged; the type constructor and value environments are updated.
typeCheck :: Monad m => Check m Module

-- | Check the export specification
exportCheck :: Monad m => Check m Module

-- | Check the export specification
expandExports :: Monad m => Options -> CompEnv Module -> m (CompEnv Module)

-- | Check for warnings.
warnCheck :: Options -> CompilerEnv -> Module -> [Message]


-- | This module provides the computation of the exported interface of a
--   compiled module. The function <a>exportInterface</a> uses the expanded
--   export specifications and the corresponding environments in order to
--   compute the interface of the module.
module Exports
exportInterface :: CompilerEnv -> Module -> Interface


-- | This module contains the generation of an <tt>AbstractCurry</tt>
--   program term for a given <tt>Curry</tt> module.
module Generators.GenAbstractCurry

-- | Generate an AbstractCurry program term from the syntax tree when uacy
--   flag is set untype AbstractCurry is generated
genAbstractCurry :: Bool -> CompilerEnv -> Module -> CurryProg
instance GHC.Show.Show Generators.GenAbstractCurry.AbstractEnv


-- | This module provides the function <a>importModules</a> to bring the
--   imported entities into the module's scope, and the function
--   <a>qualifyEnv</a> to qualify the environment prior to computing the
--   export interface.
module Imports

-- | The function <a>importInterfaces</a> brings the declarations of all
--   imported interfaces into scope for the current <a>Interface</a>.
importInterfaces :: Interface -> InterfaceEnv -> CompilerEnv
importModules :: Monad m => Module -> InterfaceEnv -> [ImportDecl] -> CYT m CompilerEnv
qualifyEnv :: CompilerEnv -> CompilerEnv


-- | After desugaring and lifting have been performed, the source code is
--   translated into the intermediate language. Besides translating from
--   source terms and expressions into intermediate language terms and
--   expressions, this phase in particular has to implement the pattern
--   matching algorithm for equations and case expressions.
--   
--   Because of name conflicts between the source and intermediate language
--   data structures, we can use only a qualified import for the
--   <tt>IL</tt> module.
module Transformations.CurryToIL
ilTrans :: ValueEnv -> Module -> Module
transType :: Type -> Type
instance GHC.Show.Show Transformations.CurryToIL.NestedTerm


-- | The desugaring pass removes all syntactic sugar from the module. In
--   particular, the output of the desugarer will have the following
--   properties.
--   
--   <ul>
--   <li>No guarded right hand sides occur in equations, pattern
--   declarations, and case alternatives. In addition, the declaration
--   lists (`where`-blocks) of the right hand sides are empty; local
--   declarations are transformed into let expressions.</li>
--   <li>Patterns in equations and case alternatives are composed only
--   of</li>
--   <li>literals,</li>
--   <li>variables,</li>
--   <li>constructor applications, and</li>
--   <li>as patterns applied to literals or constructor applications.</li>
--   <li>Expressions are composed only of</li>
--   <li>literals,</li>
--   <li>variables,</li>
--   <li>constructors,</li>
--   <li>(binary) applications,</li>
--   <li>case expressions,</li>
--   <li>let expressions, and</li>
--   <li>expressions with a type signature.</li>
--   <li>Applications 'N x' in patterns and expressions, where <tt>N</tt>
--   is a newtype constructor, are replaced by a <tt>x</tt>. Note that
--   neither the newtype declaration itself nor partial applications of
--   newtype constructors are changed. It were possible to replace partial
--   applications of newtype constructor by <a>id</a>. However, our
--   solution yields a more accurate output when the result of a
--   computation includes partial applications.</li>
--   <li>Functional patterns are replaced by variables and are integrated
--   in a guarded right hand side using the (=:&lt;=) operator.</li>
--   <li>Records are transformed into ordinary data types by removing the
--   fields. Record construction and pattern matching are represented using
--   solely the record constructor. Record selections are represented using
--   selector functions which are generated for each record declaration,
--   and record updated are represented using case-expressions that perform
--   the update.</li>
--   <li>The type environment will be extended by new function declarations
--   for:</li>
--   <li>Record selections, and</li>
--   <li>Converted lambda expressions.</li>
--   </ul>
--   
--   As we are going to insert references to real prelude entities, all
--   names must be properly qualified before calling this module.
module Transformations.Desugar
desugar :: [KnownExtension] -> ValueEnv -> TCEnv -> Module -> (Module, ValueEnv)


-- | This module subsumes the different transformations of the source code.
module Transformations

-- | Fully qualify used constructors and functions.
qual :: CompEnv Module -> CompEnv Module

-- | Remove any syntactic sugar, changes the value environment.
desugar :: CompEnv Module -> CompEnv Module

-- | Simplify the source code, changes the value environment.
simplify :: CompEnv Module -> CompEnv Module

-- | Lift local declarations, changes the value environment.
lift :: CompEnv Module -> CompEnv Module

-- | Translate into the intermediate language
ilTrans :: CompEnv Module -> CompEnv Module

-- | Translate a type into its representation in the intermediate language
transType :: Type -> Type

-- | Add missing case branches
completeCase :: CompEnv Module -> CompEnv Module


-- | This module contains the generation of a <tt>FlatCurry</tt> program
--   term for a given module in the intermediate language, and the
--   generation of a <tt>FlatCurry</tt> interface for a given
--   <tt>Curry</tt> interface.
module Generators.GenFlatCurry
genFlatCurry :: CompilerEnv -> Module -> Module -> Prog
genFlatInterface :: CompilerEnv -> Interface -> Module -> Module -> Prog


-- | This module subsumes the different code generators.
module Generators

-- | Generate typed AbstractCurry
genTypedAbstractCurry :: CompilerEnv -> Module -> CurryProg

-- | Generate untyped AbstractCurry
genUntypedAbstractCurry :: CompilerEnv -> Module -> CurryProg

-- | Generate FlatCurry
genFlatCurry :: CompilerEnv -> Module -> Module -> Prog

-- | Generate a FlatCurry interface
genFlatInterface :: CompilerEnv -> Interface -> Module -> Module -> Prog


-- | This module controls the compilation of modules.
module Modules
compileModule :: Options -> ModuleIdent -> FilePath -> CYIO ()
loadAndCheckModule :: Options -> ModuleIdent -> FilePath -> CYIO (CompEnv Module)
loadModule :: Options -> ModuleIdent -> FilePath -> CYIO (CompEnv Module)
checkModule :: Options -> CompEnv Module -> CYIO (CompEnv Module)
parseModule :: Options -> ModuleIdent -> FilePath -> CYIO ([(Span, Token)], Module)
checkModuleHeader :: Monad m => Options -> ModuleIdent -> FilePath -> Module -> CYT m Module


-- | This module contains functions to generate Curry representations for a
--   Curry source file including all imported modules.
module CurryBuilder

-- | Compile the Curry module in the given source file including all
--   imported modules w.r.t. the given <a>Options</a>.
buildCurry :: Options -> String -> CYIO ()

-- | Search for a compilation target identified by the given <a>String</a>.
findCurry :: Options -> String -> CYIO FilePath
