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


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


-- | 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 the generation of a <tt>FlatCurry</tt> program
--   term or a <tt>FlatCurry</tt> interface out of an 'Annotated FlatCurry'
--   module.
module Generators.GenFlatCurry
genFlatCurry :: AProg a -> Prog
genFlatInterface :: Prog -> Prog


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

-- | Retrieve the location of the front end executable
getCymake :: IO String

-- | Show a greeting of the current front end
cymakeGreeting :: String

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


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


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

-- | case mode
[optCaseMode] :: Options -> CaseMode

-- | C preprocessor options
[optCppOpts] :: Options -> CppOpts

-- | C preprocessor options
data CppOpts
CppOpts :: Bool -> Map String Int -> CppOpts

-- | run C preprocessor
[cppRun] :: CppOpts -> Bool

-- | defintions for the C preprocessor
[cppDefinitions] :: CppOpts -> Map String Int

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

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

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

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

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

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

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

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

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

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

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

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

-- | dump all bindings instead of just the local bindings
[dbDumpAllBindings] :: DebugOpts -> Bool

-- | print more readable environments
[dbDumpSimple] :: DebugOpts -> Bool
data CaseMode
CaseModeFree :: CaseMode
CaseModeHaskell :: CaseMode
CaseModeProlog :: CaseMode
CaseModeGoedel :: CaseMode

-- | Modus operandi of the program
data CymakeMode

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

-- | Show version and exit
ModeVersion :: CymakeMode

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

-- | Compile with dependencies
ModeMake :: CymakeMode

-- | Verbosity level
data Verbosity

-- | be quiet
VerbQuiet :: Verbosity

-- | show status of compilation
VerbStatus :: Verbosity

-- | Type of the target file
data TargetType

-- | Source code tokens
Tokens :: TargetType

-- | Parsed source code
Parsed :: TargetType

-- | FlatCurry
FlatCurry :: TargetType

-- | Typed FlatCurry
TypedFlatCurry :: 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

-- | Warn for missing method implementations
WarnMissingMethods :: WarnFlag

-- | Warn for orphan instances
WarnOrphanInstances :: WarnFlag
WarnIrregularCaseMode :: WarnFlag

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

-- | anonymous free variables
AnonFreeVars :: KnownExtension

-- | C preprocessor
CPP :: KnownExtension

-- | existential quantification
ExistentialQuantification :: KnownExtension

-- | functional patterns
FunctionalPatterns :: KnownExtension

-- | negative literals
NegativeLiterals :: KnownExtension

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

-- | Dump level
data DumpLevel

-- | dump source code after conditional compiling
DumpCondCompiled :: DumpLevel

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

-- | dump source code after extension checking
DumpExtensionChecked :: DumpLevel

-- | dump source code after type syntax checking
DumpTypeSyntaxChecked :: DumpLevel

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

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

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

-- | dump source code after derive checking
DumpDeriveChecked :: DumpLevel

-- | dump source code after instance checking
DumpInstanceChecked :: DumpLevel

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

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

-- | dump source code after qualification
DumpQualified :: DumpLevel

-- | dump source code after deriving
DumpDerived :: DumpLevel

-- | dump source code after desugaring
DumpDesugared :: DumpLevel

-- | dump source code after dictionary transformation
DumpDictionaries :: DumpLevel

-- | dump source code after removing newtype constructors
DumpNewtypes :: DumpLevel

-- | dump source code after simplification
DumpSimplified :: DumpLevel

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

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

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

-- | dump typed FlatCurry code
DumpTypedFlatCurry :: DumpLevel

-- | dump FlatCurry code
DumpFlatCurry :: DumpLevel

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

-- | Default compiler options
defaultOptions :: Options

-- | Default preprocessor options
defaultPrepOpts :: PrepOpts

-- | Default warning options
defaultWarnOpts :: WarnOpts

-- | Default dump options
defaultDebugOpts :: DebugOpts

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

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

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


-- | TODO
module CondCompile
condCompile :: CppOpts -> FilePath -> String -> CYIO String


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


-- | 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 b, GHC.Show.Show a) => 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 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 :: MonadIO m => IO a -> m a

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

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

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

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

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

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

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

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

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

-- | Compiler message
data Message :: *

-- | Construct a <a>Message</a> without a <a>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
qualUnbindTopEnv :: QualIdent -> TopEnv a -> TopEnv a
lookupTopEnv :: Ident -> TopEnv a -> [a]
qualLookupTopEnv :: QualIdent -> TopEnv a -> [a]
qualElemTopEnv :: QualIdent -> TopEnv a -> Bool
allImports :: TopEnv a -> [(QualIdent, a)]
moduleImports :: ModuleIdent -> TopEnv a -> [(Ident, a)]
localBindings :: TopEnv a -> [(Ident, a)]
allLocalBindings :: TopEnv a -> [(QualIdent, a)]
allBindings :: TopEnv a -> [(QualIdent, a)]
allEntities :: TopEnv a -> [a]
instance GHC.Show.Show a => GHC.Show.Show (Base.TopEnv.TopEnv a)
instance GHC.Show.Show Base.TopEnv.Source
instance GHC.Classes.Eq Base.TopEnv.Source
instance GHC.Base.Functor Base.TopEnv.TopEnv


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


-- | 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 Curry.Base.Pretty.Pretty Env.OpPrec.OpPrec
instance Base.TopEnv.Entity Env.OpPrec.PrecInfo
instance Curry.Base.Pretty.Pretty Env.OpPrec.PrecInfo


-- | First of all, the compiler scans a source file for file-header pragmas
--   that may activate language extensions.
module Checks.ExtensionCheck
extensionCheck :: Options -> Module a -> ([KnownExtension], [Message])


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


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

-- | Different types of source files
data Source

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

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

-- | An unknown file
Unknown :: Source

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

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

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

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


