gf-3.11: Grammatical Framework
Safe HaskellNone
LanguageHaskell2010

GF

Description

GF, the Grammatical Framework, as a library

Synopsis

Command line interface

main :: IO () Source #

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.

mainGFI :: Options -> [FilePath] -> IO () Source #

Run the interactive GF Shell

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

link :: Options -> (ModuleName, Grammar) -> IOE PGF Source #

Link a grammar into a PGF that can be used to linearize and parse with the PGF run-time system.

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 :: Maybe Int -> Options -> [FilePath] -> IO (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 controls the number of jobs to run in parallel. This works if GF was compiled with GHC>=7.6, otherwise you have to use the GHC run-time flag +RTS -N -RTS to enable parallelism.

exportPGF Source #

Arguments

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

compileOne :: (Output m, ErrorMonad m, MonadIO m, MonadFail 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, MonadFail 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, MonadFail 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 :: (MonadIO m, ErrorMonad m) => Options -> FilePath -> m (ModuleName, ModuleInfo) Source #

Read a source file and parse it (after applying preprocessors specified in the options)

getBNFCRules :: Options -> FilePath -> IOE [BNFCRule] Source #

Grammar modules

data Grammar Source #

A grammar is a self-contained collection of grammar modules

Instances

Instances details
Binary Grammar Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

put :: Grammar -> Put

get :: Get Grammar

Pretty Grammar Source # 
Instance details

Defined in GF.Grammar.Printer

Methods

pp :: Grammar -> Doc Source #

ppList :: [Grammar] -> Doc Source #

data ModuleName Source #

Module names

Instances

Instances details
Eq ModuleName Source # 
Instance details

Defined in GF.Infra.Ident

Ord ModuleName Source # 
Instance details

Defined in GF.Infra.Ident

Show ModuleName Source # 
Instance details

Defined in GF.Infra.Ident

Binary ModuleName Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

put :: ModuleName -> Put

get :: Get ModuleName

Pretty ModuleName Source # 
Instance details

Defined in GF.Infra.Ident

data ModuleType Source #

encoding the type of the module

Instances

Instances details
Eq ModuleType Source # 
Instance details

Defined in GF.Grammar.Grammar

Show ModuleType Source # 
Instance details

Defined in GF.Grammar.Grammar

Binary ModuleType Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

put :: ModuleType -> Put

get :: Get ModuleType

data MInclude Source #

Constructors

MIAll 
MIOnly [Ident] 
MIExcept [Ident] 

Instances

Instances details
Eq MInclude Source # 
Instance details

Defined in GF.Grammar.Grammar

Show MInclude Source # 
Instance details

Defined in GF.Grammar.Grammar

Binary MInclude Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

put :: MInclude -> Put

get :: Get MInclude

data OpenSpec Source #

Instances

Instances details
Eq OpenSpec Source # 
Instance details

Defined in GF.Grammar.Grammar

Show OpenSpec Source # 
Instance details

Defined in GF.Grammar.Grammar

Binary OpenSpec Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

put :: OpenSpec -> Put

get :: Get OpenSpec

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

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

Judgements

data Info Source #

the constructors are judgements in

  • abstract syntax (ABS)
  • resource (RES)
  • concrete syntax (CNC)

and indirection to module (INDIR)

Constructors

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 TC

AnyInd Bool ModuleName

(INDIR) the Bool says if canonical

Instances

Instances details
Show Info Source # 
Instance details

Defined in GF.Grammar.Grammar

Methods

showsPrec :: Int -> Info -> ShowS #

show :: Info -> String #

showList :: [Info] -> ShowS #

Binary Info Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

put :: Info -> Put

get :: Get Info

Terms

data Term Source #

Constructors

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: "foo"

Empty

the empty string []

App Term Term

application: f a

Abs BindType Ident Term

abstraction: x -> b

Meta !MetaId

metavariable: ?i (only parsable: ? = ?0)

ImplArg Term

placeholder for implicit argument {t}

Prod BindType Ident Term Term

function type: (x : A) -> B, A -> B, ({x} : A) -> B

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: { p : A ; ...}

R [Assign]

record: { p = a ; ...}

P Term Label

projection: r.p

ExtR Term Term

extension: R ** {x : A} (both types and terms)

Table Term Term

table type: P => A

T TInfo [Case]

table: table {p => c ; ...}

V Type [Term]

table given as course of values: table T [c1 ; ... ; cn]

S Term Term

selection: t ! p

Let LocalDef Term

local definition: let {t : T = a} in b

Q QIdent

qualified constant from a package

QC QIdent

qualified constructor from a package

C Term Term

concatenation: s ++ t

Glue Term Term

agglutination: s + t

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: variants { s ; ... }

Alts Term [(Term, Term)]

alternatives by prefix: pre {t ; s/c ; ...}

Strs [Term]

conditioning prefix strings: strs {s ; ...}

Error String

error values returned by Predef.error

Instances

Instances details
Eq Term Source # 
Instance details

Defined in GF.Grammar.Grammar

Methods

(==) :: Term -> Term -> Bool #

(/=) :: Term -> Term -> Bool #

Ord Term Source # 
Instance details

Defined in GF.Grammar.Grammar

Methods

compare :: Term -> Term -> Ordering #

(<) :: Term -> Term -> Bool #

(<=) :: Term -> Term -> Bool #

(>) :: Term -> Term -> Bool #

(>=) :: Term -> Term -> Bool #

max :: Term -> Term -> Term #

min :: Term -> Term -> Term #

Show Term Source # 
Instance details

Defined in GF.Grammar.Grammar

Methods

showsPrec :: Int -> Term -> ShowS #

show :: Term -> String #

showList :: [Term] -> ShowS #

Binary Term Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

put :: Term -> Put

get :: Get Term

Pretty Term Source # 
Instance details

Defined in GF.Grammar.Printer

Methods

pp :: Term -> Doc Source #

ppList :: [Term] -> Doc Source #

type Type = Term Source #

data BindType Source #

Constructors

Explicit 
Implicit 

Instances

Instances details
Eq BindType Source # 
Instance details

Defined in PGF.Expr

Ord BindType Source # 
Instance details

Defined in PGF.Expr

Show BindType Source # 
Instance details

Defined in PGF.Expr

Binary BindType Source # 
Instance details

Defined in PGF.Binary

Methods

put :: BindType -> Put

get :: Get BindType

data Patt Source #

Patterns

Constructors

PC Ident [Patt]

constructor pattern: C p1 ... pn C

PP QIdent [Patt]

package constructor pattern: P.C p1 ... pn P.C

PV Ident

variable pattern: x

PW

wild card pattern: _

PR [(Label, Patt)]

record pattern: {r = p ; ...} -- only concrete

PString String

string literal pattern: "foo" -- only abstract

PInt Int

integer literal pattern: 12 -- only abstract

PFloat Double

float literal pattern: 1.2 -- only abstract

PT Type Patt

type-annotated pattern

PAs Ident Patt

as-pattern: x@p

PImplArg Patt

placeholder for pattern for implicit argument {p}

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 

Instances

Instances details
Eq Patt Source # 
Instance details

Defined in GF.Grammar.Grammar

Methods

(==) :: Patt -> Patt -> Bool #

(/=) :: Patt -> Patt -> Bool #

Ord Patt Source # 
Instance details

Defined in GF.Grammar.Grammar

Methods

compare :: Patt -> Patt -> Ordering #

(<) :: Patt -> Patt -> Bool #

(<=) :: Patt -> Patt -> Bool #

(>) :: Patt -> Patt -> Bool #

(>=) :: Patt -> Patt -> Bool #

max :: Patt -> Patt -> Patt #

min :: Patt -> Patt -> Patt #

Show Patt Source # 
Instance details

Defined in GF.Grammar.Grammar

Methods

showsPrec :: Int -> Patt -> ShowS #

show :: Patt -> String #

showList :: [Patt] -> ShowS #

Binary Patt Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

put :: Patt -> Put

get :: Get Patt

Pretty Patt Source # 
Instance details

Defined in GF.Grammar.Printer

Methods

pp :: Patt -> Doc Source #

ppList :: [Patt] -> Doc Source #

data TInfo Source #

to guide computation and type checking of tables

Constructors

TRaw

received from parser; can be anything

TTyped Type

type annontated, but can be anything

TComp Type

expanded

TWild Type

just one wild card pattern, no need to expand

Instances

Instances details
Eq TInfo Source # 
Instance details

Defined in GF.Grammar.Grammar

Methods

(==) :: TInfo -> TInfo -> Bool #

(/=) :: TInfo -> TInfo -> Bool #

Ord TInfo Source # 
Instance details

Defined in GF.Grammar.Grammar

Methods

compare :: TInfo -> TInfo -> Ordering #

(<) :: TInfo -> TInfo -> Bool #

(<=) :: TInfo -> TInfo -> Bool #

(>) :: TInfo -> TInfo -> Bool #

(>=) :: TInfo -> TInfo -> Bool #

max :: TInfo -> TInfo -> TInfo #

min :: TInfo -> TInfo -> TInfo #

Show TInfo Source # 
Instance details

Defined in GF.Grammar.Grammar

Methods

showsPrec :: Int -> TInfo -> ShowS #

show :: TInfo -> String #

showList :: [TInfo] -> ShowS #

Binary TInfo Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

put :: TInfo -> Put

get :: Get TInfo

data Label Source #

record label

Constructors

LIdent RawIdent 
LVar Int 

Instances

Instances details
Eq Label Source # 
Instance details

Defined in GF.Grammar.Grammar

Methods

(==) :: Label -> Label -> Bool #

(/=) :: Label -> Label -> Bool #

Ord Label Source # 
Instance details

Defined in GF.Grammar.Grammar

Methods

compare :: Label -> Label -> Ordering #

(<) :: Label -> Label -> Bool #

(<=) :: Label -> Label -> Bool #

(>) :: Label -> Label -> Bool #

(>=) :: Label -> Label -> Bool #

max :: Label -> Label -> Label #

min :: Label -> Label -> Label #

Show Label Source # 
Instance details

Defined in GF.Grammar.Grammar

Methods

showsPrec :: Int -> Label -> ShowS #

show :: Label -> String #

showList :: [Label] -> ShowS #

Binary Label Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

put :: Label -> Put

get :: Get Label

Pretty Label Source # 
Instance details

Defined in GF.Grammar.Printer

Methods

pp :: Label -> Doc Source #

ppList :: [Label] -> Doc Source #

type Context = [Hypo] Source #

type Equation = ([Patt], Term) Source #

type Case = (Patt, Term) Source #

type Altern = (Term, [(Term, Term)]) Source #

Source locations

data Location Source #

Instances

Instances details
Eq Location Source # 
Instance details

Defined in GF.Infra.Location

Ord Location Source # 
Instance details

Defined in GF.Infra.Location

Show Location Source # 
Instance details

Defined in GF.Infra.Location

Binary Location Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

put :: Location -> Put

get :: Get Location

Pretty Location Source # 
Instance details

Defined in GF.Infra.Location

data L a Source #

Attaching location information

Constructors

L Location a 

Instances

Instances details
Functor L Source # 
Instance details

Defined in GF.Infra.Location

Methods

fmap :: (a -> b) -> L a -> L b #

(<$) :: a -> L b -> L a #

Show a => Show (L a) Source # 
Instance details

Defined in GF.Infra.Location

Methods

showsPrec :: Int -> L a -> ShowS #

show :: L a -> String #

showList :: [L a] -> ShowS #

Binary a => Binary (L a) Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

put :: L a -> Put

get :: Get (L a)

Pretty a => Pretty (L a) Source # 
Instance details

Defined in GF.Infra.Location

Methods

pp :: L a -> Doc Source #

ppList :: [L a] -> Doc Source #

unLoc :: L a -> a Source #

noLoc :: a -> L a Source #

ppL :: (Pretty a1, Pretty a3) => L a3 -> a1 -> Doc Source #

PMCFG

data PMCFG Source #

Instances

Instances details
Eq PMCFG Source # 
Instance details

Defined in GF.Grammar.Grammar

Methods

(==) :: PMCFG -> PMCFG -> Bool #

(/=) :: PMCFG -> PMCFG -> Bool #

Show PMCFG Source # 
Instance details

Defined in GF.Grammar.Grammar

Methods

showsPrec :: Int -> PMCFG -> ShowS #

show :: PMCFG -> String #

showList :: [PMCFG] -> ShowS #

Binary PMCFG Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

put :: PMCFG -> Put

get :: Get PMCFG

data Production Source #

Constructors

Production !FId !FunId [[FId]] 

Instances

Instances details
Eq Production Source # 
Instance details

Defined in GF.Grammar.Grammar

Ord Production Source # 
Instance details

Defined in GF.Grammar.Grammar

Show Production Source # 
Instance details

Defined in GF.Grammar.Grammar

Binary Production Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

put :: Production -> Put

get :: Get Production

type FId = Int Source #

type FunId = Int Source #

type SeqId = Int Source #

type Sequence = Array DotPos Symbol Source #

Functions for constructing and analysing source code terms.

funsToAndFrom :: Type -> (Cat, [(Cat, [Int])]) Source #

termForm :: Monad m => Term -> m ([(BindType, Ident)], Term, [Term]) Source #

mkApp :: Term -> [Term] -> Term Source #

Assignment

unzipR :: [Assign] -> ([Label], [Term]) Source #

mapAssignM :: Monad m => (Term -> m c) -> [Assign] -> m [(Label, (Maybe c, c))] Source #

Records

mkRecordN :: Int -> (Int -> Label) -> [Term] -> Term Source #

mkRecord :: (Int -> Label) -> [Term] -> Term Source #

mkRecTypeN :: Int -> (Int -> Label) -> [Type] -> Type Source #

mkRecType :: (Int -> Label) -> [Type] -> Type Source #

Types

Terms

defLinType :: Type Source #

default linearization type

mkFreshVar :: [Ident] -> Ident Source #

refreshing variables

mkFreshVarX :: [Ident] -> Ident -> Ident Source #

trying to preserve a given symbol

freshAsTerm :: String -> Term Source #

quick hack for refining with var in editor

string2term :: String -> Term Source #

create a terminal for concrete syntax

ident2terminal :: Ident -> Term Source #

create a terminal from identifier

Term and pattern conversion

Almost compositional

composSafeOp :: (Term -> Term) -> Term -> Term Source #

to define compositional term functions

composOp :: Monad m => (Term -> m Term) -> Term -> m Term Source #

to define compositional term functions

composPattOp :: Monad m => (Patt -> m Patt) -> Patt -> m Patt Source #

collectOp :: Monoid m => (Term -> m) -> Term -> m Source #

mconcatMap :: Monoid c => (a -> c) -> [a] -> c Source #

collectPattOp :: (Patt -> [a]) -> Patt -> [a] Source #

Misc

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

changeTableType :: Monad m => (Type -> m Type) -> TInfo -> m TInfo Source #

wordsInTerm :: Term -> [String] Source #

to find the word items in a term

sortRec :: [(Label, a)] -> [(Label, a)] Source #

normalize records and record types; put s first

Dependencies

allDependencies :: (ModuleName -> Bool) -> Map Ident Info -> [(Ident, [Ident])] Source #

dependency check, detecting circularities and returning topo-sorted list

Pretty printing

data TermPrintQual Source #

Instances

Instances details
Eq TermPrintQual Source # 
Instance details

Defined in GF.Grammar.Printer

ppParams :: Pretty a1 => TermPrintQual -> [(a1, [(a, Ident, Term)])] -> Doc Source #

ppTerm :: (Ord t, Num t) => TermPrintQual -> t -> Term -> Doc Source #

ppPatt :: (Num a, Ord a) => TermPrintQual -> a -> Patt -> Doc Source #

ppConstrs :: Constraints -> [Doc] Source #

ppMeta :: MetaId -> Doc Source #

Identifiers

newtype ModuleName Source #

Module names

Constructors

MN Ident 

Instances

Instances details
Eq ModuleName Source # 
Instance details

Defined in GF.Infra.Ident

Ord ModuleName Source # 
Instance details

Defined in GF.Infra.Ident

Show ModuleName Source # 
Instance details

Defined in GF.Infra.Ident

Binary ModuleName Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

put :: ModuleName -> Put

get :: Get ModuleName

Pretty ModuleName Source # 
Instance details

Defined in GF.Infra.Ident

data Ident Source #

the constructors labelled INTERNAL are internal representation never returned by the parser

Instances

Instances details
Eq Ident Source # 
Instance details

Defined in GF.Infra.Ident

Methods

(==) :: Ident -> Ident -> Bool #

(/=) :: Ident -> Ident -> Bool #

Ord Ident Source # 
Instance details

Defined in GF.Infra.Ident

Methods

compare :: Ident -> Ident -> Ordering #

(<) :: Ident -> Ident -> Bool #

(<=) :: Ident -> Ident -> Bool #

(>) :: Ident -> Ident -> Bool #

(>=) :: Ident -> Ident -> Bool #

max :: Ident -> Ident -> Ident #

min :: Ident -> Ident -> Ident #

Read Ident Source # 
Instance details

Defined in GF.Infra.Ident

Show Ident Source # 
Instance details

Defined in GF.Infra.Ident

Methods

showsPrec :: Int -> Ident -> ShowS #

show :: Ident -> String #

showList :: [Ident] -> ShowS #

Binary Ident Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

put :: Ident -> Put

get :: Get Ident

Pretty Ident Source # 
Instance details

Defined in GF.Infra.Ident

Methods

pp :: Ident -> Doc Source #

ppList :: [Ident] -> Doc Source #

ident2utf8 :: Ident -> ByteString Source #

This function should be used with care, since the returned ByteString is UTF-8-encoded.

Normal identifiers (returned by the parser)

Special identifiers for internal use

argIdent :: Int -> Ident -> Int -> Ident Source #

to mark argument variables

varStr :: Ident Source #

used in lin defaults

varX :: Int -> Ident Source #

refreshing variables

Raw identifiers

data RawIdent Source #

Identifiers are stored as UTF-8-encoded bytestrings. (It is also possible to use regular Haskell Strings, with somewhat reduced performance and increased memory use.)

Instances

Instances details
Eq RawIdent Source # 
Instance details

Defined in GF.Infra.Ident

Ord RawIdent Source # 
Instance details

Defined in GF.Infra.Ident

Read RawIdent Source # 
Instance details

Defined in GF.Infra.Ident

Show RawIdent Source # 
Instance details

Defined in GF.Infra.Ident

JSON RawIdent Source # 
Instance details

Defined in GF.Grammar.CanonicalJSON

Binary RawIdent Source # 
Instance details

Defined in GF.Infra.Ident

Methods

put :: RawIdent -> Put

get :: Get RawIdent

Pretty RawIdent Source # 
Instance details

Defined in GF.Infra.Ident

Binary serialisation

data VersionTagged a Source #

Constructors

Tagged 

Fields

WrongVersion 

Instances

Instances details
Functor VersionTagged Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

fmap :: (a -> b) -> VersionTagged a -> VersionTagged b #

(<$) :: a -> VersionTagged b -> VersionTagged a #

Binary a => Binary (VersionTagged a) Source # 
Instance details

Defined in GF.Grammar.Binary

Methods

put :: VersionTagged a -> Put

get :: Get (VersionTagged a)

decodeModuleHeader :: MonadIO io => FilePath -> io (VersionTagged Module) Source #

Read just the module header, the returned Module will have an empty body

Canonical GF

grammar2canonical :: Options -> ModuleName -> Grammar -> Grammar Source #

Generate Canonical code for the named abstract syntax and all associated concrete syntaxes

abstract2canonical :: ModuleName -> Grammar -> Abstract Source #

Generate Canonical code for the named abstract syntax

concretes2canonical :: Options -> ModuleName -> Grammar -> [(FilePath, Concrete)] Source #

Generate Canonical code for the all concrete syntaxes associated with the named abstract syntax in given the grammar.

projection :: LinValue -> LabelId -> LinValue Source #

Smart constructor for projections

selection :: LinValue -> LinValue -> LinValue Source #

Smart constructor for selections