Safe Haskell | None |
---|---|
Language | Haskell2010 |
GF, the Grammatical Framework, as a library
- main :: IO ()
- getOptions :: IO (Options, [FilePath])
- mainOpts :: Options -> [FilePath] -> IO ()
- mainGFI :: Options -> [FilePath] -> IO ()
- mainRunGFI :: Options -> [FilePath] -> IO ()
- mainServerGFI :: Options -> Int -> [FilePath] -> IO Server
- mainGFC :: Options -> [FilePath] -> IO ()
- linkGrammars :: Options -> (UTCTime, [(ModuleName, Grammar)]) -> IO ()
- writePGF :: Options -> PGF -> IOE ()
- writeOutputs :: Options -> PGF -> IOE ()
- compileToPGF :: Options -> [FilePath] -> IOE PGF
- link :: Options -> (ModuleName, Grammar) -> IOE PGF
- batchCompile :: Options -> [FilePath] -> IOE (UTCTime, (ModuleName, Grammar))
- srcAbsName :: Grammar -> ModuleName -> ModuleName
- parallelBatchCompile :: (Output m, ErrorMonad m, MonadIO m) => t -> Options -> [FilePath] -> m (UTCTime, [(ModuleName, Grammar)])
- exportPGF :: Options -> OutputFormat -> PGF -> [(FilePath, String)]
- type OneOutput = (Maybe FullPath, CompiledModule)
- type CompiledModule = Module
- compileOne :: (Output m, ErrorMonad m, MonadIO m) => Options -> Grammar -> FullPath -> m OneOutput
- reuseGFO :: (Output m, ErrorMonad m, MonadIO m) => Options -> Grammar -> FullPath -> m OneOutput
- useTheSource :: (Output m, ErrorMonad m, MonadIO m) => Options -> Grammar -> FullPath -> m OneOutput
- getSourceModule :: (Output m, ErrorMonad m, MonadIO m) => Options -> FilePath -> m (ModuleName, ModuleInfo)
- getCFRules :: Options -> FilePath -> IOE [CFRule]
- getEBNFRules :: Options -> FilePath -> IOE [ERule]
- data Grammar
- data ModuleName
- type Module = (ModuleName, ModuleInfo)
- data ModuleInfo = ModInfo {
- mtype :: ModuleType
- mstatus :: ModuleStatus
- mflags :: Options
- mextend :: [(ModuleName, MInclude)]
- mwith :: Maybe (ModuleName, MInclude, [(ModuleName, ModuleName)])
- mopens :: [OpenSpec]
- mexdeps :: [ModuleName]
- msrc :: FilePath
- mseqs :: Maybe (Array SeqId Sequence)
- jments :: Map Ident Info
- type SourceGrammar = Grammar
- type SourceModInfo = ModuleInfo
- type SourceModule = Module
- data ModuleType
- emptyGrammar :: Grammar
- mGrammar :: [Module] -> Grammar
- modules :: Grammar -> [Module]
- prependModule :: Grammar -> Module -> Grammar
- moduleMap :: Grammar -> Map ModuleName ModuleInfo
- data MInclude
- data OpenSpec
- extends :: ModuleInfo -> [ModuleName]
- isInherited :: MInclude -> Ident -> Bool
- inheritAll :: ModuleName -> (ModuleName, MInclude)
- openedModule :: OpenSpec -> ModuleName
- allDepsModule :: Grammar -> ModuleInfo -> [OpenSpec]
- partOfGrammar :: Grammar -> Module -> Grammar
- depPathModule :: ModuleInfo -> [OpenSpec]
- allExtends :: Grammar -> ModuleName -> [Module]
- allExtendsPlus :: Grammar -> ModuleName -> [ModuleName]
- lookupModule :: ErrorMonad m => Grammar -> ModuleName -> m ModuleInfo
- isModAbs :: ModuleInfo -> Bool
- isModRes :: ModuleInfo -> Bool
- isModCnc :: ModuleInfo -> Bool
- sameMType :: ModuleType -> ModuleType -> Bool
- isCompilableModule :: ModuleInfo -> Bool
- isCompleteModule :: ModuleInfo -> Bool
- allAbstracts :: Grammar -> [ModuleName]
- greatestAbstract :: Grammar -> Maybe ModuleName
- allResources :: Grammar -> [ModuleName]
- greatestResource :: Grammar -> Maybe ModuleName
- allConcretes :: Grammar -> ModuleName -> [ModuleName]
- allConcreteModules :: Grammar -> [ModuleName]
- abstractOfConcrete :: ErrorMonad m => Grammar -> ModuleName -> m ModuleName
- data ModuleStatus
- data Info
- = AbsCat (Maybe (L Context))
- | AbsFun (Maybe (L Type)) (Maybe Int) (Maybe [L Equation]) (Maybe Bool)
- | ResParam (Maybe (L [Param])) (Maybe [Term])
- | ResValue (L Type)
- | ResOper (Maybe (L Type)) (Maybe (L Term))
- | ResOverload [ModuleName] [(L Type, L Term)]
- | CncCat (Maybe (L Type)) (Maybe (L Term)) (Maybe (L Term)) (Maybe (L Term)) (Maybe PMCFG)
- | CncFun (Maybe (Ident, Context, Type)) (Maybe (L Term)) (Maybe (L Term)) (Maybe PMCFG)
- | AnyInd Bool ModuleName
- data Term
- = Vr Ident
- | Cn Ident
- | Con Ident
- | Sort Ident
- | EInt Int
- | EFloat Double
- | K String
- | Empty
- | App Term Term
- | Abs BindType Ident Term
- | Meta !MetaId
- | ImplArg Term
- | Prod BindType Ident Term Term
- | Typed Term Term
- | Example Term String
- | RecType [Labelling]
- | R [Assign]
- | P Term Label
- | ExtR Term Term
- | Table Term Term
- | T TInfo [Case]
- | V Type [Term]
- | S Term Term
- | Let LocalDef Term
- | Q QIdent
- | QC QIdent
- | C Term Term
- | Glue Term Term
- | EPatt Patt
- | EPattType Term
- | ELincat Ident Term
- | ELin Ident Term
- | AdHocOverload [Term]
- | FV [Term]
- | Alts Term [(Term, Term)]
- | Strs [Term]
- | Error String
- type Type = Term
- type Cat = QIdent
- type Fun = QIdent
- type QIdent = (ModuleName, Ident)
- data BindType
- data Patt
- data TInfo
- data Label
- type MetaId = Int
- type Hypo = (BindType, Ident, Term)
- type Context = [Hypo]
- type Equation = ([Patt], Term)
- type Labelling = (Label, Type)
- type Assign = (Label, (Maybe Type, Term))
- type Case = (Patt, Term)
- type LocalDef = (Ident, (Maybe Type, Term))
- type Param = (Ident, Context)
- type Altern = (Term, [(Term, Term)])
- type Substitution = [(Ident, Term)]
- varLabel :: Int -> Label
- tupleLabel :: Int -> Label
- linLabel :: Int -> Label
- theLinLabel :: Label
- ident2label :: Ident -> Label
- label2ident :: Label -> Ident
- data Location
- data L a = L Location a
- unLoc :: L a -> a
- noLoc :: a -> L a
- ppLocation :: FilePath -> Location -> Doc
- ppL :: (Pretty a2, Pretty a1) => L a2 -> a1 -> Doc
- data PMCFG = PMCFG [Production] (Array FunId (UArray LIndex SeqId))
- data Production = Production !FId !FunId [[FId]]
- type FId = Int
- type FunId = Int
- type SeqId = Int
- type LIndex = Int
- type Sequence = Array DotPos Symbol
- typeForm :: Type -> (Context, Cat, [Term])
- typeFormCnc :: Type -> (Context, Type)
- valCat :: Type -> Cat
- valType :: Type -> Type
- valTypeCnc :: Type -> Type
- typeSkeleton :: Type -> ([(Int, Cat)], Cat)
- catSkeleton :: Type -> ([Cat], Cat)
- funsToAndFrom :: Type -> (Cat, [(Cat, [Int])])
- isRecursiveType :: Type -> Bool
- isHigherOrderType :: Type -> Bool
- contextOfType :: Monad m => Type -> m Context
- termForm :: Monad m => Term -> m ([(BindType, Ident)], Term, [Term])
- termFormCnc :: Term -> ([(BindType, Ident)], Term)
- appForm :: Term -> (Term, [Term])
- mkProdSimple :: Context -> Term -> Term
- mkProd :: Context -> Term -> [Term] -> Term
- mkTerm :: ([(BindType, Ident)], Term, [Term]) -> Term
- mkApp :: Term -> [Term] -> Term
- mkAbs :: [(BindType, Ident)] -> Term -> Term
- appCons :: Ident -> [Term] -> Term
- mkLet :: [LocalDef] -> Term -> Term
- mkLetUntyped :: Context -> Term -> Term
- isVariable :: Term -> Bool
- uType :: Type
- assign :: Label -> Term -> Assign
- assignT :: Label -> Type -> Term -> Assign
- unzipR :: [Assign] -> ([Label], [Term])
- mkAssign :: [(Label, Term)] -> [Assign]
- projectRec :: Label -> [Assign] -> Term
- zipAssign :: [Label] -> [Term] -> [Assign]
- mapAssignM :: Monad m => (Term -> m c) -> [Assign] -> m [(Label, (Maybe c, c))]
- mkRecordN :: Int -> (Int -> Label) -> [Term] -> Term
- mkRecord :: (Int -> Label) -> [Term] -> Term
- mkRecTypeN :: Int -> (Int -> Label) -> [Type] -> Type
- mkRecType :: (Int -> Label) -> [Type] -> Type
- record2subst :: Term -> Err Substitution
- typeType :: Type
- typeStrs :: Type
- typeTok :: Type
- typeStr :: Type
- typePType :: Type
- typeString :: Type
- typeInt :: Type
- typeFloat :: Type
- typeInts :: Int -> Type
- typePBool :: Type
- typeError :: Type
- isTypeInts :: Type -> Maybe Int
- isPredefConstant :: Term -> Bool
- checkPredefError :: Monad m => Term -> m Term
- cnPredef :: Ident -> Term
- mkSelects :: Term -> [Term] -> Term
- mkTable :: [Term] -> Term -> Term
- mkCTable :: [(BindType, Ident)] -> Term -> Term
- mkHypo :: Term -> Hypo
- eqStrIdent :: Ident -> Ident -> Bool
- tuple2record :: [Term] -> [Assign]
- tuple2recordType :: [Term] -> [Labelling]
- tuple2recordPatt :: [Patt] -> [(Label, Patt)]
- mkCases :: Ident -> Term -> Term
- mkWildCases :: Term -> Term
- mkFunType :: [Type] -> Type -> Type
- plusRecType :: ErrorMonad m => Term -> Term -> m Term
- plusRecord :: ErrorMonad m => Term -> Term -> m Term
- defLinType :: Type
- mkFreshVar :: [Ident] -> Ident
- mkFreshVarX :: [Ident] -> Ident -> Ident
- maxVarIndex :: [Ident] -> Int
- mkFreshVars :: Int -> [Ident] -> [Ident]
- freshAsTerm :: String -> Term
- string2term :: String -> Term
- int2term :: Int -> Term
- float2term :: Double -> Term
- ident2terminal :: Ident -> Term
- symbolOfIdent :: Ident -> String
- symid :: Ident -> String
- justIdentOf :: Term -> Maybe Ident
- linTypeStr :: Type
- linAsStr :: String -> Term
- term2patt :: Term -> Err Patt
- patt2term :: Patt -> Term
- composSafeOp :: (Term -> Term) -> Term -> Term
- composOp :: Monad m => (Term -> m Term) -> Term -> m Term
- composSafePattOp :: (Patt -> Patt) -> Patt -> Patt
- composPattOp :: Monad m => (Patt -> m Patt) -> Patt -> m Patt
- collectOp :: Monoid m => (Term -> m) -> Term -> m
- mconcatMap :: Monoid c => (a -> c) -> [a] -> c
- collectPattOp :: (Patt -> [a]) -> Patt -> [a]
- redirectTerm :: ModuleName -> Term -> Term
- allCaseValues :: Term -> [([Patt], Term)]
- strsFromTerm :: Term -> Err [Str]
- stringFromTerm :: Term -> String
- getTableType :: TInfo -> Err Type
- changeTableType :: Monad m => (Type -> m Type) -> TInfo -> m TInfo
- wordsInTerm :: Term -> [String]
- noExist :: Term
- defaultLinType :: Type
- sortRec :: [(Label, a)] -> [(Label, a)]
- allDependencies :: (ModuleName -> Bool) -> BinTree Ident Info -> [(Ident, [Ident])]
- topoSortJments :: ErrorMonad m => SourceModule -> m [(Ident, Info)]
- topoSortJments2 :: ErrorMonad m => SourceModule -> m [[(Ident, Info)]]
- data TermPrintQual
- ppModule :: TermPrintQual -> SourceModule -> Doc
- ppJudgement :: Pretty a1 => TermPrintQual -> (a1, Info) -> Doc
- ppParams :: Pretty a => TermPrintQual -> [(a, [(t, Ident, Term)])] -> Doc
- ppTerm :: (Ord a, Num a) => TermPrintQual -> a -> Term -> Doc
- ppPatt :: (Ord a, Num a) => TermPrintQual -> a -> Patt -> Doc
- ppValue :: TermPrintQual -> Int -> Val -> Doc
- ppConstrs :: Constraints -> [Doc]
- ppQIdent :: TermPrintQual -> QIdent -> Doc
- ppMeta :: MetaId -> Doc
- getAbs :: Term -> ([(BindType, Ident)], Term)
- newtype ModuleName = MN Ident
- moduleNameS :: String -> ModuleName
- data Ident
- ident2utf8 :: Ident -> ByteString
- showIdent :: Ident -> String
- prefixIdent :: String -> Ident -> Ident
- identS :: String -> Ident
- identC :: RawIdent -> Ident
- identW :: Ident
- identV :: RawIdent -> Int -> Ident
- identA :: RawIdent -> Int -> Ident
- identAV :: RawIdent -> Int -> Int -> Ident
- argIdent :: Int -> Ident -> Int -> Ident
- isArgIdent :: Ident -> Bool
- getArgIndex :: Ident -> Maybe Int
- varStr :: Ident
- varX :: Int -> Ident
- isWildIdent :: Ident -> Bool
- varIndex :: Ident -> Int
- data RawIdent
- rawIdentS :: String -> RawIdent
- rawIdentC :: ByteString -> RawIdent
- ident2raw :: Ident -> RawIdent
- prefixRawIdent :: RawIdent -> RawIdent -> RawIdent
- isPrefixOf :: RawIdent -> RawIdent -> Bool
- showRawIdent :: RawIdent -> String
- data VersionTagged a
- = Tagged {
- unV :: a
- | WrongVersion
- = Tagged {
- decodeModuleHeader :: MonadIO io => FilePath -> io (VersionTagged Module)
- decodeModule :: MonadIO io => FilePath -> io SourceModule
- encodeModule :: MonadIO io => FilePath -> SourceModule -> io ()
Command line interface
Run the GF main program, taking arguments from the command line.
(It calls setConsoleEncoding
and getOptions
, then mainOpts
.)
Run gf --help
for usage info.
getOptions :: IO (Options, [FilePath]) Source
Get and parse GF command line arguments. Fix relative paths.
Calls getArgs
and parseOptions
.
mainOpts :: Options -> [FilePath] -> IO () Source
Run the GF main program with the given options and files. Depending on
the options it invokes mainGFC
, mainGFI
, mainRunGFI
, mainServerGFI
,
or it just prints version/usage info.
mainRunGFI :: Options -> [FilePath] -> IO () Source
Run the GF Shell in quiet mode (gf -run
).
mainServerGFI :: Options -> Int -> [FilePath] -> IO Server Source
Run the GF Server (gf -server
).
The Int
argument is the port number for the HTTP service.
mainGFC :: Options -> [FilePath] -> IO () Source
Compile the given GF grammar files. The result is a number of .gfo
files
and, depending on the options, a .pgf
file. (gf -batch
, gf -make
)
linkGrammars :: Options -> (UTCTime, [(ModuleName, Grammar)]) -> IO () Source
Create a .pgf
file (and possibly files in other formats, if specified
in the Options
) from the output of parallelBatchCompile
.
If a .pgf
file by the same name already exists and it is newer than the
source grammar files (as indicated by the UTCTime
argument), it is not
recreated. Calls writePGF
and writeOutputs
.
writePGF :: Options -> PGF -> IOE () Source
Write the result of compiling a grammar (e.g. with compileToPGF
or
link
) to a .pgf
file.
A split PGF file is output if the -split-pgf
option is used.
writeOutputs :: Options -> PGF -> IOE () Source
Export the PGF to the OutputFormat
s specified in the Options
.
Calls exportPGF
.
Compiling GF grammars
compileToPGF :: Options -> [FilePath] -> IOE PGF Source
Compiles a number of source files and builds a PGF
structure for them.
This is a composition of link
and batchCompile
.
batchCompile :: Options -> [FilePath] -> IOE (UTCTime, (ModuleName, Grammar)) Source
Compile the given grammar files and everything they depend on.
Compiled modules are stored in .gfo
files (unless the -tags
option is
used, in which case tags files are produced instead).
Existing .gfo
files are reused if they are up-to-date
(unless the option -src
aka -force-recomp
is used).
srcAbsName :: Grammar -> ModuleName -> ModuleName Source
Returns the name of the abstract syntax corresponding to the named concrete syntax
parallelBatchCompile :: (Output m, ErrorMonad m, MonadIO m) => t -> Options -> [FilePath] -> m (UTCTime, [(ModuleName, Grammar)]) Source
Compile the given grammar files and everything they depend on,
like batchCompile
. This function compiles modules in parallel.
It keeps modules compiled in present and alltenses mode apart,
storing the .gfo
files in separate subdirectories to avoid creating
the broken PGF files that can result from mixing different modes in the
same concrete syntax.
The first argument is supposed to be the number of jobs to run in
parallel, but this has not been implemented yet. Instead you have to
use the GHC run-time flag +RTS -N -RTS
to enable parallelism.
:: Options | |
-> OutputFormat | |
-> PGF | |
-> [(FilePath, String)] | List of recommended file names and contents. |
Export a PGF to the given OutputFormat
. For many output formats,
additional Options
can be used to control the output.
Compiling a single module
type OneOutput = (Maybe FullPath, CompiledModule) Source
type CompiledModule = Module Source
compileOne :: (Output m, ErrorMonad m, MonadIO m) => Options -> Grammar -> FullPath -> m OneOutput Source
Compile a given source file (or just load a .gfo file),
given a Grammar
containing everything it depends on.
Calls reuseGFO
or useTheSource
.
reuseGFO :: (Output m, ErrorMonad m, MonadIO m) => Options -> Grammar -> FullPath -> m OneOutput Source
Read a compiled GF module. Also undo common subexp optimization, to enable normal computations.
useTheSource :: (Output m, ErrorMonad m, MonadIO m) => Options -> Grammar -> FullPath -> m OneOutput Source
Compile GF module from source. It both returns the result and
stores it in a .gfo
file
(or a tags file, if running with the -tags
option)
Abstract syntax, parsing, pretty printing and serialisation
getSourceModule :: (Output m, ErrorMonad m, MonadIO m) => Options -> FilePath -> m (ModuleName, ModuleInfo) Source
Read a source file and parse it (after applying preprocessors specified in the options)
getCFRules :: Options -> FilePath -> IOE [CFRule] Source
getEBNFRules :: Options -> FilePath -> IOE [ERule] Source
Grammar modules
A grammar is a self-contained collection of grammar modules
data ModuleName Source
Module names
type Module = (ModuleName, ModuleInfo) Source
Modules
data ModuleInfo Source
ModInfo | |
|
type SourceGrammar = Grammar Source
type SourceModInfo = ModuleInfo Source
type SourceModule = Module Source
data ModuleType Source
encoding the type of the module
prependModule :: Grammar -> Module -> Grammar Source
extends :: ModuleInfo -> [ModuleName] Source
isInherited :: MInclude -> Ident -> Bool Source
inheritAll :: ModuleName -> (ModuleName, MInclude) Source
openedModule :: OpenSpec -> ModuleName Source
allDepsModule :: Grammar -> ModuleInfo -> [OpenSpec] Source
all dependencies
partOfGrammar :: Grammar -> Module -> Grammar Source
select just those modules that a given one depends on, including itself
depPathModule :: ModuleInfo -> [OpenSpec] Source
initial dependency list
allExtends :: Grammar -> ModuleName -> [Module] Source
all modules that a module extends, directly or indirectly, with restricts
allExtendsPlus :: Grammar -> ModuleName -> [ModuleName] Source
the same as allExtends
plus that an instance extends its interface
lookupModule :: ErrorMonad m => Grammar -> ModuleName -> m ModuleInfo Source
isModAbs :: ModuleInfo -> Bool Source
isModRes :: ModuleInfo -> Bool Source
isModCnc :: ModuleInfo -> Bool Source
sameMType :: ModuleType -> ModuleType -> Bool Source
isCompilableModule :: ModuleInfo -> Bool Source
don't generate code for interfaces and for incomplete modules
isCompleteModule :: ModuleInfo -> Bool Source
interface and "incomplete M" are not complete
allAbstracts :: Grammar -> [ModuleName] Source
all abstract modules sorted from least to most dependent
greatestAbstract :: Grammar -> Maybe ModuleName Source
the last abstract in dependency order (head of list)
allResources :: Grammar -> [ModuleName] Source
all resource modules
greatestResource :: Grammar -> Maybe ModuleName Source
the greatest resource in dependency order
allConcretes :: Grammar -> ModuleName -> [ModuleName] Source
all concretes for a given abstract
allConcreteModules :: Grammar -> [ModuleName] Source
all concrete modules for any abstract
abstractOfConcrete :: ErrorMonad m => Grammar -> ModuleName -> m ModuleName Source
we store the module type with the identifier
data ModuleStatus Source
Judgements
the constructors are judgements in
- abstract syntax (ABS)
- resource (RES)
- concrete syntax (CNC)
and indirection to module (INDIR)
AbsCat (Maybe (L Context)) | (ABS) context of a category |
AbsFun (Maybe (L Type)) (Maybe Int) (Maybe [L Equation]) (Maybe Bool) | (ABS) type, arrity and definition of a function |
ResParam (Maybe (L [Param])) (Maybe [Term]) | (RES) the second parameter is list of all possible values |
ResValue (L Type) | (RES) to mark parameter constructors for lookup |
ResOper (Maybe (L Type)) (Maybe (L Term)) | (RES) |
ResOverload [ModuleName] [(L Type, L Term)] | (RES) idents: modules inherited |
CncCat (Maybe (L Type)) (Maybe (L Term)) (Maybe (L Term)) (Maybe (L Term)) (Maybe PMCFG) | (CNC) lindef ini'zed, |
CncFun (Maybe (Ident, Context, Type)) (Maybe (L Term)) (Maybe (L Term)) (Maybe PMCFG) | (CNC) type info added at |
AnyInd Bool ModuleName | (INDIR) the |
Terms
Vr Ident | variable |
Cn Ident | constant |
Con Ident | constructor |
Sort Ident | basic type |
EInt Int | integer literal |
EFloat Double | floating point literal |
K String | string literal or token: |
Empty | the empty string |
App Term Term | application: |
Abs BindType Ident Term | abstraction: |
Meta !MetaId | metavariable: |
ImplArg Term | placeholder for implicit argument |
Prod BindType Ident Term Term | function type: |
Typed Term Term | type-annotated term below this, the constructors are only for concrete syntax |
Example Term String | example-based term: @in M.C "foo" |
RecType [Labelling] | record type: |
R [Assign] | record: |
P Term Label | projection: |
ExtR Term Term | extension: |
Table Term Term | table type: |
T TInfo [Case] | table: |
V Type [Term] | table given as course of values: |
S Term Term | selection: |
Let LocalDef Term | local definition: |
Q QIdent | qualified constant from a package |
QC QIdent | qualified constructor from a package |
C Term Term | concatenation: |
Glue Term Term | agglutination: |
EPatt Patt | pattern (in macro definition): # p |
EPattType Term | pattern type: pattern T |
ELincat Ident Term | boxed linearization type of Ident |
ELin Ident Term | boxed linearization of type Ident |
AdHocOverload [Term] | ad hoc overloading generated in Rename |
FV [Term] | alternatives in free variation: |
Alts Term [(Term, Term)] | alternatives by prefix: |
Strs [Term] | conditioning prefix strings: |
Error String | error values returned by Predef.error |
type QIdent = (ModuleName, Ident) Source
Patterns
PC Ident [Patt] | constructor pattern: |
PP QIdent [Patt] | package constructor pattern: |
PV Ident | variable pattern: |
PW | wild card pattern: |
PR [(Label, Patt)] | record pattern: |
PString String | string literal pattern: |
PInt Int | integer literal pattern: |
PFloat Double | float literal pattern: |
PT Type Patt | type-annotated pattern |
PAs Ident Patt | as-pattern: x@p |
PImplArg Patt | placeholder for pattern for implicit argument |
PTilde Term | inaccessible pattern |
PNeg Patt | negated pattern: -p |
PAlt Patt Patt | disjunctive pattern: p1 | p2 |
PSeq Patt Patt | sequence of token parts: p + q |
PMSeq MPatt MPatt | sequence of token parts: p + q |
PRep Patt | repetition of token part: p* |
PChar | string of length one: ? |
PChars [Char] | character list: ["aeiou"] |
PMacro Ident | |
PM QIdent |
to guide computation and type checking of tables
record label
type Substitution = [(Ident, Term)] Source
tupleLabel :: Int -> Label Source
ident2label :: Ident -> Label Source
label2ident :: Label -> Ident Source
Source locations
Attaching location information
ppLocation :: FilePath -> Location -> Doc Source
PMCFG
data Production Source
Production !FId !FunId [[FId]] |
Functions for constructing and analysing source code terms.
typeFormCnc :: Type -> (Context, Type) Source
valTypeCnc :: Type -> Type Source
catSkeleton :: Type -> ([Cat], Cat) Source
isRecursiveType :: Type -> Bool Source
isHigherOrderType :: Type -> Bool Source
contextOfType :: Monad m => Type -> m Context Source
mkProdSimple :: Context -> Term -> Term Source
mkLetUntyped :: Context -> Term -> Term Source
isVariable :: Term -> Bool Source
Assignment
projectRec :: Label -> [Assign] -> Term Source
Records
record2subst :: Term -> Err Substitution Source
Types
typeString :: Type Source
isTypeInts :: Type -> Maybe Int Source
Terms
isPredefConstant :: Term -> Bool Source
checkPredefError :: Monad m => Term -> m Term Source
eqStrIdent :: Ident -> Ident -> Bool Source
tuple2record :: [Term] -> [Assign] Source
tuple2recordType :: [Term] -> [Labelling] Source
tuple2recordPatt :: [Patt] -> [(Label, Patt)] Source
mkWildCases :: Term -> Term Source
plusRecType :: ErrorMonad m => Term -> Term -> m Term Source
plusRecord :: ErrorMonad m => Term -> Term -> m Term Source
defLinType :: Type Source
default linearization type
mkFreshVar :: [Ident] -> Ident Source
refreshing variables
mkFreshVarX :: [Ident] -> Ident -> Ident Source
trying to preserve a given symbol
maxVarIndex :: [Ident] -> Int Source
mkFreshVars :: Int -> [Ident] -> [Ident] Source
freshAsTerm :: String -> Term Source
quick hack for refining with var in editor
string2term :: String -> Term Source
create a terminal for concrete syntax
float2term :: Double -> Term Source
ident2terminal :: Ident -> Term Source
create a terminal from identifier
symbolOfIdent :: Ident -> String Source
justIdentOf :: Term -> Maybe Ident Source
linTypeStr :: Type Source
Term and pattern conversion
Almost compositional
composOp :: Monad m => (Term -> m Term) -> Term -> m Term Source
to define compositional term functions
mconcatMap :: Monoid c => (a -> c) -> [a] -> c Source
collectPattOp :: (Patt -> [a]) -> Patt -> [a] Source
Misc
redirectTerm :: ModuleName -> Term -> Term Source
allCaseValues :: Term -> [([Patt], Term)] Source
to gather ultimate cases in a table; preserves pattern list
strsFromTerm :: Term -> Err [Str] Source
to get a string from a term that represents a sequence of terminals
stringFromTerm :: Term -> String Source
to print an Str-denoting term as a string; if the term is of wrong type, the error msg
getTableType :: TInfo -> Err Type Source
wordsInTerm :: Term -> [String] Source
to find the word items in a term
Dependencies
allDependencies :: (ModuleName -> Bool) -> BinTree Ident Info -> [(Ident, [Ident])] Source
dependency check, detecting circularities and returning topo-sorted list
topoSortJments :: ErrorMonad m => SourceModule -> m [(Ident, Info)] Source
topoSortJments2 :: ErrorMonad m => SourceModule -> m [[(Ident, Info)]] Source
Pretty printing
ppModule :: TermPrintQual -> SourceModule -> Doc Source
ppJudgement :: Pretty a1 => TermPrintQual -> (a1, Info) -> Doc Source
ppValue :: TermPrintQual -> Int -> Val -> Doc Source
ppQIdent :: TermPrintQual -> QIdent -> Doc Source
Identifiers
newtype ModuleName Source
Module names
moduleNameS :: String -> ModuleName Source
the constructors labelled INTERNAL are internal representation never returned by the parser
ident2utf8 :: Ident -> ByteString Source
This function should be used with care, since the returned ByteString is UTF-8-encoded.
prefixIdent :: String -> Ident -> Ident Source
Normal identifiers (returned by the parser)
Special identifiers for internal use
isArgIdent :: Ident -> Bool Source
getArgIndex :: Ident -> Maybe Int Source
isWildIdent :: Ident -> Bool Source
Raw identifiers
Identifiers are stored as UTF-8-encoded bytestrings.
(It is also possible to use regular Haskell String
s, with somewhat
reduced performance and increased memory use.)
rawIdentC :: ByteString -> RawIdent Source
prefixRawIdent :: RawIdent -> RawIdent -> RawIdent Source
isPrefixOf :: RawIdent -> RawIdent -> Bool Source
showRawIdent :: RawIdent -> String Source
Binary serialisation
data VersionTagged a Source
Tagged | |
| |
WrongVersion |
Functor VersionTagged | |
Binary a => Binary (VersionTagged a) |
decodeModuleHeader :: MonadIO io => FilePath -> io (VersionTagged Module) Source
Read just the module header, the returned Module
will have an empty body
decodeModule :: MonadIO io => FilePath -> io SourceModule Source
encodeModule :: MonadIO io => FilePath -> SourceModule -> io () Source