-- | The compiler maintains information about all type classes in an
--   environment that maps type classes to a list of their direct
--   superclasses and all their associated class methods with an additional
--   boolean flag stating whether an default implementation has been
--   provided or not. For both the type class identifier and the list of
--   super classes original names are used. Thus, the use of a flat
--   environment is sufficient.
module Env.Class
type ClassEnv = Map QualIdent ClassInfo
initClassEnv :: ClassEnv
type ClassInfo = ([QualIdent], [(Ident, Bool)])
bindClassInfo :: QualIdent -> ClassInfo -> ClassEnv -> ClassEnv
mergeClassInfo :: ClassInfo -> ClassInfo -> ClassInfo
lookupClassInfo :: QualIdent -> ClassEnv -> Maybe ClassInfo
superClasses :: QualIdent -> ClassEnv -> [QualIdent]
allSuperClasses :: QualIdent -> ClassEnv -> [QualIdent]
classMethods :: QualIdent -> ClassEnv -> [Ident]
hasDefaultImpl :: QualIdent -> Ident -> ClassEnv -> Bool


-- | This module modules provides the definitions for the internal
--   representation of types in the compiler along with some helper
--   functions.
module Base.Types
data Type
TypeConstructor :: QualIdent -> Type
TypeVariable :: Int -> Type
TypeConstrained :: [Type] -> Int -> Type
TypeSkolem :: Int -> Type
TypeApply :: Type -> Type -> Type
TypeArrow :: Type -> Type -> Type
TypeForall :: [Int] -> Type -> Type
applyType :: Type -> [Type] -> Type
unapplyType :: Bool -> Type -> (Type, [Type])
rootOfType :: Type -> QualIdent
isArrowType :: Type -> Bool
arrowArity :: Type -> Int
arrowArgs :: Type -> [Type]
arrowBase :: Type -> Type
arrowUnapply :: Type -> ([Type], Type)
class IsType t
typeVars :: IsType t => t -> [Int]
typeSkolems :: IsType t => t -> [Int]
typeConstrs :: Type -> [QualIdent]
qualifyType :: ModuleIdent -> Type -> Type
unqualifyType :: ModuleIdent -> Type -> Type
qualifyTC :: ModuleIdent -> QualIdent -> QualIdent
data Pred
Pred :: QualIdent -> Type -> Pred
qualifyPred :: ModuleIdent -> Pred -> Pred
unqualifyPred :: ModuleIdent -> Pred -> Pred
type PredSet = Set Pred
emptyPredSet :: PredSet
partitionPredSet :: PredSet -> (PredSet, PredSet)
minPredSet :: ClassEnv -> PredSet -> PredSet
maxPredSet :: ClassEnv -> PredSet -> PredSet
qualifyPredSet :: ModuleIdent -> PredSet -> PredSet
unqualifyPredSet :: ModuleIdent -> PredSet -> PredSet
data PredType
PredType :: PredSet -> Type -> PredType
predType :: Type -> PredType
unpredType :: PredType -> Type
qualifyPredType :: ModuleIdent -> PredType -> PredType
unqualifyPredType :: ModuleIdent -> PredType -> PredType
data DataConstr
DataConstr :: Ident -> Int -> PredSet -> [Type] -> DataConstr
RecordConstr :: Ident -> Int -> PredSet -> [Ident] -> [Type] -> DataConstr
constrIdent :: DataConstr -> Ident
constrTypes :: DataConstr -> [Type]
recLabels :: DataConstr -> [Ident]
recLabelTypes :: DataConstr -> [Type]
tupleData :: [DataConstr]
data ClassMethod
ClassMethod :: Ident -> (Maybe Int) -> PredType -> ClassMethod
methodName :: ClassMethod -> Ident
methodArity :: ClassMethod -> Maybe Int
methodType :: ClassMethod -> PredType
data TypeScheme
ForAll :: Int -> PredType -> TypeScheme
data ExistTypeScheme
ForAllExist :: Int -> Int -> PredType -> ExistTypeScheme
monoType :: Type -> TypeScheme
polyType :: Type -> TypeScheme
typeScheme :: PredType -> TypeScheme
rawType :: TypeScheme -> Type
arrowType :: Type -> Type -> Type
unitType :: Type
predUnitType :: PredType
boolType :: Type
predBoolType :: PredType
charType :: Type
intType :: Type
predIntType :: PredType
floatType :: Type
predFloatType :: PredType
stringType :: Type
predStringType :: PredType
listType :: Type -> Type
consType :: Type -> Type
ioType :: Type -> Type
tupleType :: [Type] -> Type
numTypes :: [Type]
fractionalTypes :: [Type]
predefTypes :: [(Type, [DataConstr])]
instance GHC.Show.Show Base.Types.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.ClassMethod
instance GHC.Classes.Eq Base.Types.ClassMethod
instance GHC.Show.Show Base.Types.DataConstr
instance GHC.Classes.Eq Base.Types.DataConstr
instance GHC.Show.Show Base.Types.PredType
instance GHC.Classes.Eq Base.Types.PredType
instance GHC.Show.Show Base.Types.Pred
instance GHC.Classes.Eq Base.Types.Pred
instance GHC.Show.Show Base.Types.Type
instance GHC.Classes.Ord Base.Types.Type
instance GHC.Classes.Eq Base.Types.Type
instance Base.Types.IsType Base.Types.Type
instance GHC.Classes.Ord Base.Types.Pred
instance Base.Types.IsType Base.Types.Pred
instance (Base.Types.IsType a, GHC.Classes.Ord a) => Base.Types.IsType (Data.Set.Base.Set a)
instance Base.Types.IsType Base.Types.PredType
instance Base.Types.IsType Base.Types.TypeScheme
instance Base.Types.IsType Base.Types.ExistTypeScheme


-- | The compiler maintains information about defined instances in an
--   environment that maps pairs of type classes and type constructors to
--   the name of the module where the instance is declared, the context as
--   given in the instance declaration, and a list of the class methods
--   implemented in the specific instance along with their arity. A flat
--   environment is sufficient because instances are visible globally and
--   cannot be hidden. Instances are recorded only with the original names
--   of the type class and type constructor involved.
module Env.Instance
type InstIdent = (QualIdent, QualIdent)
ppInstIdent :: InstIdent -> Doc
type InstInfo = (ModuleIdent, PredSet, [(Ident, Int)])
type InstEnv = Map InstIdent InstInfo
initInstEnv :: InstEnv
bindInstInfo :: InstIdent -> InstInfo -> InstEnv -> InstEnv
lookupInstInfo :: InstIdent -> InstEnv -> Maybe InstInfo


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

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


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

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


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

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

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

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

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

-- | The function <a>isSimpleKind</a> returns whether a kind is simple or
--   not.
isSimpleKind :: Kind -> Bool
instance GHC.Show.Show Base.Kinds.Kind
instance GHC.Classes.Eq Base.Kinds.Kind


-- | 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 a)
instance Base.Expr.QuantExpr (Curry.Syntax.Type.Decl a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.Equation a)
instance Base.Expr.QuantExpr (Curry.Syntax.Type.Lhs a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.Lhs a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.Rhs a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.CondExpr a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.Expression a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.Statement a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.Alt a)
instance Base.Expr.QuantExpr (Curry.Syntax.Type.Var a)
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 a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.InfixOp a)
instance Base.Expr.QuantExpr (Curry.Syntax.Type.Pattern a)
instance Base.Expr.QualExpr (Curry.Syntax.Type.Pattern a)
instance Base.Expr.Expr Curry.Syntax.Type.Constraint
instance Base.Expr.QuantExpr Curry.Syntax.Type.Constraint
instance Base.Expr.Expr Curry.Syntax.Type.QualTypeExpr
instance Base.Expr.QuantExpr Curry.Syntax.Type.QualTypeExpr
instance Base.Expr.Expr Curry.Syntax.Type.TypeExpr
instance Base.Expr.QuantExpr 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 a] -> ([Decl a], OpPrecEnv, [Message])


-- | 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] -> Decl
ExternalDataDecl :: QualIdent -> Int -> Decl
FunctionDecl :: QualIdent -> [(Type, Ident)] -> Type -> Expression -> Decl
ExternalDecl :: QualIdent -> Type -> Decl
data ConstrDecl
ConstrDecl :: QualIdent -> [Type] -> ConstrDecl
data Type
TypeConstructor :: QualIdent -> [Type] -> Type
TypeVariable :: Int -> Type
TypeArrow :: Type -> Type -> Type
TypeForall :: [Int] -> Type -> Type
data Literal
Char :: Char -> Literal
Int :: Integer -> Literal
Float :: Double -> Literal
data ConstrTerm

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

-- | constructors
ConstructorPattern :: Type -> QualIdent -> [(Type, Ident)] -> ConstrTerm

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

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

-- | variables
Variable :: Type -> Ident -> Expression

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

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

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

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

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

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

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

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

-- | typed expression
Typed :: Expression -> Type -> Expression
data Eval
Rigid :: Eval
Flex :: Eval
data Alt
Alt :: ConstrTerm -> Expression -> Alt
data Binding
Binding :: Ident -> Expression -> Binding
instance GHC.Show.Show IL.Type.Module
instance GHC.Classes.Eq IL.Type.Module
instance GHC.Show.Show IL.Type.Decl
instance GHC.Classes.Eq IL.Type.Decl
instance GHC.Show.Show IL.Type.Alt
instance GHC.Classes.Eq IL.Type.Alt
instance GHC.Show.Show IL.Type.Expression
instance GHC.Classes.Eq IL.Type.Expression
instance GHC.Show.Show IL.Type.Binding
instance GHC.Classes.Eq IL.Type.Binding
instance GHC.Show.Show IL.Type.Eval
instance GHC.Classes.Eq IL.Type.Eval
instance GHC.Show.Show IL.Type.ConstrTerm
instance GHC.Classes.Eq IL.Type.ConstrTerm
instance GHC.Show.Show IL.Type.Literal
instance GHC.Classes.Eq IL.Type.Literal
instance GHC.Show.Show IL.Type.ConstrDecl
instance GHC.Classes.Eq IL.Type.ConstrDecl
instance GHC.Show.Show IL.Type.Type
instance GHC.Classes.Eq IL.Type.Type
instance Base.Expr.Expr IL.Type.Expression
instance Base.Expr.Expr IL.Type.Alt


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

-- | Show a IL module like by an devired <a>Show</a> instance
showModule :: Module -> String


-- | TODO
module IL.Typing
class Typeable a
typeOf :: Typeable a => a -> Type
instance IL.Typing.Typeable IL.Type.ConstrTerm
instance IL.Typing.Typeable IL.Type.Expression
instance IL.Typing.Typeable IL.Type.Alt


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

-- | Show a IL module like by an devired <a>Show</a> instance
showModule :: Module -> String


-- | The functions <a>toType</a>, <a>toTypes</a>, and <a>fromType</a>
--   convert Curry type expressions into types and vice versa. The
--   functions <a>qualifyType</a> and <a>unqualifyType</a> add and remove
--   module qualifiers in a type, respectively.
--   
--   When Curry type expression are converted with <a>toType</a> or
--   <a>toTypes</a>, type variables are assigned ascending indices in the
--   order of their occurrence. It is possible to pass a list of additional
--   type variables to both functions which are assigned indices before
--   those variables occurring in the type. This allows preserving the
--   order of type variables in the left hand side of a type declaration.
module Base.CurryTypes
toType :: [Ident] -> TypeExpr -> Type
toTypes :: [Ident] -> [TypeExpr] -> [Type]
toQualType :: ModuleIdent -> [Ident] -> TypeExpr -> Type
toQualTypes :: ModuleIdent -> [Ident] -> [TypeExpr] -> [Type]
toPred :: [Ident] -> Constraint -> Pred
toQualPred :: ModuleIdent -> [Ident] -> Constraint -> Pred
toPredSet :: [Ident] -> Context -> PredSet
toQualPredSet :: ModuleIdent -> [Ident] -> Context -> PredSet
toPredType :: [Ident] -> QualTypeExpr -> PredType
toQualPredType :: ModuleIdent -> [Ident] -> QualTypeExpr -> PredType
toConstrType :: QualIdent -> [Ident] -> Context -> [TypeExpr] -> PredType
toMethodType :: QualIdent -> Ident -> QualTypeExpr -> PredType
fromType :: [Ident] -> Type -> TypeExpr
fromQualType :: ModuleIdent -> [Ident] -> Type -> TypeExpr
fromPred :: [Ident] -> Pred -> Constraint
fromQualPred :: ModuleIdent -> [Ident] -> Pred -> Constraint
fromPredSet :: [Ident] -> PredSet -> Context
fromQualPredSet :: ModuleIdent -> [Ident] -> PredSet -> Context
fromPredType :: [Ident] -> PredType -> QualTypeExpr
fromQualPredType :: ModuleIdent -> [Ident] -> PredType -> QualTypeExpr
ppType :: ModuleIdent -> Type -> Doc
ppPred :: ModuleIdent -> Pred -> Doc
ppPredType :: ModuleIdent -> PredType -> Doc
ppTypeScheme :: ModuleIdent -> TypeScheme -> Doc


-- | TODO
module Base.PrettyTypes
instance Curry.Base.Pretty.Pretty Base.Types.Type
instance Curry.Base.Pretty.Pretty Base.Types.Pred
instance Curry.Base.Pretty.Pretty a => Curry.Base.Pretty.Pretty (Data.Set.Base.Set a)
instance Curry.Base.Pretty.Pretty Base.Types.PredType
instance Curry.Base.Pretty.Pretty Base.Types.DataConstr
instance Curry.Base.Pretty.Pretty Base.Types.ClassMethod
instance Curry.Base.Pretty.Pretty Base.Types.TypeScheme
instance Curry.Base.Pretty.Pretty Base.Types.ExistTypeScheme


-- | 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, class method flag, arity and type
Value :: QualIdent -> Bool -> 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 -> Bool -> Int -> TypeScheme -> ValueEnv -> ValueEnv
qualBindFun :: ModuleIdent -> Ident -> Bool -> Int -> TypeScheme -> ValueEnv -> ValueEnv
rebindFun :: ModuleIdent -> Ident -> Bool -> Int -> TypeScheme -> ValueEnv -> ValueEnv
unbindFun :: Ident -> ValueEnv -> ValueEnv
lookupValue :: Ident -> ValueEnv -> [ValueInfo]
qualLookupValue :: QualIdent -> ValueEnv -> [ValueInfo]
qualLookupValueUnique :: ModuleIdent -> QualIdent -> ValueEnv -> [ValueInfo]
initDCEnv :: ValueEnv
class ValueType t
toValueType :: ValueType t => Type -> t
fromValueType :: ValueType t => t -> PredType
bindLocalVars :: ValueType t => [(Ident, Int, t)] -> ValueEnv -> ValueEnv
bindLocalVar :: ValueType t => (Ident, Int, t) -> ValueEnv -> ValueEnv
instance GHC.Show.Show Env.Value.ValueInfo
instance Base.TopEnv.Entity Env.Value.ValueInfo
instance Curry.Base.Pretty.Pretty Env.Value.ValueInfo
instance Env.Value.ValueType Base.Types.Type
instance Env.Value.ValueType Base.Types.PredType


-- | 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
subst' :: TypeSubst -> Type -> [Type] -> Type
class ExpandAliasType a
expandAliasType :: ExpandAliasType a => [Type] -> a -> a
expandAliasType' :: [Type] -> Type -> [Type] -> Type
normalize :: Int -> PredType -> PredType
instanceType :: ExpandAliasType a => Type -> a -> a

-- | Identity substitution
idSubst :: Subst a b

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

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

-- | Compose two substitutions
compose :: Ord v => Subst v e -> Subst v e -> Subst v e
instance (GHC.Classes.Ord a, Base.TypeSubst.SubstType a) => Base.TypeSubst.SubstType (Data.Set.Base.Set a)
instance Base.TypeSubst.SubstType a => Base.TypeSubst.SubstType [a]
instance Base.TypeSubst.SubstType Base.Types.Type
instance Base.TypeSubst.SubstType Base.Types.Pred
instance Base.TypeSubst.SubstType Base.Types.PredType
instance Base.TypeSubst.SubstType Base.Types.TypeScheme
instance Base.TypeSubst.SubstType Base.Types.ExistTypeScheme
instance Base.TypeSubst.SubstType Env.Value.ValueInfo
instance Base.TypeSubst.SubstType a => Base.TypeSubst.SubstType (Base.TopEnv.TopEnv a)
instance Base.TypeSubst.ExpandAliasType a => Base.TypeSubst.ExpandAliasType [a]
instance (GHC.Classes.Ord a, Base.TypeSubst.ExpandAliasType a) => Base.TypeSubst.ExpandAliasType (Data.Set.Base.Set a)
instance Base.TypeSubst.ExpandAliasType Base.Types.Type
instance Base.TypeSubst.ExpandAliasType Base.Types.Pred
instance Base.TypeSubst.ExpandAliasType Base.Types.PredType


-- | After the compiler has attributed patterns and expressions with type
--   information during type inference, it is straightforward to recompute
--   the type of every pattern and expression. Since all annotated types
--   are monomorphic, there is no need to instantiate any variables or
--   perform any (non-trivial) unifications.
module Base.Typing
class Typeable a
typeOf :: Typeable a => a -> Type
withType :: (Functor f, Typeable (f Type)) => Type -> f Type -> f Type
matchType :: Type -> Type -> TypeSubst -> TypeSubst
bindDecls :: (Eq t, Typeable t, ValueType t) => [Decl t] -> ValueEnv -> ValueEnv
bindDecl :: (Eq t, Typeable t, ValueType t) => Decl t -> ValueEnv -> ValueEnv
bindPatterns :: (Eq t, Typeable t, ValueType t) => [Pattern t] -> ValueEnv -> ValueEnv
bindPattern :: (Eq t, Typeable t, ValueType t) => Pattern t -> ValueEnv -> ValueEnv
declVars :: (Eq t, Typeable t, ValueType t) => Decl t -> [(Ident, Int, t)]
patternVars :: (Eq t, Typeable t, ValueType t) => Pattern t -> [(Ident, Int, t)]
instance Base.Typing.Typeable Base.Types.Type
instance Base.Typing.Typeable Base.Types.PredType
instance Base.Typing.Typeable a => Base.Typing.Typeable (Curry.Syntax.Type.Rhs a)
instance Base.Typing.Typeable a => Base.Typing.Typeable (Curry.Syntax.Type.Pattern a)
instance Base.Typing.Typeable a => Base.Typing.Typeable (Curry.Syntax.Type.Expression a)
instance Base.Typing.Typeable a => Base.Typing.Typeable (Curry.Syntax.Type.Alt a)


-- | After inserting dictionaries, the compiler removes all occurences of
--   newtype declarations. Applications 'N x' in patterns and expressions,
--   where <tt>N</tt> is a newtype constructor, are replaced by a
--   <tt>x</tt>. The newtype declarations are replaced by type synonyms and
--   partial applications of newtype constructors are changed into calls to
--   <a>id</a>.
module Transformations.Newtypes
removeNewtypes :: ValueEnv -> Module Type -> Module Type
instance Transformations.Newtypes.Newtypes a => Transformations.Newtypes.Newtypes [a]
instance GHC.Show.Show a => Transformations.Newtypes.Newtypes (Curry.Syntax.Type.Module a)
instance GHC.Show.Show a => Transformations.Newtypes.Newtypes (Curry.Syntax.Type.Decl a)
instance GHC.Show.Show a => Transformations.Newtypes.Newtypes (Curry.Syntax.Type.Equation a)
instance GHC.Show.Show a => Transformations.Newtypes.Newtypes (Curry.Syntax.Type.Lhs a)
instance GHC.Show.Show a => Transformations.Newtypes.Newtypes (Curry.Syntax.Type.Rhs a)
instance GHC.Show.Show a => Transformations.Newtypes.Newtypes (Curry.Syntax.Type.Pattern a)
instance GHC.Show.Show a => Transformations.Newtypes.Newtypes (Curry.Syntax.Type.Expression a)
instance GHC.Show.Show a => Transformations.Newtypes.Newtypes (Curry.Syntax.Type.Alt a)


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


-- | 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 Type -> Module
transType :: Type -> Type
instance GHC.Show.Show Transformations.CurryToIL.NestedTerm


-- | The functions <tt>tokind</tt> and <a>fromKind</a> convert Curry kind
--   expressions into kinds and vice versa.
--   
--   When Curry kinds are converted with <a>fromKind</a>, kind variables
--   are instantiated with the kind *.
module Base.CurryKinds
toKind :: KindExpr -> Kind
toKind' :: Maybe KindExpr -> Int -> Kind
fromKind :: Kind -> KindExpr
fromKind' :: Kind -> Int -> Maybe KindExpr
ppKind :: Kind -> Doc


-- | TODO
module Base.PrettyKinds
instance Curry.Base.Pretty.Pretty Base.Kinds.Kind


-- | For all defined types the compiler must maintain kind information. For
--   algebraic data types and renaming types the compiler also records all
--   data constructors belonging to that type, for alias types the type
--   expression to be expanded is saved. Futhermore, recording the arity is
--   necessary for alias types because the right hand side, i.e., the type
--   expression, can have arbitrary kind and therefore the type alias'
--   arity cannot be determined from its own kind. For instance, the type
--   alias type List = [] has the kind * -&gt; *, but its arity is 0. In
--   order to manage the import and export of types, the names of the
--   original definitions are also recorded. On import two types are
--   considered equal if their original names match.
--   
--   The information for a data constructor comprises the number of
--   existentially quantified type variables, the context and the list of
--   the argument types. Note that renaming type constructors have only one
--   type argument.
--   
--   For type classes the all their methods are saved. Type classes are
--   recorded in the type constructor environment because type constructors
--   and type classes share a common name space.
--   
--   For type variables only their kind is recorded in the environment.
--   
--   Importing and exporting algebraic data types and renaming types is
--   complicated by the fact that the constructors of the type may be
--   (partially) hidden in the interface. This facilitates the definition
--   of abstract data types. An abstract type is always represented as a
--   data type without constructors in the interface regardless of whether
--   it is defined as a data type or as a renaming type. When only some
--   constructors of a data type are hidden, those constructors are
--   replaced by underscores in the interface. Furthermore, if the
--   right-most constructors of a data type are hidden, they are not
--   exported at all in order to make the interface more stable against
--   changes which are private to the module.
module Env.TypeConstructor
data TypeInfo
DataType :: QualIdent -> Kind -> [DataConstr] -> TypeInfo
RenamingType :: QualIdent -> Kind -> DataConstr -> TypeInfo
AliasType :: QualIdent -> Kind -> Int -> Type -> TypeInfo
TypeClass :: QualIdent -> Kind -> [ClassMethod] -> TypeInfo
TypeVar :: Kind -> TypeInfo
tcKind :: ModuleIdent -> QualIdent -> TCEnv -> Kind
clsKind :: ModuleIdent -> QualIdent -> TCEnv -> Kind
varKind :: Ident -> TCEnv -> Kind
clsMethods :: ModuleIdent -> QualIdent -> TCEnv -> [Ident]
type TCEnv = TopEnv TypeInfo
initTCEnv :: TCEnv
bindTypeInfo :: ModuleIdent -> Ident -> TypeInfo -> TCEnv -> TCEnv
rebindTypeInfo :: ModuleIdent -> Ident -> TypeInfo -> TCEnv -> TCEnv
lookupTypeInfo :: Ident -> TCEnv -> [TypeInfo]
qualLookupTypeInfo :: QualIdent -> TCEnv -> [TypeInfo]
qualLookupTypeInfoUnique :: ModuleIdent -> QualIdent -> TCEnv -> [TypeInfo]
getOrigName :: ModuleIdent -> QualIdent -> TCEnv -> QualIdent
reverseLookupByOrigName :: QualIdent -> TCEnv -> [QualIdent]
instance GHC.Show.Show Env.TypeConstructor.TypeInfo
instance Base.TopEnv.Entity Env.TypeConstructor.TypeInfo
instance Curry.Base.Pretty.Pretty Env.TypeConstructor.TypeInfo


-- | This module implements substitutions on kinds.
module Base.KindSubst
type KindSubst = Subst Int Kind
class SubstKind a
subst :: SubstKind a => KindSubst -> a -> a
bindVar :: Int -> Kind -> KindSubst -> KindSubst
substVar :: KindSubst -> Int -> Kind

-- | Identity substitution
idSubst :: Subst a b

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

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

-- | Compose two substitutions
compose :: Ord v => Subst v e -> Subst v e -> Subst v e
instance Base.KindSubst.SubstKind Base.Kinds.Kind
instance Base.KindSubst.SubstKind Env.TypeConstructor.TypeInfo
instance Base.KindSubst.SubstKind a => Base.KindSubst.SubstKind (Base.TopEnv.TopEnv a)


-- | This module implements expansion of alias types in types and
--   predicates.
module Base.TypeExpansion
expandType :: ModuleIdent -> TCEnv -> Type -> Type
expandType' :: ModuleIdent -> TCEnv -> Type -> [Type] -> Type
expandPred :: ModuleIdent -> TCEnv -> Pred -> Pred
expandPredSet :: ModuleIdent -> TCEnv -> ClassEnv -> PredSet -> PredSet
expandPredType :: ModuleIdent -> TCEnv -> ClassEnv -> PredType -> PredType
expandMonoType :: ModuleIdent -> TCEnv -> [Ident] -> TypeExpr -> Type
expandPolyType :: ModuleIdent -> TCEnv -> ClassEnv -> QualTypeExpr -> PredType
expandConstrType :: ModuleIdent -> TCEnv -> ClassEnv -> QualIdent -> [Ident] -> Context -> [TypeExpr] -> PredType
expandMethodType :: ModuleIdent -> TCEnv -> ClassEnv -> QualIdent -> Ident -> QualTypeExpr -> PredType


-- | Before entering derived instances into the instance environment, the
--   compiler has to ensure that it is not asked for other instances than
--   those of supported type classes.
module Checks.DeriveCheck
deriveCheck :: TCEnv -> Module a -> [Message]


-- | This module implements 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


-- | Before type checking, the compiler checks for every instance
--   declaration that all necessary super class instances exist.
--   Furthermore, the compiler infers the contexts of the implicit instance
--   declarations introduced by deriving clauses in data and newtype
--   declarations. The instances declared explicitly and automatically
--   derived by the compiler are added to the instance environment . It is
--   also checked that there are no duplicate instances and that all types
--   specified in a default declaration are instances of the Num class.
module Checks.InstanceCheck
instanceCheck :: ModuleIdent -> TCEnv -> ClassEnv -> InstEnv -> [Decl a] -> (InstEnv, [Message])
instance GHC.Classes.Eq Checks.InstanceCheck.InstSource


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


-- | This module implements the type checker of the Curry compiler. The
--   type checker is invoked after the syntactic correctness of the program
--   has been verified and kind checking has been applied to all type
--   expressions. Local variables have been renamed already. Thus the
--   compiler can maintain a flat type environment. The type checker now
--   checks the correct typing of all expressions and also verifies that
--   the type signatures given by the user match the inferred types. The
--   type checker uses the algorithm by Damas and Milner (1982) for
--   inferring the types of unannotated declarations, but allows for
--   polymorphic recursion when a type annotation is present.
--   
--   The result of type checking is a (flat) top-level environment
--   containing the types of all constructors, variables, and functions
--   defined at the top level of a module. In addition, a type annotated
--   source module is returned. Note that type annotations on the left hand
--   side of a declaration hold the function or variable's generalized type
--   with the type scheme's universal quantifier left implicit. Type
--   annotations on the right hand side of a declaration hold the
--   particular instance at which a polymorphic function or variable is
--   used.
module Checks.TypeCheck
typeCheck :: ModuleIdent -> TCEnv -> ValueEnv -> ClassEnv -> InstEnv -> [Decl a] -> ([Decl PredType], ValueEnv, [Message])
instance Checks.TypeCheck.Binding a => Checks.TypeCheck.Binding [a]
instance Checks.TypeCheck.Binding (Curry.Syntax.Type.Decl a)
instance Checks.TypeCheck.Binding (Curry.Syntax.Type.Rhs a)
instance Checks.TypeCheck.Binding (Curry.Syntax.Type.Expression a)
instance Checks.TypeCheck.Binding a => Checks.TypeCheck.Binding (Curry.Syntax.Type.Field a)


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


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

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

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

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

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

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

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

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

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

-- | all type classes with their super classes
[classEnv] :: CompilerEnv -> ClassEnv

-- | instances
[instEnv] :: CompilerEnv -> InstEnv

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

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

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

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

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

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


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

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


-- | At the type level, we distinguish data and renaming types, synonym
--   types, and type classes. Type variables are not recorded. Type
--   synonyms use a kind of their own so that the compiler can verify that
--   no type synonyms are used in type expressions in interface files.
module Env.Type
data TypeKind
Data :: QualIdent -> [Ident] -> TypeKind
Alias :: QualIdent -> TypeKind
Class :: QualIdent -> [Ident] -> TypeKind
toTypeKind :: TypeInfo -> TypeKind
type TypeEnv = TopEnv TypeKind
bindTypeKind :: ModuleIdent -> Ident -> TypeKind -> TypeEnv -> TypeEnv
lookupTypeKind :: Ident -> TypeEnv -> [TypeKind]
qualLookupTypeKind :: QualIdent -> TypeEnv -> [TypeKind]
instance GHC.Show.Show Env.Type.TypeKind
instance GHC.Classes.Eq Env.Type.TypeKind
instance Base.TopEnv.Entity Env.Type.TypeKind


-- | 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 a -> CYIO InterfaceEnv


-- | After the source file has been parsed and all modules have been
--   imported, the compiler first checks all type definitions and
--   signatures. In particular, this module disambiguates nullary type
--   constructors and type variables, which -- in contrast to Haskell -- is
--   not possible on purely syntactic criteria. In addition it is checked
--   that all type constructors and type variables occurring on the right
--   hand side of a type declaration are actually defined and no identifier
--   is defined more than once.
module Checks.TypeSyntaxCheck
typeSyntaxCheck :: [KnownExtension] -> TCEnv -> Module a -> ((Module a, [KnownExtension]), [Message])
instance Checks.TypeSyntaxCheck.Rename a => Checks.TypeSyntaxCheck.Rename [a]
instance Checks.TypeSyntaxCheck.Rename (Curry.Syntax.Type.Decl a)
instance Checks.TypeSyntaxCheck.Rename Curry.Syntax.Type.ConstrDecl
instance Checks.TypeSyntaxCheck.Rename Curry.Syntax.Type.FieldDecl
instance Checks.TypeSyntaxCheck.Rename Curry.Syntax.Type.NewConstrDecl
instance Checks.TypeSyntaxCheck.Rename Curry.Syntax.Type.Constraint
instance Checks.TypeSyntaxCheck.Rename Curry.Syntax.Type.QualTypeExpr
instance Checks.TypeSyntaxCheck.Rename Curry.Syntax.Type.TypeExpr
instance Checks.TypeSyntaxCheck.Rename (Curry.Syntax.Type.Equation a)
instance Checks.TypeSyntaxCheck.Rename (Curry.Syntax.Type.Rhs a)
instance Checks.TypeSyntaxCheck.Rename (Curry.Syntax.Type.CondExpr a)
instance Checks.TypeSyntaxCheck.Rename (Curry.Syntax.Type.Expression a)
instance Checks.TypeSyntaxCheck.Rename (Curry.Syntax.Type.Statement a)
instance Checks.TypeSyntaxCheck.Rename (Curry.Syntax.Type.Alt a)
instance Checks.TypeSyntaxCheck.Rename a => Checks.TypeSyntaxCheck.Rename (Curry.Syntax.Type.Field a)
instance Checks.TypeSyntaxCheck.Rename Curry.Base.Ident.Ident


-- | TODO
module Transformations.Derive
derive :: TCEnv -> ValueEnv -> InstEnv -> OpPrecEnv -> Module PredType -> Module PredType


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


-- | TODO
module Transformations.Dictionary
insertDicts :: InterfaceEnv -> TCEnv -> ValueEnv -> ClassEnv -> InstEnv -> OpPrecEnv -> Module PredType -> (Module Type, InterfaceEnv, TCEnv, ValueEnv, OpPrecEnv)
dictTypeId :: QualIdent -> Ident
qDictTypeId :: QualIdent -> QualIdent
dictConstrId :: QualIdent -> Ident
qDictConstrId :: QualIdent -> QualIdent
defaultMethodId :: QualIdent -> Ident -> Ident
qDefaultMethodId :: QualIdent -> Ident -> QualIdent
superDictStubId :: QualIdent -> QualIdent -> Ident
qSuperDictStubId :: QualIdent -> QualIdent -> QualIdent
instFunId :: QualIdent -> Type -> Ident
qInstFunId :: ModuleIdent -> QualIdent -> Type -> QualIdent
implMethodId :: QualIdent -> Type -> Ident -> Ident
qImplMethodId :: ModuleIdent -> QualIdent -> Type -> Ident -> QualIdent
instance Transformations.Dictionary.Augment Curry.Syntax.Type.Module
instance Transformations.Dictionary.Augment Curry.Syntax.Type.Rhs
instance Transformations.Dictionary.Augment Curry.Syntax.Type.Expression
instance Transformations.Dictionary.Augment Curry.Syntax.Type.Alt
instance Transformations.Dictionary.DictTrans Curry.Syntax.Type.Module
instance Transformations.Dictionary.DictTrans Curry.Syntax.Type.Decl
instance Transformations.Dictionary.DictTrans Curry.Syntax.Type.Equation
instance Transformations.Dictionary.DictTrans Curry.Syntax.Type.Rhs
instance Transformations.Dictionary.DictTrans Curry.Syntax.Type.Pattern
instance Transformations.Dictionary.DictTrans Curry.Syntax.Type.Expression
instance Transformations.Dictionary.DictTrans Curry.Syntax.Type.Alt
instance Transformations.Dictionary.Specialize Curry.Syntax.Type.Module
instance Transformations.Dictionary.Specialize Curry.Syntax.Type.Decl
instance Transformations.Dictionary.Specialize Curry.Syntax.Type.Equation
instance Transformations.Dictionary.Specialize Curry.Syntax.Type.Rhs
instance Transformations.Dictionary.Specialize Curry.Syntax.Type.Expression
instance Transformations.Dictionary.Specialize Curry.Syntax.Type.Alt


-- | 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
instance Transformations.CaseCompletion.SubstType a => Transformations.CaseCompletion.SubstType [a]
instance Transformations.CaseCompletion.SubstType IL.Type.Type


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


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


-- | After the type syntax has been checked und nullary type constructors
--   and type variables have been disambiguated, the compiler infers kinds
--   for all type constructors and type classes defined in the current
--   module and performs kind checking on all type definitions and type
--   signatures.
module Checks.KindCheck
kindCheck :: TCEnv -> ClassEnv -> Module a -> ((TCEnv, ClassEnv), [Message])
instance Checks.KindCheck.HasType a => Checks.KindCheck.HasType [a]
instance Checks.KindCheck.HasType a => Checks.KindCheck.HasType (GHC.Base.Maybe a)
instance Checks.KindCheck.HasType (Curry.Syntax.Type.Decl a)
instance Checks.KindCheck.HasType Curry.Syntax.Type.ConstrDecl
instance Checks.KindCheck.HasType Curry.Syntax.Type.FieldDecl
instance Checks.KindCheck.HasType Curry.Syntax.Type.NewConstrDecl
instance Checks.KindCheck.HasType Curry.Syntax.Type.Constraint
instance Checks.KindCheck.HasType Curry.Syntax.Type.QualTypeExpr
instance Checks.KindCheck.HasType Curry.Syntax.Type.TypeExpr
instance Checks.KindCheck.HasType (Curry.Syntax.Type.Equation a)
instance Checks.KindCheck.HasType (Curry.Syntax.Type.Rhs a)
instance Checks.KindCheck.HasType (Curry.Syntax.Type.CondExpr a)
instance Checks.KindCheck.HasType (Curry.Syntax.Type.Expression a)
instance Checks.KindCheck.HasType (Curry.Syntax.Type.Statement a)
instance Checks.KindCheck.HasType (Curry.Syntax.Type.Alt a)
instance Checks.KindCheck.HasType a => Checks.KindCheck.HasType (Curry.Syntax.Type.Field a)
instance Checks.KindCheck.HasType Curry.Base.Ident.QualIdent


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

-- | Check for enabled language extensions.
--   
--   <ul>
--   <li>Declarations: remain unchanged</li>
--   <li>Environment: The enabled language extensions are updated</li>
--   </ul>
extensionCheck :: Monad m => Check m (Module a)

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

-- | Check the kinds of type definitions and signatures.
--   
--   <ul>
--   <li>Declarations: remain unchanged</li>
--   <li>Environment: The type constructor and class environment are
--   updated</li>
--   </ul>
kindCheck :: Monad m => Check m (Module a)

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

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

-- | Check the deriving clauses.
--   
--   <ul>
--   <li>Declarations: remain unchanged</li>
--   <li>Environment: remain unchanged</li>
--   </ul>
deriveCheck :: Monad m => Check m (Module a)

-- | Check the instances.
--   
--   <ul>
--   <li>Declarations: remain unchanged</li>
--   <li>Environment: The instance environment is updated</li>
--   </ul>
instanceCheck :: Monad m => Check m (Module a)

-- | Apply the correct typing of the module.
--   
--   <ul>
--   <li>Declarations: Type annotations are added to all expressions.</li>
--   <li>Environment: The value environment is updated.</li>
--   </ul>
typeCheck :: Monad m => Options -> CompEnv (Module a) -> CYT m (CompEnv (Module PredType))

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

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

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


-- | This module provides the computation of the exported interface of a
--   compiled module. The function <a>exportInterface</a> uses the expanded
--   export specifications and the corresponding environments in order to
--   compute the interface of the module.
module Exports
exportInterface :: CompilerEnv -> Module a -> Interface
instance GHC.Classes.Ord Exports.IInfo
instance GHC.Classes.Eq Exports.IInfo
instance Exports.HasModule a => Exports.HasModule (GHC.Base.Maybe a)
instance Exports.HasModule a => Exports.HasModule [a]
instance Exports.HasModule Curry.Syntax.Type.IDecl
instance Exports.HasModule Curry.Syntax.Type.ConstrDecl
instance Exports.HasModule Curry.Syntax.Type.FieldDecl
instance Exports.HasModule Curry.Syntax.Type.NewConstrDecl
instance Exports.HasModule Curry.Syntax.Type.IMethodDecl
instance Exports.HasModule Curry.Syntax.Type.Constraint
instance Exports.HasModule Curry.Syntax.Type.TypeExpr
instance Exports.HasModule Curry.Syntax.Type.QualTypeExpr
instance Exports.HasModule Curry.Base.Ident.QualIdent
instance Exports.HasModule Curry.Base.Ident.ModuleIdent
instance Exports.HasType a => Exports.HasType (GHC.Base.Maybe a)
instance Exports.HasType a => Exports.HasType [a]
instance Exports.HasType Curry.Syntax.Type.IDecl
instance Exports.HasType Curry.Syntax.Type.ConstrDecl
instance Exports.HasType Curry.Syntax.Type.FieldDecl
instance Exports.HasType Curry.Syntax.Type.NewConstrDecl
instance Exports.HasType Curry.Syntax.Type.IMethodDecl
instance Exports.HasType Curry.Syntax.Type.Constraint
instance Exports.HasType Curry.Syntax.Type.TypeExpr
instance Exports.HasType Curry.Syntax.Type.QualTypeExpr


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

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


-- | TODO
module Base.AnnotExpr
class QualAnnotExpr e

-- | Free qualified annotated variables in an <a>Expr</a>
qafv :: QualAnnotExpr e => ModuleIdent -> e Type -> [(Type, Ident)]
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.Decl
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.Equation
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.Lhs
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.Rhs
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.CondExpr
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.Expression
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.Statement
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.Alt
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.InfixOp
instance Base.AnnotExpr.QualAnnotExpr Curry.Syntax.Type.Pattern


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


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

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

-- | Automatically derive instances.
derive :: CompEnv (Module PredType) -> CompEnv (Module PredType)

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

-- | Insert dictionaries, changes the type constructor and value
--   environments.
insertDicts :: CompEnv (Module PredType) -> CompEnv (Module Type)

-- | Remove newtype constructors.
removeNewtypes :: CompEnv (Module Type) -> CompEnv (Module Type)

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

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

-- | Translate into the intermediate language
ilTrans :: CompEnv (Module Type) -> 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 typed <tt>FlatCurry</tt>
--   program term for a given module in the intermediate language.
module Generators.GenTypedFlatCurry
genTypedFlatCurry :: CompilerEnv -> Module Type -> Module -> AProg TypeExpr
instance Generators.GenTypedFlatCurry.Normalize GHC.Types.Int
instance Generators.GenTypedFlatCurry.Normalize Curry.FlatCurry.Type.TypeExpr
instance Generators.GenTypedFlatCurry.Normalize b => Generators.GenTypedFlatCurry.Normalize (a, b)
instance Generators.GenTypedFlatCurry.Normalize a => Generators.GenTypedFlatCurry.Normalize (Curry.FlatCurry.Annotated.Type.AFuncDecl a)
instance Generators.GenTypedFlatCurry.Normalize a => Generators.GenTypedFlatCurry.Normalize (Curry.FlatCurry.Annotated.Type.ARule a)
instance Generators.GenTypedFlatCurry.Normalize a => Generators.GenTypedFlatCurry.Normalize (Curry.FlatCurry.Annotated.Type.AExpr a)
instance Generators.GenTypedFlatCurry.Normalize a => Generators.GenTypedFlatCurry.Normalize (Curry.FlatCurry.Annotated.Type.ABranchExpr a)
instance Generators.GenTypedFlatCurry.Normalize a => Generators.GenTypedFlatCurry.Normalize (Curry.FlatCurry.Annotated.Type.APattern a)


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

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

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

-- | Generate typed FlatCurry
genTypedFlatCurry :: CompilerEnv -> Module Type -> Module -> AProg TypeExpr

-- | Generate FlatCurry
genFlatCurry :: AProg a -> Prog

-- | Generate a FlatCurry interface
genFlatInterface :: Prog -> Prog


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