removed obsolete items from doc

This commit is contained in:
aarne
2008-06-27 11:21:49 +00:00
parent 62bca15468
commit c878a7561c
14 changed files with 0 additions and 5242 deletions

Binary file not shown.

View File

@@ -1,424 +0,0 @@
This is an API for the user of the resource grammar for adding
lexical items. It gives functions for forming expressions of open
categories: nouns, adjectives, verbs.
Closed categories (determiners, pronouns, conjunctions) are
accessed through the resource syntax API, {\tt Structural.gf}.
The main difference with {\tt MorphoRus.gf} is that the types
referred to are compiled resource grammar types. We have moreover
had the design principle of always having existing forms, rather
than stems, as string arguments of the paradigms.
The structure of functions for each word class {\tt C} is the following:
first we give a handful of patterns that aim to cover all
regular cases. Then we give a worst-case function {\tt mkC}, which serves as an
escape to construct the most irregular words of type {\tt C}.
%However, this function should only seldom be needed: we have a
%separate module {\tt IrregularEng}, which covers all irregularly inflected
words.
The following modules are presupposed:
\begin{verbatim}
resource ParadigmsRus = open
(Predef=Predef),
Prelude,
MorphoRus,
CatRus,
NounRus
in {
flags coding=utf8 ;
\end{verbatim}
\textbf{Parameters}
To abstract over gender names, we define the following identifiers.
\begin{verbatim}
oper
Gender : Type ;
masculine : Gender ;
feminine : Gender ;
neuter : Gender ;
\end{verbatim}
To abstract over case names, we define the following.
\begin{verbatim}
Case : Type ;
nominative : Case ;
genitive : Case ;
dative : Case ;
accusative : Case ;
instructive : Case ;
prepositional : Case ;
\end{verbatim}
In some (written in English) textbooks accusative case
is put on the second place. However, we follow the case order
standard for Russian textbooks.
To abstract over number names, we define the following.
\begin{verbatim}
Number : Type ;
singular : Number ;
plural : Number ;
Animacy: Type ;
animate: Animacy;
inanimate: Animacy;
\end{verbatim}
\textbf{Nouns}
Best case: indeclinabe nouns: {\cyr kofe}, {\cyr
pal\cyrsftsn{}to}, {\cyr VUZ}.
\begin{verbatim}
mkIndeclinableNoun: Str -> Gender -> Animacy -> N ;
\end{verbatim}
Worst case - give six singular forms:
Nominative, Genetive, Dative, Accusative, Instructive and Prepositional;
corresponding six plural forms and the gender.
May be the number of forms needed can be reduced,
but this requires a separate investigation.
Animacy parameter (determining whether the Accusative form is equal
to the Nominative or the Genetive one) is actually of no help,
since there are a lot of exceptions and the gain is just one form less.
\begin{verbatim}
mkN : (nomSg, genSg, datSg, accSg, instSg, preposSg,
nomPl, genPl, datPl, accPl, instPl, preposPl: Str)
-> Gender -> Animacy -> N ;
\end{verbatim}
({\cyr \em muzhchina, muzhchinu, muzhchine, muzhchinu,
muzhchino\cyrishrt{}, muzhchine}
\noindent {\cyr \em muzhchin\cyrery{}, muzhchin, muzhchinam,
muzhchin, muzhchinami, muzhchinah})
\vspace{5mm}
The regular function captures the variants for some popular nouns
endings from the list below:
\begin{verbatim}
regN : Str -> N ;
\end{verbatim}
Here are some common patterns. The list is far from complete.
\subsubsection{Feminine patterns}
\noindent feminine, inanimate, ending with "-a", Inst -"{\cyr
mashin-o\cyrishrt{}}":
\begin{verbatim}
nMashina : Str -> N ;
\end{verbatim}
feminine, inanimate, ending with "-a", Inst -"{\cyr
edinic-e\cyrishrt{}}":
\begin{verbatim}
nEdinica : Str -> N ;
\end{verbatim}
feminine, animate, ending with "-a":
\begin{verbatim}
nZhenchina : Str -> N ;
\end{verbatim}
feminine, inanimate, ending with "{\cyr g\_k\_h-a}":
\begin{verbatim}
nNoga : Str -> N ;
\end{verbatim}
feminine, inanimate, ending with "-{\cyr -iya}":
\begin{verbatim}
nMalyariya : Str -> N ;
\end{verbatim}
feminine, animate, ending with "{\cyr -ya}":
\begin{verbatim}
nTetya : Str -> N ;
\end{verbatim}
feminine, inanimate, ending with "-{\cyr \cyrsftsn{}}"(soft sign):
\begin{verbatim}
nBol : Str -> N ;
\end{verbatim}
\subsubsection{Neuter patterns}
\noindent neutral, inanimate, ending with "-ee":
\begin{verbatim}
nObezbolivauchee : Str -> N ;
\end{verbatim}
neutral, inanimate, ending with "-e":
\begin{verbatim}
nProizvedenie : Str -> N ;
\end{verbatim}
neutral, inanimate, ending with "-o":
\begin{verbatim}
nChislo : Str -> N ;
\end{verbatim}
neutral, inanimate, ending with "-{\cyr oe}":
\begin{verbatim}
nZhivotnoe : Str -> N ;
\end{verbatim}
\subsubsection{Masculine patterns}
\noindent Ending with consonant:
\noindent masculine, inanimate, ending with "-{\cyr el}"- "{\cyr
pep-la}":
\begin{verbatim}
nPepel : Str -> N ;
\end{verbatim}
animate, "{\cyr brat-\cyrsftsn{}ya}":
\begin{verbatim}
nBrat : Str -> N ;
\end{verbatim}
same as above, but inanimate:
\begin{verbatim}
nStul : Str -> N ;
\end{verbatim}
"{\cyr malyshe\cyrishrt{}}":
\begin{verbatim}
nMalush : Str -> N ;
\end{verbatim}
"{\cyr potol-ok, potol-ka}"
\begin{verbatim}
nPotolok : Str -> N ;
\end{verbatim}
the next four differ in plural nominative and/or accusative
form(s):
\noindent {\cyr bank-i}(Nom=Acc):
\begin{verbatim}
nBank : Str -> N ;
\end{verbatim}
same as above, but animate:
\begin{verbatim}
nStomatolog : Str -> N ;
\end{verbatim}
"{\cyr adres-a}" (Nom=Acc):
\begin{verbatim}
nAdres : Str -> N ;
\end{verbatim}
"{\cyr telefony}" (Nom=Acc):
\begin{verbatim}
nTelefon : Str -> N ;
\end{verbatim}
masculine, inanimate, ending with "{\cyr \cyrsftsn{}}" (soft
sign):
\begin{verbatim}
nNol : Str -> N ;
\end{verbatim}
masculine, inanimate, ending with "{\cyr -en\cyrsftsn{}}":
\begin{verbatim}
nUroven : Str -> N ;
\end{verbatim}
Nouns used as functions need a preposition. The most common is with Genitive.
\begin{verbatim}
mkFun : N -> Prep -> N2 ;
mkN2 : N -> N2 ;
mkN3 : N -> Prep -> Prep -> N3 ;
\end{verbatim}
\subsubsection{Proper names}
{\cyr Ivan, Masha}:
\begin{verbatim}
mkPN : Str -> Gender -> Animacy -> PN ;
\end{verbatim}
\begin{verbatim}
nounPN : N -> PN ;
\end{verbatim}
On the top level, it is maybe {\tt CN} that is used rather than {\tt N}, and
{\tt NP} rather than {\tt PN}.
\begin{verbatim}
mkCN : N -> CN ;
mkNP : Str -> Gender -> Animacy -> NP ;
\end{verbatim}
\textbf{Adjectives}
Non-comparison (only positive degree) one-place adjectives need 28
(4 by 7) forms in the worst case: (Masculine | Feminine | Neutral
| Plural) * (Nominative | Genitive | Dative | Accusative Inanimate
| Accusative Animate | Instructive | Prepositional). Notice that 4
short forms, which exist for some adjectives are not included in
the current description, otherwise there would be 32 forms for
positive degree.
The regular function captures the variants for some popular
adjective endings below. The first string agrument is the
masculine singular form, the second is comparative:
\begin{verbatim}
regA : Str -> Str -> A ;
\end{verbatim}
\noindent Invariable adjective is a special case: {\cyr haki,
mini, hindi, netto}:
\begin{verbatim}
adjInvar : Str -> A ;
\end{verbatim}
Some regular patterns depending on the ending.
\noindent ending with "{\cyr y\cyrishrt{}}":
\begin{verbatim}
AStaruyj : Str -> Str -> A ;
\end{verbatim}
ending with "{\cyr i\cyrishrt{}}", Gen - "{\cyr
malen\cyrsftsn{}k-ogo}":
\begin{verbatim}
AMalenkij : Str -> Str -> A ;
\end{verbatim}
ending with "{\cyr i\cyrishrt{}}", Gen - "{\cyr horosh-ego}":
\begin{verbatim}
AKhoroshij : Str -> Str -> A ;
\end{verbatim}
ending with "{\cyr o\cyrishrt{}}", plural - "{\cyr molod-ye}":
\begin{verbatim}
AMolodoj : Str -> Str -> A ;
\end{verbatim}
ending with "{\cyr o\cyrishrt{}}", plural - "{\cyr kak-ie}":
\begin{verbatim}
AKakoj_Nibud : Str -> Str -> Str -> A ;
\end{verbatim}
Two-place adjectives need a preposition and a case as extra arguments.
"{\cyr delim na}":
\begin{verbatim}
mkA2 : A -> Str -> Case -> A2 ;
\end{verbatim}
Comparison adjectives need a positive adjective (28 forms without
short forms). Taking only one comparative form (non-syntactic) and
only one superlative form (syntactic) we can produce the
comparison adjective with only one extra argument - non-syntactic
comparative form. Syntactic forms are based on the positive forms.
\begin{verbatim}
mkADeg : A -> Str -> ADeg ;
\end{verbatim}
On top level, there are adjectival phrases. The most common case
is just to use a one-place adjective.
\begin{verbatim}
ap : A -> IsPostfixAdj -> AP ;
\end{verbatim}
\textbf{Adverbs}
Adverbs are not inflected. %Most lexical ones have position after the verb. Some can be preverbal (e.g. {\it always}).
\begin{verbatim}
mkAdv : Str -> Adv ;
\end{verbatim}
\textbf{Verbs}
In our lexicon description ({\it Verbum}) there are 62 forms: 2
(Voice) by { 1 (infinitive) + [2(number) by 3
(person)](imperative) + [ [2(Number) by 3(Person)](present) +
[2(Number) by 3(Person)](future) + 4(GenNum)(past) ](indicative)+
4 (GenNum) (subjunctive) } Participles (Present and Past) and
Gerund forms are not included, since they fuction more like
Adjectives and Adverbs correspondingly rather than verbs. Aspect
is regarded as an inherent parameter of a verb. Notice, that some
forms are never used for some verbs. %Actually, the majority of verbs do not have many of the forms.
\begin{verbatim}
Voice: Type;
Aspect: Type;
Tense : Type;
Bool: Type;
Conjugation: Type ;
\end{verbatim}
"{\cyr gulya-Esh\cyrsftsn{}, gulya-Em}":
\begin{verbatim}
first: Conjugation;
\end{verbatim}
\noindent Verbs with vowel "{\cyr \cyryo}": "{\cyr
da\cyryo{}sh\cyrsftsn{}}" (give), "{\cyr
p\cyrsftsn{}\cyryo{}sh\cyrsftsn{}}" (drink):
\begin{verbatim}
firstE: Conjugation;
\end{verbatim}
\noindent "{\cyr vid-Ish\cyrsftsn{}, vid-Im}":
\begin{verbatim}
second: Conjugation;
\end{verbatim}
"{\cyr hoch-Esh\cyrsftsn{}, hot-Im}":
\begin{verbatim}
mixed: Conjugation;
\end{verbatim}
irregular:
\begin{verbatim}
dolzhen: Conjugation;
true: Bool;
false: Bool;
active: Voice ;
passive: Voice ;
imperfective: Aspect;
perfective: Aspect ;
\end{verbatim}
The worst case need 6 forms of the present tense in indicative
mood ({\cyr ya begu}, {\cyr ty bezhish\cyrsftsn{}}, {\cyr on
bezhit}, {\cyr my bezhim}, {\cyr vy bezhite}, {\cyr oni begut}), a
past form (singular, masculine: {\cyr ya bezhal}), an imperative
form (singular, second person: {\cyr begi}), an infinitive ({\cyr
bezhat\cyrsftsn{}}). Inherent aspect should also be specified.
\begin{verbatim}
mkVerbum : Aspect -> (presentSgP1,presentSgP2,presentSgP3,
presentPlP1,presentPlP2,presentPlP3,
pastSgMasculine,imperative,infinitive: Str) -> V ;
\end{verbatim}
Common conjugation patterns are two conjugations: first - verbs
ending with {\cyr -at\cyrsftsn{}/-yat\cyrsftsn{}} and second -
{\cyr -it\cyrsftsn{}/-et\cyrsftsn{}}. Instead of 6 present forms
of the worst case, we only need a present stem and one ending
(singular, first person): {\cyr ya l\cyryu{}bl\cyryu{}}, {\cyr ya
zhdu}, etc. To determine where the border between stem and ending
lies it is sufficient to compare first person from with second
person form: {\cyr ya l\cyryu{}bl\cyryu{}}, {\cyr ty
l\cyryu{}bish\cyrsftsn{}}. Stems should be the same. So the
definition for verb {\cyr l\cyryu{}bit\cyrsftsn{}} looks like:
\texttt{regV Imperfective Second }"{\cyr l\cyryu{}b}" "{\cyr
l\cyryu{}}" "{\cyr l\cyryu{}bil}" "{\cyr l\cyryu{}bi}" "{\cyr
l\cyryu{}bit\cyrsftsn{}}";
\begin{verbatim}
regV : Aspect -> Conjugation -> (stemPresentSgP1,
endingPresentSgP1,pastSgP1,imperative,infinitive: Str) -> V ;
\end{verbatim}
For writing an application grammar one usually doesn't need the
whole inflection table, since each verb is used in a particular
context that determines some of the parameters (Tense and Voice
while Aspect is fixed from the beginning) for certain usage. The
{\it V} type, that have these parameters fixed. We can extract the
{\it V} from the lexicon.
\begin{verbatim}
mkV : Verbum -> Voice -> V ;
mkPresentV : Verbum -> Voice -> V ;
\end{verbatim}
Two-place verbs, and the special case with direct object. Notice
that a particle can be included in a {\tt V}.
\noindent "{\cyr vo\cyrishrt{}ti v dom}", "{\cyr v}", accusative:
\begin{verbatim}
mkV2 : V -> Str -> Case -> V2 ;
\end{verbatim}
{\cyr slozhit\cyrsftsn{} pic\cyrsftsn{}mo v konvert}:
\begin{verbatim}
mkV3 : V -> Str -> Str -> Case -> Case -> V3 ;
\end{verbatim}
"{\cyr videt\cyrsftsn{}}", "{\cyr l\cyryu{}bit\cyrsftsn{}}":
\begin{verbatim}
dirV2 : V -> V2 ;
tvDirDir : V -> V3 ;
\end{verbatim}
The definitions should not bother the user of the API. So they are
hidden from the document.

View File

@@ -1,546 +0,0 @@
<html>
<body bgcolor="#FFFFFF" text="#000000">
<center>
<h1>Grammatical Framework Version 2</h1>
Release of Version 2.0
<p>
Planned: 24 June 2004
<p>
<a href="http://www.cs.chalmers.se/~aarne">Aarne Ranta</a>
</center>
<!-- NEW -->
<h2>Highlights</h2>
Module system.
<p>
Separate compilation to canonical GF.
<p>
Improved GUI.
<p>
Improved parser generation.
<p>
Improved shell (new commands and options, help, error messages).
<p>
Accurate <a href="DocGF.pdf">language specification</a>
(also of GFC).
<p>
Extended resource library.
<p>
Extended Numerals library.
<!-- NEW -->
<h2>Module system</h2>
<li> Separate modules for <tt>abstract</tt>,
<tt>concrete</tt>, and <tt>resource</tt>.
<li> Replaces the file-based <tt>include</tt> system
<li> Name space handling with qualified names
<li> Hierarchic structure (single inheritance <tt>**</tt>) +
cross-cutting reuse (<tt>open</tt>)
<li> Separate compilation, one module per file
<li> Reuse of <tt>abstract</tt>+<tt>concrete</tt> as <tt>resource</tt>
<li> Parametrized modules:
<tt>interface</tt>, <tt>instance</tt>, <tt>incomplete</tt>.
<li> New experimental module types: <tt>transfer</tt>,
<tt>union</tt>.
<!-- NEW -->
<h4>Canonical format GFC</h4>
<li> The target of GF compiler; to reuse, just read in.
<li> Readable by Haskell/Java/C++/C applications (by BNFC generated parsers).
<!-- NEW -->
<h4>New features in expression language</h4>
In addition to the module system:
<p>
<li> Disjunctive patterns <tt>P | ... | Q</tt>.
<li> String patterns <tt>"foo"</tt>.
<li> (?) Integer patterns <tt>74</tt>.
<li> Binding token <tt>&+</tt> to glue separate tokens at unlexing phase,
and unlexer to resolve this.
<li> New syntax alternatives for local definitions: <tt>let</tt> without
braces and <tt>where</tt>.
<li> Pattern variables can be used on lhs's of <tt>oper</tt> definitions.
<li> New Unicode transliterations (by Harad Hammarström).
<!-- NEW -->
<h4>New shell commands and command functionalities</h4>
<li> <tt>pi</tt> = <tt>print_info</tt>: information on an identifier in scope.
<li> <tt>h</tt> = <tt>help</tt> now in long or short form,
and on individual commands.
<li> <tt>gt</tt> = <tt>generate_trees</tt>: all trees of a given
category or instantiations of a given incomplete term, up to a
given depth.
<li> <tt>gr</tt> = <tt>generate_random</tt> can now be given
an incomplete term as an argument, to constrain generation.
<li> <tt>so</tt> = <tt>show_opers</tt> shows all <tt>ope</tt>
operations with a given value type.
<li> <tt>pm</tt> = <tt>print_multi</tt> prints the multilingual
grammar resident in the current state to a ready-compiles
<tt>.gfcm</tt> file.
<li> All commands have both long and short names (see help). Short
names are easier to type, whereas long names
make scripts more readable.
<li> Meaningless command options generate warnings.
<!-- NEW -->
<h4>New editor features</h4>
<li> Active text field: click the middle button in the focus to send
in refinement through the parser.
<li> Clipboard: copy complex terms into the refine menu.
<li> Two-step refinements generated by the "Generate" operation.
<!-- NEW -->
<h4>Improved implementation</h4>
<li> Haskell source code is organized into subdirectories.
<li> BNF Converter is used for defining the languages GF and GFC, which also
give reliable LaTeX documentation.
<li> Lexical rules sorted out by option <tt>-cflexer</tt> for efficient
parsing with large lexica.
<li> GHC optimizations and strictness flags are used for improving performance.
<!-- NEW -->
<h4>New parser (work in progress)</h4>
<li> By Peter Ljunglöf, based on MCFG.
<li> Much more efficient for morphology and discontinuous constituents.
<li> Treatment of cyclic rules.
<li> Currently lots of alternative parsers via flags <tt>-parser=newX</tt>.
<!-- NEW -->
<h2>Status (21/6/2004)</h2>
Grammar compiler, editor GUIs, and shell work for all platforms
(with restrictions for Solaris).
<p>
The updated <tt>HelpFile</tt> (accessible through <tt>h</tt> command)
marks unsupported features present in GF 1.2 with <tt>*</tt>.
They will be supported again if interested users appear.
<p>
GF1 grammars can be automatically translated to GF2 (although the
result is not as good
as manual, since indentation and comments are destroyed). The results can be
saved in GF2 files, but this is not necessary.
Some rarely used GF1 features are no longer supported (see next section).
<p>
It is also possible to write a GF2 grammar back to GF1, with the
command <tt>pg -printer=old</tt>.
<!-- NEW -->
Resource libraries
and some example grammars and have been
converted. Most old example grammars work without any changes.
There is a new resource API with
many new constructions.
<p>
A make facility works, finding out which modules have to be recompiled.
<p>
Soundness checking of module depencencies and completeness is not
complete. This means that some errors may show up too late.
<p>
The environment variable <tt>GF_LIB_PATH</tt> needs some more work.
<p>
Latex and XML printing of grammars do not work yet.
<!-- NEW -->
<h2>How to use GF 1.* files</h2>
Backward compatibility with respect to old GF grammars has been
a central goal. All GF grammars, from version 0.9, should work in
the old way in GF2. The main exceptions are some features that
are rarely used.
<ul>
<li> The <tt>package</tt> system introduced in GF 1.2, cannot be
interpreted in the module system of GF 2.0, since packages are in
mutual scope with the top level.
<li> <tt>tokenizer</tt> pragmas are cannot be parsed any more. In GF
1.2, they are already replaced by <tt>lexer</tt> flags.
<li> <tt>var</tt> pragmas cannot be parsed any more.
</ul>
<p>
Very old GF grammars (from versions before 0.9), with the completely
different notation, do not work. They should be first converted to
GF1 by using GF version 1.2.
<!-- NEW -->
The import command <tt>i</tt> can be given the option <tt>-old</tt>. E.g.
<pre>
i -old tut1.Eng.g2
</pre>
But this is no more necessary: GF2 detects automatically if a grammar
is in the GF1 format.
<p>
Importing a set of GF2 files generates, internally, three modules:
<pre>
abstract tut1 = ...
resource ResEng = ...
concrete Eng of tut1 = open ResEng in ...
</pre>
(The names are different if the file name has fewer parts.)
<p>
The option <tt>-o</tt> causes GF2 to write these modules into files.
<!-- NEW -->
The flags <tt>-abs</tt>, <tt>-cnc</tt>, and <tt>-res</tt> can be used
to give custom names to the modules. In particular, it is good to use
the <tt>-abs</tt> flag to guarantee that the abstract syntax module
has the same name for all grammars in a multilingual environmens:
<pre>
i -old -abs=Numerals hungarian.gf
i -old -abs=Numerals tamil.gf
i -old -abs=Numerals sanskrit.gf
</pre>
<p>
The same flags as in the import command can be used when invoking
GF2 from the system shell. Many grammars can be imported on the same command
line, e.g.
<pre>
% gf2 -old -abs=Tutorial tut1.Eng.gf tut1.Fin.gf tut1.Fra.gf
</pre>
<p>
To write a GF2 grammar back to GF1 (as one big file), use the command
<pre>
> pg -old
</pre>
<!-- NEW -->
GF2 has more reserved words than GF 1.2. When old files are read, a preprocessor
replaces every identifier that has the shape of a new reserved word
with a variant where the last letter is replaced by <tt>Z</tt>, e.g.
<tt>instance</tt> is replaced by <tt>instancZ</tt>. This method is of course
unsafe and should be replaced by something better.
<!-- NEW -->
<h2>Abstract, concrete, and resource modules</h2>
Judgement forms are sorted as follows:
<ul>
<li> abstract:
<tt>cat</tt>, <tt>fun</tt>, <tt>def</tt>, <tt>data</tt>, <tt>flags</tt>
<li> concrete:
<tt>lincat</tt>, <tt>cat</tt>, <tt>printname</tt>, <tt>flags</tt>
<li> resource:
<tt>param</tt>, <tt>oper</tt>, <tt>flags</tt>
<li>
</ul>
<!-- NEW -->
Example:
<pre>
abstract Sums = {
cat
Exp ;
fun
One : Exp ;
plus : Exp -> Exp -> Exp ;
}
concrete EnglishSums of Sums = open ResEng in {
lincat
Exp = {s : Str ; n : Number} ;
lin
One = expSg "one" ;
sum x y = expSg ("the" ++ "sum" ++ "of" ++ x.s ++ "and" ++ y.s) ;
}
resource ResEng = {
param
Number = Sg | Pl ;
oper
expSG : Str -> {s : Str ; n : Number} = \s -> {s = s ; n = Sg} ;
}
</pre>
<!-- NEW -->
<h2>Opening and extending modules</h2>
A <tt>concrete</tt> or <tt>resource</tt> can <b>open</b> a
<tt>resource</tt>. This means that
<ul>
<li> the names defined in <tt>resource</tt> can be used ("become visible")
<li> but: these names are not included in ("exported from") the opening module
</ul>
A module of any type can moreover <b>extend</b> a module of the same type.
This means that
<ul>
<li> the names defined in the extended module can be used ("become visible")
<li> and also: these names are included in ("exported from") the extending module
</ul>
Examples of extension:
<pre>
abstract Products = Sums ** {
fun times : Exp -> Exp -> Exp ;
}
-- names exported: Exp, plus, times
concrete English of Products = EnglishSums ** open ResEng in {
lin times x y = expSg ("the" ++ "product" ++ "of" ++ x.s ++ "and" ++ y.s) ;
}
</pre>
Another important difference:
<li> extension is single
<li> opening can be multiple: <tt>open Foo, Bar, Baz in {...}</tt>
<!-- NEW -->
Moreover:
<li> opening can be <b>qualified</b>
<p>
Example of qualified opening:
<pre>
concrete NumberSystems of Systems = open (Bin = Binary), (Dec = Decimal) in {
lin
BZero = Bin.Zero ;
DZero = Dec.Zero
}
</pre>
<!-- NEW -->
<h2>Compiling modules</h2>
Separate compilation assumes there is <b>one module per file</b>.
<p>
The <b>module header</b> is the beginning of the module code up to the
first left bracket (<tt>{</tt>). The header gives
<ul>
<li> the module type: <tt>abstract</tt>, <tt>concrete</tt> (<tt>of</tt> <i>A</i>),
or <tt>resource</tt>
<li> the name of the module (next to the module type keyword)
<li> the name of extended module (between <tt>=</tt> and <tt>**</tt>)
<li> the names of opened modules
</ul>
<!-- NEW -->
<b>filename</b> = <b>modulename</b> <tt>.</tt> <b>extension</b>
<p>
File name extensions:
<ul>
<li> <tt>gf</tt>: GF source file (uses GF syntax, is type checked and compiled)
<li> <tt>gfc</tt>: canonical GF file (uses GFC syntax, is simply read
in instead of compiled; produced from all kinds of modules)
<li> <tt>gfr</tt>: GF resource file (uses GF syntax, is only read in; produced from
<tt>resource</tt> modules)
<li> <tt>gfcm</tt>: canonical multilingual GF file
(uses GFC syntax, is only read in; produced
from a set of <tt>abstract</tt> and <tt>conctrete</tt> modules)
</ul>
Only <tt>gf</tt> files should ever be written/edited manually!
<!-- NEW -->
What the make facility does when compiling <tt>Foo.gf</tt>
<ol>
<li> read the module header of <tt>Foo.gf</tt>, and recursively all headers from
the modules it <b>depends</b> on (i.e. extends or opens)
<li> build a dependency graph of these modules, and do topological sorting
<li> starting from the first module in topological order,
compare the modification times of each <tt>gf</tt> and <tt>gfc</tt> file:
<ul>
<li> if <tt>gf</tt> is later, compile the module and all modules depending on it
<li> if <tt>gfc</tt> is later, just read in the module
</ul>
</ol>
Inside the GF shell, also time stamps of modules read into memory are
taken into account. Thus a module need not be read from a file if the
module is in the memory and the file has not been modified.
<!-- NEW -->
If the compilation of a grammar fails at some module, the state of the
GF shell contains all modules read up to that point. This makes it
faster to compile the faulty module again after fixing it.
<p>
Use the command <tt>po</tt> = <tt>print_options</tt> to see what
modules are in the state.
<p>
To force compilation:
<ul>
<li> The flag <i>-src</i> in the import command forces compilation from
source even if more recent object files exist. This is useful
when testing new versions of GF.
<li> The flag <i>-retain</i> in the import command forces reading in
<tt>gfr</tt> files in addition to <tt>gfc</tt> files. This is useful
when testing operations with the <tt>cc</tt> command.
</ul>
<!-- NEW -->
<h2>Module search paths</h2>
Modules can reside in different directories. Use the <tt>path</tt>
flag to extend the directory search path. For instance,
<pre>
-path=.:../resource/russian:../prelude
</pre>
enables files to be found in three different directories.
By default, only the current directory is included.
If a <tt>path</tt> flag is given, the current directory
<tt>.</tt> must be explicitly included if it is wanted.
<p>
The <tt>path</tt> flag can be set in any of the following
places:
<ul>
<li> when invoking GF: <tt>gf -path=xxx</tt>
<li> when importing a module: <tt>i -path=xxx Foo.gf</tt>
<li> as a pragma in a topmost file: <tt>--# -path=xxx</tt>
</ul>
A flag set on a command line overrides ones set in files.
<p>
The value of the environment variable <tt>GF_LIB_PATH</tt> is
appended to the user-given path.
<!-- NEW -->
<h2>To do</h2>
Testing
<p>
Documentation
<p>
Packaging
<!-- NEW -->
<h2>Nasty details</h2>
<li> Readline in Solaris
<li> Proper treatment file search paths
<li> Unicode fonts in GUIs
<li> directionality of Semitic alphabets
</body>
</html>

View File

@@ -1,7 +0,0 @@
\documentclass[11pt,a4paper]{article}
\usepackage[T2A,OT1]{fontenc}
\usepackage[ot2enc]{inputenc}
\usepackage[russian,german,french,english]{babel}
\usepackage{isolatin1} % user defined package

View File

@@ -1,893 +0,0 @@
==GF Resource Grammar Library: Synopsis==
==Syntax==
[source ../api/Constructors.gf]
|| Function | Type | Example ||
| ``mkText`` | ``Phr -> Text`` | //But John walks.// |
| ``mkText`` | ``Phr -> (Punct) -> (Text) -> Text`` | //John walks? Yes.// |
| ``mkText`` | ``Utt -> Text`` | //John.// |
| ``mkText`` | ``S -> Text`` | //John walked.// |
| ``mkText`` | ``Cl -> Text`` | //John walks.// |
| ``mkText`` | ``QS -> Text`` | //Did John walk?// |
| ``mkText`` | ``Imp -> Text`` | //Walk!// |
| ``emptyText`` | ``Text`` | //(empty text)// |
| ``fullStopPunct`` | ``Punct`` | //.// |
| ``questMarkPunct`` | ``Punct`` | //?// |
| ``exclMarkPunct`` | ``Punct`` | //!// |
| ``mkPhr`` | ``Utt -> Phr`` | //why// |
| ``mkPhr`` | ``(PConj) -> Utt -> (Voc) -> Phr`` | //but why John// |
| ``mkPhr`` | ``S -> Phr`` | //John walked// |
| ``mkPhr`` | ``Cl -> Phr`` | //John walks// |
| ``mkPhr`` | ``QS -> Phr`` | //did John walk// |
| ``mkPhr`` | ``Imp -> Phr`` | //walk// |
| ``mkPConj`` | ``Conj -> PConj`` | //and// |
| ``mkVoc`` | ``NP -> Voc`` | //John// |
| ``mkUtt`` | ``S -> Utt`` | //John walked// |
| ``mkUtt`` | ``Cl -> Utt`` | //John walks// |
| ``mkUtt`` | ``QS -> Utt`` | //did John walk// |
| ``mkUtt`` | ``Imp -> Utt`` | //love yourself// |
| ``mkUtt`` | ``(ImpForm) -> (Pol) -> Imp -> Utt`` | //don't love yourselves// |
| ``mkUtt`` | ``IP -> Utt`` | //who// |
| ``mkUtt`` | ``IAdv -> Utt`` | //why// |
| ``mkUtt`` | ``NP -> Utt`` | //John// |
| ``mkUtt`` | ``Adv -> Utt`` | //here// |
| ``mkUtt`` | ``VP -> Utt`` | //to walk// |
| ``lets_Utt`` | ``VP -> Utt`` | //let's walk// |
| ``positivePol`` | ``Pol`` | //(John walks) [default]// |
| ``negativePol`` | ``Pol`` | //(John doesn't walk)// |
| ``simultaneousAnt`` | ``Ant`` | //(John walks) [default]// |
| ``anteriorAnt`` | ``Ant`` | //(John has walked) --# notpresent// |
| ``presentTense`` | ``Tense`` | //(John walks) [default]// |
| ``pastTense`` | ``Tense`` | //(John walked) --# notpresent// |
| ``futureTense`` | ``Tense`` | //(John will walk) --# notpresent// |
| ``conditionalTense`` | ``Tense`` | //(John would walk) --# notpresent// |
| ``singularImpForm`` | ``ImpForm`` | //(help yourself) [default]// |
| ``pluralImpForm`` | ``ImpForm`` | //(help yourselves)// |
| ``politeImpForm`` | ``ImpForm`` | //(help yourself) (polite singular)// |
| ``mkS`` | ``Cl -> S`` | //John walks// |
| ``mkS`` | ``(Tense) -> (Ant) -> (Pol) -> Cl -> S`` | //John wouldn't have walked// |
| ``mkS`` | ``Conj -> S -> S -> S`` | //John walks and I run// |
| ``mkS`` | ``Conj -> ListS -> S`` | //John walks, I run and you sleep// |
| ``mkS`` | ``DConj -> S -> S -> S`` | //either John walk or I run// |
| ``mkS`` | ``DConj -> ListS -> S`` | //either John walks, I run or you sleep// |
| ``mkS`` | ``Adv -> S -> S`` | //today, John walks// |
| ``mkCl`` | ``NP -> V -> Cl`` | //John walks// |
| ``mkCl`` | ``NP -> V2 -> NP -> Cl`` | //John loves her// |
| ``mkCl`` | ``NP -> V3 -> NP -> NP -> Cl`` | //John sends it to her// |
| ``mkCl`` | ``NP -> VV -> VP -> Cl`` | //John wants to walk// |
| ``mkCl`` | ``NP -> VS -> S -> Cl`` | //John says that it is good// |
| ``mkCl`` | ``NP -> VQ -> QS -> Cl`` | //John wonders if it is good// |
| ``mkCl`` | ``NP -> VA -> AP -> Cl`` | //John becomes old// |
| ``mkCl`` | ``NP -> V2A ->NP -> AP -> Cl`` | //John paints it red// |
| ``mkCl`` | ``NP -> A -> Cl`` | //John is old// |
| ``mkCl`` | ``NP -> A -> NP -> Cl`` | //John is older than her// |
| ``mkCl`` | ``NP -> A2 -> NP -> Cl`` | //John is married to her// |
| ``mkCl`` | ``NP -> AP -> Cl`` | //John is very old// |
| ``mkCl`` | ``NP -> N -> Cl`` | //John is a man// |
| ``mkCl`` | ``NP -> CN -> Cl`` | //John is an old man// |
| ``mkCl`` | ``NP -> NP -> Cl`` | //John is the man// |
| ``mkCl`` | ``NP -> Adv -> Cl`` | //John is here// |
| ``mkCl`` | ``NP -> VP -> Cl`` | //John walks here// |
| ``mkCl`` | ``V -> Cl`` | //it rains// |
| ``mkCl`` | ``VP -> Cl`` | //it is raining// |
| ``mkCl`` | ``N -> Cl`` | //there is a house// |
| ``mkCl`` | ``CN -> Cl`` | //there is an old houses// |
| ``mkCl`` | ``NP -> Cl`` | //there are five houses// |
| ``mkCl`` | ``NP -> RS -> Cl`` | //it is John that walks// |
| ``mkCl`` | ``Adv -> S -> Cl`` | //it is here John walks// |
| ``genericCl`` | ``VP -> Cl`` | //one walks// |
| ``mkVP`` | ``V -> VP`` | //walk// |
| ``mkVP`` | ``V2 -> NP -> VP`` | //love her// |
| ``mkVP`` | ``V3 -> NP -> NP -> VP`` | //send it to her// |
| ``mkVP`` | ``VV -> VP -> VP`` | //want to walk// |
| ``mkVP`` | ``VS -> S -> VP`` | //know that she walks// |
| ``mkVP`` | ``VQ -> QS -> VP`` | //ask if she walks// |
| ``mkVP`` | ``VA -> AP -> VP`` | //become old// |
| ``mkVP`` | ``V2A -> NP -> AP -> VP`` | //paint it red// |
| ``mkVP`` | ``A -> VP`` | //be warm// |
| ``mkVP`` | ``AP -> VP`` | //be very warm// |
| ``mkVP`` | ``A -> NP -> VP`` | //be older than her// |
| ``mkVP`` | ``A2 -> NP -> VP`` | //be married to her// |
| ``mkVP`` | ``N -> VP`` | //be a man// |
| ``mkVP`` | ``CN -> VP`` | //be an old man// |
| ``mkVP`` | ``NP -> VP`` | //be the man// |
| ``mkVP`` | ``Adv -> VP`` | //be here// |
| ``mkVP`` | ``VP -> Adv -> VP`` | //sleep here// |
| ``mkVP`` | ``AdV -> VP -> VP`` | //always sleep// |
| ``reflexiveVP`` | ``V2 -> VP`` | //love itself// |
| ``passiveVP`` | ``V2 -> VP`` | //be loved// |
| ``passiveVP`` | ``V2 -> NP -> VP`` | //be loved by her// |
| ``progressiveVP`` | ``VP -> VP`` | //be sleeping// |
| ``mkImp`` | ``V -> Imp`` | //go// |
| ``mkImp`` | ``V2 -> NP -> Imp`` | //take it// |
| ``mkImp`` | ``VP -> Imp`` | //go there now// |
| ``mkNP`` | ``Det -> N -> NP`` | //the first man// |
| ``mkNP`` | ``Det -> CN -> NP`` | //the first old man// |
| ``mkNP`` | ``QuantSg -> N -> NP`` | //this man// |
| ``mkNP`` | ``QuantSg -> CN -> NP`` | //this old man// |
| ``mkNP`` | ``QuantPl -> N -> NP`` | //these men// |
| ``mkNP`` | ``QuantPl -> CN -> NP`` | //these old men// |
| ``mkNP`` | ``Numeral -> N -> NP`` | //twenty men// |
| ``mkNP`` | ``Numeral -> CN -> NP`` | //twenty old men// |
| ``mkNP`` | ``Int -> N -> NP`` | //45 men// |
| ``mkNP`` | ``Int -> CN -> NP`` | //45 old men// |
| ``mkNP`` | ``Num -> N -> NP`` | //almost twenty men// |
| ``mkNP`` | ``Num -> CN -> NP`` | //almost twenty old men// |
| ``mkNP`` | ``Pron -> N -> NP`` | //my man// |
| ``mkNP`` | ``Pron -> CN -> NP;`` | //my old man// |
| ``mkNP`` | ``PN -> NP`` | //John// |
| ``mkNP`` | ``Pron -> NP`` | //he// |
| ``mkNP`` | ``Predet -> NP -> NP`` | //only John// |
| ``mkNP`` | ``NP -> V2 -> NP`` | //John killed// |
| ``mkNP`` | ``NP -> Adv -> NP`` | //John in Paris// |
| ``mkNP`` | ``Conj -> NP -> NP -> NP`` | //John and I// |
| ``mkNP`` | ``Conj -> ListNP -> NP`` | //John, I, and that// |
| ``mkNP`` | ``DConj -> NP -> NP -> NP`` | //either John or I// |
| ``mkNP`` | ``DConj -> ListNP -> NP`` | //either John, I, or that// |
| ``mkDet`` | ``QuantSg -> Det`` | //this// |
| ``mkDet`` | ``QuantSg -> (Ord) -> Det`` | //this first// |
| ``mkDet`` | ``QuantPl -> Det`` | //these// |
| ``mkDet`` | ``QuantPl -> (Num) -> (Ord) -> Det`` | //these five best// |
| ``mkDet`` | ``Quant -> Det`` | //this// |
| ``mkDet`` | ``Quant -> Num -> Det`` | //these five// |
| ``mkDet`` | ``Num -> Det`` | //almost twenty// |
| ``mkDet`` | ``Numeral -> Det`` | //five// |
| ``mkDet`` | ``Int -> Det`` | //51// |
| ``mkDet`` | ``Pron -> Det`` | //my// |
| ``defSgDet`` | ``Det`` | //the (house)// |
| ``defPlDet`` | ``Det`` | //the (houses)// |
| ``indefSgDet`` | ``Det`` | //a (house)// |
| ``indefPlDet`` | ``Det`` | //(houses)// |
| ``defQuant`` | ``Quant`` | //the// |
| ``indefQuant`` | ``Quant`` | //a// |
| ``mkQuantSg`` | ``Quant -> QuantSg`` | //this// |
| ``massQuant`` | ``QuantSg`` | //(mass terms)// |
| ``mkQuantPl`` | ``Quant -> QuantPl`` | //these// |
| ``mkNum`` | ``Numeral -> Num`` | //twenty// |
| ``mkNum`` | ``Int -> Num`` | //51// |
| ``mkNum`` | ``AdN -> Num -> Num`` | //almost ten// |
| ``mkOrd`` | ``Numeral -> Ord`` | //twentieth// |
| ``mkOrd`` | ``Int -> Ord`` | //51st// |
| ``mkOrd`` | ``A -> Ord`` | //best// |
| ``mkAdN`` | ``CAdv -> AdN`` | //more than// |
| ``n1_Numeral`` | ``Numeral`` | //one// |
| ``n2_Numeral`` | ``Numeral`` | //two// |
| ``n3_Numeral`` | ``Numeral`` | //three// |
| ``n4_Numeral`` | ``Numeral`` | //four// |
| ``n5_Numeral`` | ``Numeral`` | //five// |
| ``n6_Numeral`` | ``Numeral`` | //six// |
| ``n7_Numeral`` | ``Numeral`` | //seven// |
| ``n8_Numeral`` | ``Numeral`` | //eight// |
| ``n9_Numeral`` | ``Numeral`` | //nine// |
| ``n10_Numeral`` | ``Numeral`` | //ten// |
| ``n20_Numeral`` | ``Numeral`` | //twenty// |
| ``n100_Numeral`` | ``Numeral`` | //hundred// |
| ``n1000_Numeral`` | ``Numeral`` | //thousand// |
| ``mkCN`` | ``N -> CN`` | //house// |
| ``mkCN`` | ``N2 -> NP -> CN`` | //mother of John// |
| ``mkCN`` | ``N3 -> NP -> NP -> CN`` | //distance from this city to Paris// |
| ``mkCN`` | ``N2 -> CN`` | //son// |
| ``mkCN`` | ``N3 -> CN`` | //flight// |
| ``mkCN`` | ``A -> N -> CN`` | //big house// |
| ``mkCN`` | ``A -> CN -> CN`` | //big blue house// |
| ``mkCN`` | ``AP -> N -> CN`` | //very big house// |
| ``mkCN`` | ``AP -> CN -> CN`` | //very big blue house// |
| ``mkCN`` | ``N -> RS -> CN`` | //house that John loves// |
| ``mkCN`` | ``CN -> RS -> CN`` | //big house that John loves// |
| ``mkCN`` | ``N -> Adv -> CN`` | //house in the city// |
| ``mkCN`` | ``CN -> Adv -> CN`` | //big house in the city// |
| ``mkCN`` | ``CN -> S -> CN`` | //rule that John walks// |
| ``mkCN`` | ``CN -> QS -> CN`` | //question if John walks// |
| ``mkCN`` | ``CN -> VP -> CN`` | //reason to walk// |
| ``mkCN`` | ``N -> NP -> CN`` | //king John// |
| ``mkCN`` | ``CN -> NP -> CN`` | //old king John// |
| ``mkAP`` | ``A -> AP`` | //old// |
| ``mkAP`` | ``A -> NP -> AP`` | //older than John// |
| ``mkAP`` | ``A2 -> NP -> AP`` | //married to her// |
| ``mkAP`` | ``A2 -> AP`` | //married to myself// |
| ``mkAP`` | ``AP -> S -> AP`` | //probable that John walks// |
| ``mkAP`` | ``AP -> QS -> AP`` | //uncertain if John walks// |
| ``mkAP`` | ``AP -> VP -> AP`` | //ready to go// |
| ``mkAP`` | ``AdA -> A -> AP`` | //very old// |
| ``mkAP`` | ``AdA -> AP -> AP`` | //very very old// |
| ``mkAP`` | ``Conj -> AP -> AP -> AP`` | //old and big// |
| ``mkAP`` | ``Conj -> ListAP -> AP`` | //old, big, and warm// |
| ``mkAP`` | ``DConj -> AP -> AP -> AP`` | //either old or big// |
| ``mkAP`` | ``DConj -> ListAP -> AP`` | //either old, big, or warm// |
| ``mkAdv`` | ``A -> Adv`` | //warmly// |
| ``mkAdv`` | ``Prep -> NP -> Adv`` | //with John// |
| ``mkAdv`` | ``Subj -> S -> Adv`` | //when John walks// |
| ``mkAdv`` | ``CAdv -> A -> NP -> Adv`` | //more warmly than John// |
| ``mkAdv`` | ``CAdv -> A -> S -> Adv`` | //more warmly than John walks// |
| ``mkAdv`` | ``AdA -> Adv -> Adv`` | //very warmly// |
| ``mkAdv`` | ``Conj -> Adv -> Adv -> Adv`` | //here and now// |
| ``mkAdv`` | ``Conj -> ListAdv -> Adv`` | //with John, here and now// |
| ``mkAdv`` | ``DConj -> Adv -> Adv -> Adv`` | //either here or now// |
| ``mkAdv`` | ``DConj -> ListAdv -> Adv`` | //either here, now, or with John// |
| ``mkQS`` | ``QCl -> QS`` | //who walks// |
| ``mkQS`` | ``(Tense) -> (Ant) -> (Pol) -> QCl -> QS`` | //who wouldn't have walked// |
| ``mkQS`` | ``Cl -> QS`` | //does John walk// |
| ``mkQCl`` | ``Cl -> QCl`` | //does John walk// |
| ``mkQCl`` | ``IP -> VP -> QCl`` | //who walks// |
| ``mkQCl`` | ``IP -> NP -> V2 -> QCl`` | //whom does John love// |
| ``mkQCl`` | ``IP -> Slash -> QCl`` | //whom does John love today// |
| ``mkQCl`` | ``IAdv -> Cl -> QCl`` | //why does John walk// |
| ``mkQCl`` | ``Prep -> IP -> Cl -> QCl`` | //with who does John walk// |
| ``mkQCl`` | ``IAdv -> NP -> QCl`` | //where is John// |
| ``mkQCl`` | ``IP -> QCl`` | //what is there// |
| ``mkIP`` | ``IDet -> N -> IP`` | //which city// |
| ``mkIP`` | ``IDet -> (Num) -> (Ord) -> CN -> IP`` | //which five best cities// |
| ``mkIP`` | ``IP -> Adv -> IP`` | //who in Paris// |
| ``mkIAdv`` | ``Prep -> IP -> IAdv`` | //in which city// |
| ``mkRS`` | ``RCl -> RS`` | //that walk// |
| ``mkRS`` | ``(Tense) -> (Ant) -> (Pol) -> RCl -> RS`` | //that wouldn't have walked// |
| ``mkRCl`` | ``RP -> VP -> RCl`` | //that walk// |
| ``mkRCl`` | ``RP -> NP -> V2 -> RCl`` | //which John loves// |
| ``mkRCl`` | ``RP -> Slash -> RCl`` | //which John loves today// |
| ``mkRCl`` | ``Cl -> RCl`` | //such that John loves her// |
| ``which_RP`` | ``RP`` | //which// |
| ``mkRP`` | ``Prep -> NP -> RP -> RP`` | //all the houses in which// |
| ``mkSlash`` | ``NP -> V2 -> Slash`` | //(whom) John loves// |
| ``mkSlash`` | ``NP -> VV -> V2 -> Slash`` | //(whom) John wants to see// |
| ``mkSlash`` | ``Cl -> Prep -> Slash`` | //(with whom) John walks// |
| ``mkSlash`` | ``Slash -> Adv -> Slash`` | //(whom) John loves today// |
| ``mkListS`` | ``S -> S -> ListS`` | //he walks, I run// |
| ``mkListS`` | ``S -> ListS -> ListS`` | //John walks, I run, you sleep// |
| ``mkListAdv`` | ``Adv -> Adv -> ListAdv`` | //here, now// |
| ``mkListAdv`` | ``Adv -> ListAdv -> ListAdv`` | //to me, here, now// |
| ``mkListAP`` | ``AP -> AP -> ListAP`` | //old, big// |
| ``mkListAP`` | ``AP -> ListAP -> ListAP`` | //old, big, warm// |
| ``mkListNP`` | ``NP -> NP -> ListNP`` | //John, I// |
| ``mkListNP`` | ``NP -> ListNP -> ListNP`` | //John, I, that// |
==Paradigms for Danish==
[source ../danish/ParadigmsDan.gf]
|| Function | Type | Example ||
| ``Gender`` | ``Type`` | - |
| ``utrum`` | ``Gender`` | - |
| ``neutrum`` | ``Gender`` | - |
| ``Number`` | ``Type`` | - |
| ``singular`` | ``Number`` | - |
| ``plural`` | ``Number`` | - |
| ``Case`` | ``Type`` | - |
| ``nominative`` | ``Case`` | - |
| ``genitive`` | ``Case`` | - |
| ``mkPrep`` | ``Str -> Prep`` | - |
| ``noPrep`` | ``Prep`` | //empty string// |
| ``mkN`` | ``(dreng,drengen,drenge,drengene : Str) -> N`` | - |
| ``regN`` | ``Str -> N`` | - |
| ``regGenN`` | ``Str -> Gender -> N`` | - |
| ``mk2N`` | ``(bil,bilen : Str) -> N`` | - |
| ``mk3N`` | ``(bil,bilen,biler : Str) -> N`` | - |
| ``mkN2`` | ``N -> Prep -> N2`` | - |
| ``regN2`` | ``Str -> Gender -> N2`` | - |
| ``mkN3`` | ``N -> Prep -> Prep -> N3`` | - |
| ``mkPN`` | ``Str -> Gender -> PN`` | //Paris neutrum// |
| ``regPN`` | ``Str -> PN`` | //utrum gender// |
| ``nounPN`` | ``N -> PN`` | - |
| ``mkNP`` | ``Str -> Str -> Number -> Gender -> NP`` | - |
| ``mkA`` | ``(galen,galet,galne : Str) -> A`` | - |
| ``regA`` | ``Str -> A`` | - |
| ``mk2A`` | ``(stor,stort : Str) -> A`` | - |
| ``mkA2`` | ``A -> Prep -> A2`` | - |
| ``mkADeg`` | ``(stor,stort,store,storre,storst : Str) -> A`` | - |
| ``regADeg`` | ``Str -> A`` | - |
| ``irregADeg`` | ``(tung,tyngre,tyngst : Str) -> A`` | - |
| ``mk3ADeg`` | ``(galen,galet,galna : Str) -> A`` | - |
| ``mk2ADeg`` | ``(bred,bredt : Str) -> A`` | - |
| ``compoundA`` | ``A -> A`` | //-/mer/mest norsk// |
| ``mkAdv`` | ``Str -> Adv`` | - |
| ``mkAdV`` | ``Str -> AdV`` | - |
| ``mkAdA`` | ``Str -> AdA`` | - |
| ``mkV`` | ``(spise,spiser,spises,spiste,spist,spis : Str) -> V`` | - |
| ``regV`` | ``(snakke : Str) -> V`` | - |
| ``mk2V`` | ``(leve,levde : Str) -> V`` | - |
| ``irregV`` | ``(drikke, drak, drukket : Str) -> V`` | - |
| ``vaereV`` | ``V -> V`` | - |
| ``partV`` | ``V -> Str -> V`` | - |
| ``depV`` | ``V -> V`` | - |
| ``reflV`` | ``V -> V`` | - |
| ``mkV2`` | ``V -> Prep -> V2`` | - |
| ``dirV2`` | ``V -> V2`` | - |
| ``mkV3`` | ``V -> Prep -> Prep -> V3`` | //snakke, med, om// |
| ``dirV3`` | ``V -> Prep -> V3`` | //give,_,til// |
| ``dirdirV3`` | ``V -> V3`` | //give,_,_// |
| ``mkV0`` | ``V -> V0`` | - |
| ``mkVS`` | ``V -> VS`` | - |
| ``mkV2S`` | ``V -> Prep -> V2S`` | - |
| ``mkVV`` | ``V -> VV`` | - |
| ``mkV2V`` | ``V -> Prep -> Prep -> V2V`` | - |
| ``mkVA`` | ``V -> VA`` | - |
| ``mkV2A`` | ``V -> Prep -> V2A`` | - |
| ``mkVQ`` | ``V -> VQ`` | - |
| ``mkV2Q`` | ``V -> Prep -> V2Q`` | - |
| ``mkAS`` | ``A -> AS`` | - |
| ``mkA2S`` | ``A -> Prep -> A2S`` | - |
| ``mkAV`` | ``A -> AV`` | - |
| ``mkA2V`` | ``A -> Prep -> A2V`` | - |
==Paradigms for English==
[source ../english/ParadigmsEng.gf]
|| Function | Type | Example ||
| ``Gender`` | ``Type`` | - |
| ``human`` | ``Gender`` | - |
| ``nonhuman`` | ``Gender`` | - |
| ``masculine`` | ``Gender`` | - |
| ``Number`` | ``Type`` | - |
| ``singular`` | ``Number`` | - |
| ``plural`` | ``Number`` | - |
| ``Case`` | ``Type`` | - |
| ``nominative`` | ``Case`` | - |
| ``genitive`` | ``Case`` | - |
| ``mkN`` | ``(flash : Str) -> N`` | - |
| ``mkN`` | ``(man,men : Str) -> N`` | - |
| ``mkN`` | ``(man,men,man's,men's : Str) -> N`` | - |
| ``mkN`` | ``Str -> N -> N`` | - |
| ``mkN2`` | ``N -> Prep -> N2`` | - |
| ``regN2`` | ``Str -> N2`` | - |
| ``mkN3`` | ``N -> Prep -> Prep -> N3`` | - |
| ``mkPN`` | ``Str -> PN`` | - |
| ``mkPN`` | ``N -> PN`` | - |
| ``mkA`` | ``(happy : Str) -> A`` | - |
| ``mkA`` | ``(fat,fatter : Str) -> A`` | - |
| ``mkA`` | ``(good,better,best,well : Str) -> A`` | - |
| ``compoundA`` | ``A -> A`` | //-/more/most ridiculous// |
| ``mkA2`` | ``A -> Prep -> A2`` | - |
| ``mkAdv`` | ``Str -> Adv`` | - |
| ``mkAdV`` | ``Str -> AdV`` | - |
| ``mkAdA`` | ``Str -> AdA`` | - |
| ``mkPrep`` | ``Str -> Prep`` | - |
| ``noPrep`` | ``Prep`` | - |
| ``mkV`` | ``(cry : Str) -> V`` | - |
| ``mkV`` | ``(stop, stopped : Str) -> V`` | - |
| ``mkV`` | ``(drink, drank, drunk : Str) -> V`` | - |
| ``mkV`` | ``(run, ran, run, running : Str) -> V`` | - |
| ``mkV`` | ``(go, goes, went, gone, going : Str) -> V`` | - |
| ``partV`` | ``V -> Str -> V`` | - |
| ``reflV`` | ``V -> V`` | - |
| ``mkV2`` | ``V -> Prep -> V2`` | //believe in// |
| ``mkV2`` | ``V -> V2`` | //kill// |
| ``mkV3`` | ``V -> Prep -> Prep -> V3`` | //speak, with, about// |
| ``dirV3`` | ``V -> Prep -> V3`` | //give,_,to// |
| ``dirdirV3`` | ``V -> V3`` | //give,_,_// |
| ``mkV0`` | ``V -> V0`` | - |
| ``mkVS`` | ``V -> VS`` | - |
| ``mkV2S`` | ``V -> Prep -> V2S`` | - |
| ``mkVV`` | ``V -> VV`` | - |
| ``mkV2V`` | ``V -> Prep -> Prep -> V2V`` | - |
| ``mkVA`` | ``V -> VA`` | - |
| ``mkV2A`` | ``V -> Prep -> V2A`` | - |
| ``mkVQ`` | ``V -> VQ`` | - |
| ``mkV2Q`` | ``V -> Prep -> V2Q`` | - |
| ``mkAS`` | ``A -> AS`` | - |
| ``mkA2S`` | ``A -> Prep -> A2S`` | - |
| ``mkAV`` | ``A -> AV`` | - |
| ``mkA2V`` | ``A -> Prep -> A2V`` | - |
==Paradigms for Finnish==
[source ../finnish/ParadigmsFin.gf]
|| Function | Type | Example ||
| ``Number`` | ``Type`` | - |
| ``singular`` | ``Number`` | - |
| ``plural`` | ``Number`` | - |
| ``Case`` | ``Type`` | - |
| ``nominative`` | ``Case`` | - |
| ``genitive`` | ``Case`` | - |
| ``partitive`` | ``Case`` | - |
| ``translative`` | ``Case`` | - |
| ``inessive`` | ``Case`` | - |
| ``elative`` | ``Case`` | - |
| ``illative`` | ``Case`` | - |
| ``adessive`` | ``Case`` | - |
| ``ablative`` | ``Case`` | - |
| ``allative`` | ``Case`` | - |
| ``prePrep`` | ``Case -> Str -> Prep`` | //ilman, partitive// |
| ``postPrep`` | ``Case -> Str -> Prep`` | //takana, genitive// |
| ``postGenPrep`` | ``Str -> Prep`` | //takana// |
| ``casePrep`` | ``Case -> Prep`` | //adessive// |
| ``mkN`` | ``(talo : Str) -> N`` | - |
| ``mkN`` | ``(savi,savia : Str) -> N`` | - |
| ``mkN`` | ``(vesi,veden,vesiä : Str) -> N`` | - |
| ``mkN`` | ``(olo,oln,olona,oloa,oloon,oloina,oloissa,olojen,oloja,oloihin : Str) -> N`` | - |
| ``sgpartN`` | ``(meri : N) -> (merta : Str) -> N`` | - |
| ``nMeri`` | ``(meri : Str) -> N`` | - |
| ``nKukko`` | ``(kukko,kukon,kukkoja : Str) -> N`` | - |
| ``nTalo`` | ``(talo : Str) -> N`` | - |
| ``nLukko`` | ``(lukko : Str) -> N`` | - |
| ``nArpi`` | ``(arpi : Str) -> N`` | - |
| ``nSylki`` | ``(sylki : Str) -> N`` | - |
| ``nLinux`` | ``(linuxia : Str) -> N`` | - |
| ``nPeruna`` | ``(peruna : Str) -> N`` | - |
| ``nRae`` | ``(rae, rakeena : Str) -> N`` | - |
| ``nSusi`` | ``(susi,suden,sutta : Str) -> N`` | - |
| ``nPuu`` | ``(puu : Str) -> N`` | - |
| ``nSuo`` | ``(suo : Str) -> N`` | - |
| ``nNainen`` | ``(naista : Str) -> N`` | - |
| ``nTilaus`` | ``(tilaus,tilauksena : Str) -> N`` | - |
| ``nKulaus`` | ``(kulaus : Str) -> N`` | - |
| ``nNauris`` | ``(naurista : Str) -> N`` | - |
| ``compN`` | ``Str -> N -> N`` | - |
| ``mkN2`` | ``N -> N2`` | - |
| ``mkN2`` | ``N -> Prep -> N2`` | - |
| ``mkN3`` | ``N -> Prep -> Prep -> N3`` | - |
| ``mkPN`` | ``Str -> PN`` | - |
| ``mkPN`` | ``N -> PN`` | - |
| ``mkA`` | ``Str -> A`` | - |
| ``mkA`` | ``N -> A`` | - |
| ``mkA`` | ``N -> (kivempaa,kivinta : Str) -> A`` | - |
| ``mkA2`` | ``A -> Prep -> A2`` | - |
| ``mkV`` | ``(soutaa : Str) -> V`` | - |
| ``mkV`` | ``(soutaa,souti : Str) -> V`` | - |
| ``mkV`` | ``(soutaa,soudan,souti : Str) -> V`` | - |
| ``mkV`` | ``(tulla,tulee,tulen,tulevat,tulkaa,tullaan,tuli,tulin,tulisi,tullut,tultu,tullun : Str) -> V`` | - |
| ``mkV`` | ``V -> Case -> V`` | - |
| ``vValua`` | ``(valua : Str) -> V`` | - |
| ``vKattaa`` | ``(kattaa, katan : Str) -> V`` | - |
| ``vOstaa`` | ``(ostaa : Str) -> V`` | - |
| ``vNousta`` | ``(nousta, nousen : Str) -> V`` | - |
| ``vTuoda`` | ``(tuoda : Str) -> V`` | - |
| ``caseV`` | ``Case -> V -> V`` | - |
| ``vOlla`` | ``V`` | - |
| ``mkV2`` | ``V -> Prep -> V2`` | - |
| ``caseV2`` | ``V -> Case -> V2`` | - |
| ``dirV2`` | ``V -> V2`` | - |
| ``mkV3`` | ``V -> Prep -> Prep -> V3`` | //puhua, allative, elative// |
| ``dirV3`` | ``V -> Case -> V3`` | //siirtää, (accusative), illative// |
| ``dirdirV3`` | ``V -> V3`` | //antaa, (accusative), (allative)// |
| ``mkV0`` | ``V -> V0`` | - |
| ``mkVS`` | ``V -> VS`` | - |
| ``mkV2S`` | ``V -> Prep -> V2S`` | - |
| ``mkVV`` | ``V -> VV`` | - |
| ``mkV2V`` | ``V -> Prep -> V2V`` | - |
| ``mkVA`` | ``V -> Prep -> VA`` | - |
| ``mkV2A`` | ``V -> Prep -> Prep -> V2A`` | - |
| ``mkVQ`` | ``V -> VQ`` | - |
| ``mkV2Q`` | ``V -> Prep -> V2Q`` | - |
| ``mkAS`` | ``A -> AS`` | - |
| ``mkA2S`` | ``A -> Prep -> A2S`` | - |
| ``mkAV`` | ``A -> AV`` | - |
| ``mkA2V`` | ``A -> Prep -> A2V`` | - |
==Paradigms for French==
[source ../french/ParadigmsFre.gf]
|| Function | Type | Example ||
| ``Gender`` | ``Type`` | - |
| ``masculine`` | ``Gender`` | - |
| ``feminine`` | ``Gender`` | - |
| ``Number`` | ``Type`` | - |
| ``singular`` | ``Number`` | - |
| ``plural`` | ``Number`` | - |
| ``accusative`` | ``Prep`` | - |
| ``genitive`` | ``Prep`` | - |
| ``dative`` | ``Prep`` | - |
| ``mkPrep`` | ``Str -> Prep`` | - |
| ``mkN`` | ``(cheval : Str) -> N`` | - |
| ``mkN`` | ``(foie : Str) -> Gender -> N`` | - |
| ``mkN`` | ``(oeil,yeux : Str) -> Gender -> N`` | - |
| ``mkN`` | ``N -> Str -> N`` | - |
| ``mkN2`` | ``N -> Prep -> N2`` | - |
| ``deN2`` | ``N -> N2`` | - |
| ``aN2`` | ``N -> N2`` | - |
| ``mkN3`` | ``N -> Prep -> Prep -> N3`` | - |
| ``mkPN`` | ``Str -> PN`` | - |
| ``mkPN`` | ``Str -> Gender -> PN`` | - |
| ``mkA`` | ``(cher : Str) -> A`` | - |
| ``mkA`` | ``(sec,seche : Str) -> A`` | - |
| ``mkA`` | ``(banal,banale,banaux,banalement : Str) -> A`` | - |
| ``mkA`` | ``A -> A -> A`` | - |
| ``prefixA`` | ``A -> A`` | - |
| ``mkA2`` | ``A -> Prep -> A2`` | - |
| ``mkAdv`` | ``Str -> Adv`` | - |
| ``mkAdV`` | ``Str -> AdV`` | - |
| ``mkAdA`` | ``Str -> AdA`` | - |
| ``mkV`` | ``(finir : Str) -> V`` | - |
| ``mkV`` | ``(jeter,jette,jettera : Str) -> V`` | - |
| ``mkV`` | ``V2 -> V`` | - |
| ``etreV`` | ``V -> V`` | - |
| ``reflV`` | ``V -> V`` | - |
| ``mkV2`` | ``V -> V2 = dirV2`` | - |
| ``mkV2`` | ``V -> Prep -> V2 = mmkV2`` | - |
| ``mkV3`` | ``V -> V3`` | //donner,_,_// |
| ``mkV3`` | ``V -> Prep -> V3`` | //placer,_,dans// |
| ``mkV3`` | ``V -> Prep -> Prep -> V3`` | //parler, à, de// |
| ``mkV0`` | ``V -> V0`` | - |
| ``mkVS`` | ``V -> VS`` | - |
| ``mkV2S`` | ``V -> Prep -> V2S`` | - |
| ``mkVV`` | ``V -> VV`` | //plain infinitive: "je veux parler"// |
| ``deVV`` | ``V -> VV`` | //"j'essaie de parler"// |
| ``aVV`` | ``V -> VV`` | //"j'arrive à parler"// |
| ``mkV2V`` | ``V -> Prep -> Prep -> V2V`` | - |
| ``mkVA`` | ``V -> VA`` | - |
| ``mkV2A`` | ``V -> Prep -> Prep -> V2A`` | - |
| ``mkVQ`` | ``V -> VQ`` | - |
| ``mkV2Q`` | ``V -> Prep -> V2Q`` | - |
| ``mkAS`` | ``A -> AS`` | - |
| ``mkA2S`` | ``A -> Prep -> A2S`` | - |
| ``mkAV`` | ``A -> Prep -> AV`` | - |
| ``mkA2V`` | ``A -> Prep -> Prep -> A2V`` | - |
==Paradigms for German==
[source ../german/ParadigmsGer.gf]
|| Function | Type | Example ||
| ``Gender`` | ``Type`` | - |
| ``masculine`` | ``Gender`` | - |
| ``feminine`` | ``Gender`` | - |
| ``neuter`` | ``Gender`` | - |
| ``Case`` | ``Type`` | - |
| ``nominative`` | ``Case`` | - |
| ``accusative`` | ``Case`` | - |
| ``dative`` | ``Case`` | - |
| ``genitive`` | ``Case`` | - |
| ``Number`` | ``Type`` | - |
| ``singular`` | ``Number`` | - |
| ``plural`` | ``Number`` | - |
| ``mkN`` | ``(Stufe : Str) -> N`` | - |
| ``mkN`` | ``(Bild,Bilder : Str) -> Gender -> N`` | - |
| ``mkN`` | ``(x1,_,_,_,_,x6 : Str) -> Gender -> N`` | - |
| ``mkN2`` | ``Str -> N2`` | - |
| ``mkN2`` | ``N -> N2`` | - |
| ``mkN2`` | ``N -> Prep -> N2`` | - |
| ``mkN3`` | ``N -> Prep -> Prep -> N3`` | - |
| ``mkPN`` | ``Str -> PN`` | - |
| ``mkPN`` | ``(nom,gen : Str) -> PN`` | - |
| ``mkPN`` | ``(nom,acc,dat,gen : Str) -> PN`` | - |
| ``mkA`` | ``Str -> A`` | - |
| ``mkA`` | ``(gut,besser,beste : Str) -> A`` | //gut,besser,beste// |
| ``invarA`` | ``Str -> A`` | //prima// |
| ``mkA2`` | ``A -> Prep -> A2`` | - |
| ``mkAdv`` | ``Str -> Adv`` | - |
| ``mkPrep`` | ``Str -> Case -> Prep`` | - |
| ``accPrep`` | ``Prep`` | - |
| ``datPrep`` | ``Prep`` | - |
| ``genPrep`` | ``Prep`` | - |
| ``von_Prep`` | ``Prep`` | - |
| ``zu_Prep`` | ``Prep`` | - |
| ``mkV`` | ``(führen : Str) -> V`` | - |
| ``mkV`` | ``(sehen,sieht,sah,sähe,gesehen : Str) -> V`` | - |
| ``mkV`` | ``(geben, gibt, gib, gab, gäbe, gegeben : Str) -> V`` | - |
| ``mkV`` | ``Str -> V -> V`` | - |
| ``no_geV`` | ``V -> V`` | - |
| ``seinV`` | ``V -> V`` | - |
| ``habenV`` | ``V -> V`` | - |
| ``reflV`` | ``V -> Case -> V`` | - |
| ``mkV2`` | ``V -> Prep -> V2`` | - |
| ``mkV2`` | ``V -> V2`` | - |
| ``mkV2`` | ``V -> Case -> V2`` | - |
| ``mkV3`` | ``V -> Prep -> Prep -> V3`` | //sprechen, mit, über// |
| ``dirV3`` | ``V -> Prep -> V3`` | //senden,(accusative),nach// |
| ``accdatV3`` | ``V -> V3`` | //give,accusative,dative// |
| ``mkV0`` | ``V -> V0`` | - |
| ``mkVS`` | ``V -> VS`` | - |
| ``mkV2S`` | ``V -> Prep -> V2S`` | - |
| ``mkVV`` | ``V -> VV`` | - |
| ``mkV2V`` | ``V -> Prep -> V2V`` | - |
| ``mkVA`` | ``V -> VA`` | - |
| ``mkV2A`` | ``V -> Prep -> V2A`` | - |
| ``mkVQ`` | ``V -> VQ`` | - |
| ``mkV2Q`` | ``V -> Prep -> V2Q`` | - |
| ``mkAS`` | ``A -> AS`` | - |
| ``mkA2S`` | ``A -> Prep -> A2S`` | - |
| ``mkAV`` | ``A -> AV`` | - |
| ``mkA2V`` | ``A -> Prep -> A2V`` | - |
==Paradigms for Italian==
[source ../italian/ParadigmsIta.gf]
|| Function | Type | Example ||
| ``Gender`` | ``Type`` | - |
| ``masculine`` | ``Gender`` | - |
| ``feminine`` | ``Gender`` | - |
| ``Number`` | ``Type`` | - |
| ``singular`` | ``Number`` | - |
| ``plural`` | ``Number`` | - |
| ``Prep`` | ``Type`` | - |
| ``accusative`` | ``Prep`` | - |
| ``genitive`` | ``Prep`` | - |
| ``dative`` | ``Prep`` | - |
| ``mkPrep`` | ``Str -> Prep`` | - |
| ``mkN`` | ``(cane : Str) -> N`` | - |
| ``mkN`` | ``(carne : Str) -> Gender -> N`` | - |
| ``mkN`` | ``(uomo,uomini : Str) -> Gender -> N`` | - |
| ``mkN`` | ``N -> Str -> N`` | - |
| ``mkN2`` | ``Str -> N2`` | - |
| ``mkN2`` | ``N -> Prep -> N2`` | - |
| ``mkN3`` | ``N -> Prep -> Prep -> N3`` | - |
| ``mkPN`` | ``Str -> PN`` | - |
| ``mkPN`` | ``Str -> Gender -> PN`` | - |
| ``mkA`` | ``(bianco : Str) -> A`` | - |
| ``mkA`` | ``(solo,sola,soli,sole,solamente : Str) -> A`` | - |
| ``mkA`` | ``A -> A -> A`` | - |
| ``prefixA`` | ``A -> A = prefA`` | - |
| ``mkA2`` | ``A -> Prep -> A2`` | - |
| ``mkAdv`` | ``Str -> Adv`` | - |
| ``mkAdV`` | ``Str -> AdV`` | - |
| ``mkAdA`` | ``Str -> AdA`` | - |
| ``mkV`` | ``Str -> V`` | - |
| ``mkV`` | ``Verbo -> V`` | - |
| ``mkV`` | ``(udire,odo,ode,udiamo,udiro,udii,udisti,udi,udirono,odi,udito : Str) -> V`` | - |
| ``essereV`` | ``V -> V`` | - |
| ``reflV`` | ``V -> V`` | - |
| ``mkV2`` | ``Str -> V2`` | - |
| ``mkV2`` | ``V -> V2`` | - |
| ``mkV2`` | ``V -> Prep -> V2`` | - |
| ``v2V`` | ``V2 -> V`` | - |
| ``mkV3`` | ``V -> Prep -> Prep -> V3`` | //parlare, a, di// |
| ``dirV3`` | ``V -> Prep -> V3`` | //dare,_,a// |
| ``dirdirV3`` | ``V -> V3`` | //dare,_,_// |
| ``mkV0`` | ``V -> V0`` | - |
| ``mkVS`` | ``V -> VS`` | - |
| ``mkV2S`` | ``V -> Prep -> V2S`` | - |
| ``mkVV`` | ``V -> VV`` | //plain infinitive: "voglio parlare"// |
| ``deVV`` | ``V -> VV`` | //"cerco di parlare"// |
| ``aVV`` | ``V -> VV`` | //"arrivo a parlare"// |
| ``mkV2V`` | ``V -> Prep -> Prep -> V2V`` | - |
| ``mkVA`` | ``V -> VA`` | - |
| ``mkV2A`` | ``V -> Prep -> Prep -> V2A`` | - |
| ``mkVQ`` | ``V -> VQ`` | - |
| ``mkV2Q`` | ``V -> Prep -> V2Q`` | - |
| ``mkAS`` | ``A -> AS`` | - |
| ``mkA2S`` | ``A -> Prep -> A2S`` | - |
| ``mkAV`` | ``A -> Prep -> AV`` | - |
| ``mkA2V`` | ``A -> Prep -> Prep -> A2V`` | - |
==Paradigms for Norwegian==
[source ../norwegian/ParadigmsNor.gf]
|| Function | Type | Example ||
| ``Gender`` | ``Type`` | - |
| ``masculine`` | ``Gender`` | - |
| ``feminine`` | ``Gender`` | - |
| ``neutrum`` | ``Gender`` | - |
| ``Number`` | ``Type`` | - |
| ``singular`` | ``Number`` | - |
| ``plural`` | ``Number`` | - |
| ``Case`` | ``Type`` | - |
| ``nominative`` | ``Case`` | - |
| ``genitive`` | ``Case`` | - |
| ``mkPrep`` | ``Str -> Prep`` | - |
| ``noPrep`` | ``Prep`` | //empty string// |
| ``mkN`` | ``(dreng,drengen,drenger,drengene : Str) -> N`` | - |
| ``regN`` | ``Str -> N`` | - |
| ``regGenN`` | ``Str -> Gender -> N`` | - |
| ``mk2N`` | ``(bil,bilen : Str) -> N`` | - |
| ``mkN2`` | ``N -> Prep -> N2`` | - |
| ``regN2`` | ``Str -> Gender -> N2`` | - |
| ``mkN3`` | ``N -> Prep -> Prep -> N3`` | - |
| ``regPN`` | ``Str -> PN`` | //utrum// |
| ``regGenPN`` | ``Str -> Gender -> PN`` | - |
| ``nounPN`` | ``N -> PN`` | - |
| ``mkNP`` | ``Str -> Str -> Number -> Gender -> NP`` | - |
| ``mkA`` | ``(galen,galet,galne : Str) -> A`` | - |
| ``regA`` | ``Str -> A`` | - |
| ``mk2A`` | ``(stor,stort : Str) -> A`` | - |
| ``mkA2`` | ``A -> Prep -> A2`` | - |
| ``mkADeg`` | ``(stor,stort,store,storre,storst : Str) -> A`` | - |
| ``regADeg`` | ``Str -> A`` | - |
| ``irregADeg`` | ``(tung,tyngre,tyngst : Str) -> A`` | - |
| ``mk3ADeg`` | ``(galen,galet,galne : Str) -> A`` | - |
| ``mk2ADeg`` | ``(bred,bredt : Str) -> A`` | - |
| ``compoundA`` | ``A -> A`` | //-/mer/mest norsk// |
| ``mkAdv`` | ``Str -> Adv`` | //e.g. her// |
| ``mkAdV`` | ``Str -> AdV`` | //e.g. altid// |
| ``mkAdA`` | ``Str -> AdA`` | - |
| ``mkV`` | ``(spise,spiser,spises,spiste,spist,spis : Str) -> V`` | - |
| ``regV`` | ``(snakke : Str) -> V`` | - |
| ``mk2V`` | ``(leve,levde : Str) -> V`` | - |
| ``irregV`` | ``(drikke, drakk, drukket : Str) -> V`` | - |
| ``vaereV`` | ``V -> V`` | - |
| ``partV`` | ``V -> Str -> V`` | - |
| ``depV`` | ``V -> V`` | - |
| ``reflV`` | ``V -> V`` | - |
| ``mkV2`` | ``V -> Prep -> V2`` | - |
| ``dirV2`` | ``V -> V2`` | - |
| ``mkV3`` | ``V -> Prep -> Prep -> V3`` | //snakke, med, om// |
| ``dirV3`` | ``V -> Prep -> V3`` | //gi,_,til// |
| ``dirdirV3`` | ``V -> V3`` | //gi,_,_// |
| ``mkV0`` | ``V -> V0`` | - |
| ``mkVS`` | ``V -> VS`` | - |
| ``mkV2S`` | ``V -> Prep -> V2S`` | - |
| ``mkVV`` | ``V -> VV`` | - |
| ``mkV2V`` | ``V -> Prep -> Prep -> V2V`` | - |
| ``mkVA`` | ``V -> VA`` | - |
| ``mkV2A`` | ``V -> Prep -> V2A`` | - |
| ``mkVQ`` | ``V -> VQ`` | - |
| ``mkV2Q`` | ``V -> Prep -> V2Q`` | - |
| ``mkAS`` | ``A -> AS`` | - |
| ``mkA2S`` | ``A -> Prep -> A2S`` | - |
| ``mkAV`` | ``A -> AV`` | - |
| ``mkA2V`` | ``A -> Prep -> A2V`` | - |
==Paradigms for Russian==
[source ../russian/ParadigmsRus.gf]
(To appear)
==Paradigms for Spanish==
[source ../spanish/ParadigmsSpa.gf]
|| Function | Type | Example ||
| ``Gender`` | ``Type`` | - |
| ``masculine`` | ``Gender`` | - |
| ``feminine`` | ``Gender`` | - |
| ``Number`` | ``Type`` | - |
| ``singular`` | ``Number`` | - |
| ``plural`` | ``Number`` | - |
| ``Prep`` | ``Type`` | - |
| ``accusative`` | ``Prep`` | - |
| ``genitive`` | ``Prep`` | - |
| ``dative`` | ``Prep`` | - |
| ``mkPrep`` | ``Str -> Prep`` | - |
| ``mkN`` | ``(luz : Str) -> N`` | - |
| ``mkN`` | ``Str -> Gender -> N`` | - |
| ``mkN`` | ``(baston,bastones : Str) -> Gender -> N`` | - |
| ``compN`` | ``N -> Str -> N`` | - |
| ``mkN2`` | ``N -> Prep -> N2`` | - |
| ``deN2`` | ``N -> N2`` | - |
| ``aN2`` | ``N -> N2`` | - |
| ``mkN3`` | ``N -> Prep -> Prep -> N3`` | - |
| ``mkPN`` | ``(Anna : Str) -> PN`` | - |
| ``mkPN`` | ``(Pilar : Str) -> Gender -> PN`` | - |
| ``mkA`` | ``(util : Str) -> A`` | - |
| ``mkA`` | ``(solo,sola,solos,solas,solamiento : Str) -> A`` | - |
| ``mkA`` | ``(bueno : A) -> (mejor : A) -> A`` | - |
| ``prefixA`` | ``A -> A`` | - |
| ``mkA2`` | ``A -> Prep -> A2`` | - |
| ``mkAdv`` | ``Str -> Adv`` | - |
| ``mkAdV`` | ``Str -> AdV`` | - |
| ``mkAdA`` | ``Str -> AdA`` | - |
| ``mkV`` | ``(pagar : Str) -> V`` | - |
| ``mkV`` | ``(mostrar,muestro : Str) -> V`` | - |
| ``mkV`` | ``Verbum -> V`` | - |
| ``reflV`` | ``V -> V`` | - |
| ``special_ppV`` | ``V -> Str -> V`` | - |
| ``mkV2`` | ``Str -> V2`` | - |
| ``mkV2`` | ``V -> V2`` | - |
| ``mkV2`` | ``V -> Prep -> V2`` | - |
| ``v2V`` | ``V2 -> V`` | - |
| ``mkV3`` | ``V -> Prep -> Prep -> V3`` | //hablar, a, di// |
| ``dirV3`` | ``V -> Prep -> V3`` | //dar,(accusative),a// |
| ``dirdirV3`` | ``V -> V3`` | //dar,(dative),(accusative)// |
| ``mkV0`` | ``V -> V0`` | - |
| ``mkVS`` | ``V -> VS`` | - |
| ``mkV2S`` | ``V -> Prep -> V2S`` | - |
| ``mkVV`` | ``V -> VV`` | //plain infinitive: "quiero hablar"// |
| ``deVV`` | ``V -> VV`` | //"terminar de hablar"// |
| ``aVV`` | ``V -> VV`` | //"aprender a hablar"// |
| ``mkV2V`` | ``V -> Prep -> Prep -> V2V`` | - |
| ``mkVA`` | ``V -> VA`` | - |
| ``mkV2A`` | ``V -> Prep -> Prep -> V2A`` | - |
| ``mkVQ`` | ``V -> VQ`` | - |
| ``mkV2Q`` | ``V -> Prep -> V2Q`` | - |
| ``mkAS`` | ``A -> AS`` | - |
| ``mkA2S`` | ``A -> Prep -> A2S`` | - |
| ``mkAV`` | ``A -> Prep -> AV`` | - |
| ``mkA2V`` | ``A -> Prep -> Prep -> A2V`` | - |
==Paradigms for Swedish==
[source ../swedish/ParadigmsSwe.gf]
|| Function | Type | Example ||
| ``Gender`` | ``Type`` | - |
| ``utrum`` | ``Gender`` | - |
| ``neutrum`` | ``Gender`` | - |
| ``Number`` | ``Type`` | - |
| ``singular`` | ``Number`` | - |
| ``plural`` | ``Number`` | - |
| ``Case`` | ``Type`` | - |
| ``nominative`` | ``Case`` | - |
| ``genitive`` | ``Case`` | - |
| ``mkPrep`` | ``Str -> Prep`` | - |
| ``noPrep`` | ``Prep`` | //empty string// |
| ``mkN`` | ``(apa : Str) -> N`` | - |
| ``mkN`` | ``(lik : Str) -> Gender -> N`` | - |
| ``mkN`` | ``(nyckel,nycklar : Str) -> N`` | - |
| ``mkN`` | ``(museum,museet,museer,museerna : Str) -> N`` | - |
| ``mkN2`` | ``Str -> N2`` | - |
| ``mkN2`` | ``N -> Prep -> N2`` | - |
| ``mkN3`` | ``N -> Prep -> Prep -> N3`` | - |
| ``mkPN`` | ``Str -> PN`` | - |
| ``mkPN`` | ``Str -> Gender -> PN`` | - |
| ``mkPN`` | ``(jesus,jesu : Str) -> Gender -> PN`` | - |
| ``mkA`` | ``(billig : Str) -> A`` | - |
| ``mkA`` | ``(bred,brett : Str) -> A`` | - |
| ``mkA`` | ``(tung,tyngre,tyngst : Str) -> A`` | - |
| ``mkA`` | ``(god,gott,goda,battre,bast : Str) -> A`` | - |
| ``mkA`` | ``(liten,litet,lilla,sma,mindre,minst,minsta : Str) -> A`` | - |
| ``compoundA`` | ``A -> A`` | - |
| ``mkA2`` | ``A -> Prep -> A2`` | - |
| ``mkAdv`` | ``Str -> Adv`` | //här// |
| ``mkAdV`` | ``Str -> AdV`` | //alltid// |
| ``mkAdA`` | ``Str -> AdA`` | - |
| ``mkV`` | ``(stämmer : Str) -> V`` | - |
| ``mkV`` | ``(dricka,drack,druckit : Str) -> V`` | - |
| ``mkV`` | ``(gå,går,gå,gick,gått,gången : Str) -> V`` | - |
| ``mkV`` | ``V -> Str -> V`` | - |
| ``depV`` | ``V -> V`` | - |
| ``reflV`` | ``V -> V`` | - |
| ``mkV2`` | ``Str -> V2`` | - |
| ``mkV2`` | ``V -> V2`` | - |
| ``mkV2`` | ``V -> Prep -> V2`` | - |
| ``mkV3`` | ``Str -> V3`` | - |
| ``mkV3`` | ``V -> V3`` | - |
| ``mkV3`` | ``V -> Prep -> V3`` | - |
| ``mkV3`` | ``V -> Prep -> Prep -> V3`` | - |
| ``mkV0`` | ``V -> V0`` | - |
| ``mkVS`` | ``V -> VS`` | - |
| ``mkV2S`` | ``V -> Prep -> V2S`` | - |
| ``mkVV`` | ``V -> VV`` | - |
| ``mkV2V`` | ``V -> Prep -> Prep -> V2V`` | - |
| ``mkVA`` | ``V -> VA`` | - |
| ``mkV2A`` | ``V -> Prep -> V2A`` | - |
| ``mkVQ`` | ``V -> VQ`` | - |
| ``mkV2Q`` | ``V -> Prep -> V2Q`` | - |
| ``mkAS`` | ``A -> AS`` | - |
| ``mkA2S`` | ``A -> Prep -> A2S`` | - |
| ``mkAV`` | ``A -> AV`` | - |
| ``mkA2V`` | ``A -> Prep -> A2V`` | - |

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1,842 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META NAME="generator" CONTENT="http://txt2tags.sf.net">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<TITLE>Transfer language reference</TITLE>
</HEAD><BODY BGCOLOR="white" TEXT="black">
<P ALIGN="center"><CENTER><H1>Transfer language reference</H1>
<FONT SIZE="4">
<I>Author: Björn Bringert &lt;bringert@cs.chalmers.se&gt;</I><BR>
Last update: Wed Mar 1 13:52:22 2006
</FONT></CENTER>
<P></P>
<HR NOSHADE SIZE=1>
<P></P>
<UL>
<LI><A HREF="#toc1">Current implementation status</A>
<LI><A HREF="#toc2">Layout syntax</A>
<LI><A HREF="#toc3">Imports</A>
<LI><A HREF="#toc4">Function declarations</A>
<LI><A HREF="#toc5">Data type declarations</A>
<LI><A HREF="#toc6">Lambda expressions</A>
<LI><A HREF="#toc7">Local definitions</A>
<LI><A HREF="#toc8">Types</A>
<UL>
<LI><A HREF="#function_types">Function types</A>
<LI><A HREF="#toc10">Basic types</A>
<LI><A HREF="#toc11">Records</A>
<LI><A HREF="#tuples">Tuples</A>
<LI><A HREF="#toc13">Lists</A>
</UL>
<LI><A HREF="#toc14">Case expressions</A>
<LI><A HREF="#patterns">Patterns</A>
<UL>
<LI><A HREF="#toc16">Constructor patterns</A>
<LI><A HREF="#toc17">Variable patterns</A>
<LI><A HREF="#toc18">Wildcard patterns</A>
<LI><A HREF="#toc19">Record patterns</A>
<LI><A HREF="#toc20">Disjunctive patterns</A>
<LI><A HREF="#toc21">List patterns</A>
<LI><A HREF="#toc22">Tuple patterns</A>
<LI><A HREF="#toc23">String literal patterns</A>
<LI><A HREF="#toc24">Integer literal patterns</A>
</UL>
<LI><A HREF="#metavariables">Metavariables</A>
<LI><A HREF="#toc26">Overloaded functions</A>
<UL>
<LI><A HREF="#toc27">Type class extension</A>
<LI><A HREF="#toc28">Extending multiple classes</A>
</UL>
<LI><A HREF="#prelude">Standard prelude</A>
<LI><A HREF="#toc30">Operators</A>
<UL>
<LI><A HREF="#toc31">Unary operators</A>
<LI><A HREF="#toc32">Binary operators</A>
</UL>
<LI><A HREF="#toc33">Compositional functions</A>
<LI><A HREF="#toc34">do notation</A>
</UL>
<P></P>
<HR NOSHADE SIZE=1>
<P></P>
<P>
<B>WARNING: The Transfer language is still experimental. Its syntax, type system and semantics may change without notice. I will try to help you with any problems this might cause, but I will not refrain from changing the language solely for reasons of backwards compatibility.</B>
</P>
<P>
This document describes the features of the Transfer language.
See the <A HREF="transfer-tutorial.html">Transfer tutorial</A>
for an example of a Transfer program, and how to compile and use
Transfer programs.
</P>
<P>
Transfer is a dependently typed functional programming language
with eager evaluation. The language supports generalized algebraic
datatypes, pattern matching and function overloading.
</P>
<A NAME="toc1"></A>
<H2>Current implementation status</H2>
<P>
<B>Not all features of the Transfer language have been implemented yet</B>. The most
important missing piece is the type checker. This means that there are almost
no checks done on Transfer programs before they are run. It also means that
the values of metavariables are not inferred. Thus metavariables cannot
be used where their values matter. For example, dictionaries for overloaded
functions must be given explicitly, not as metavariables.
</P>
<A NAME="toc2"></A>
<H2>Layout syntax</H2>
<P>
Transfer uses layout syntax, where the indentation of a piece of code
determines which syntactic block it belongs to.
</P>
<P>
To give the block structure without using layout
syntax, you can enclose the block in curly braces and
separate the parts of the blocks with semicolons.
</P>
<P>
For example, this case expression:
</P>
<PRE>
case x of
p1 -&gt; e1
p2 -&gt; e2
</PRE>
<P></P>
<P>
is equivalent to this one:
</P>
<PRE>
case x of {
p1 -&gt; e1 ;
p2 -&gt; e2
}
</PRE>
<P></P>
<P>
Here the layout is insignificant, as the structure is given with
braces and semicolons. Thus it is equivalent to:
</P>
<PRE>
case x of { p1 -&gt; e1 ; p2 -&gt; e2 }
</PRE>
<P></P>
<A NAME="toc3"></A>
<H2>Imports</H2>
<P>
A Transfer module starts with some imports. Most modules will have to
import the prelude, which contains definitons used by most programs:
</P>
<PRE>
import prelude
</PRE>
<P></P>
<P>
For more information about the standard prelude, see <A HREF="#prelude">Standard prelude</A>.
</P>
<A NAME="toc4"></A>
<H2>Function declarations</H2>
<P>
Functions need to be given a type and a definition. The type is given
by a typing judgement on the form:
</P>
<PRE>
f : T
</PRE>
<P></P>
<P>
where <CODE>f</CODE> is the function's name, and <CODE>T</CODE> its type. See
<A HREF="#function_types">Function types</A> for a how the types of functions
are written.
</P>
<P>
The definition of the function is then given as a sequence of pattern
equations. The first equation whose patterns match the function arguments
is used when the function is called. Pattern equations are on the form:
</P>
<PRE>
f p11 ... p1m = exp1
...
f pn1 ... pnm = expn
</PRE>
<P></P>
<P>
where <CODE>p11</CODE> to <CODE>pnm</CODE> are patterns, see <A HREF="#patterns">Patterns</A>.
</P>
<P>
Pattern equations can also have guards, boolean expressions which determine
whether to use the equation when the pattern has been matched. Pattern equations
with guards are written:
</P>
<PRE>
f p11 ... p1m | guard1 = exp1
...
f pn1 ... pnm | guardn = expn
</PRE>
<P></P>
<P>
Pattern equations with and without guards can be mixed in the definiton of
a function.
</P>
<P>
Any variables bound in the patterns are in scope in the guards and
right hand sides of each pattern equation.
</P>
<A NAME="toc5"></A>
<H2>Data type declarations</H2>
<P>
Transfer supports Generalized Algebraic Datatypes.
They are declared thusly:
</P>
<PRE>
data D : T where
c1 : Tc1
...
cn : Tcn
</PRE>
<P></P>
<P>
Here <CODE>D</CODE> is the name of the data type, <CODE>T</CODE> is the type of the type
constructor, <CODE>c1</CODE> to <CODE>cn</CODE> are the data constructor names, and
<CODE>Tc1</CODE> to <CODE>Tcn</CODE> are their types.
</P>
<P>
FIXME: explain the constraints on the types of type and data constructors.
</P>
<A NAME="toc6"></A>
<H2>Lambda expressions</H2>
<P>
<I>Lambda expressions</I> are terms which express functions, without
giving names to them. For example:
</P>
<PRE>
\x -&gt; x + 1
</PRE>
<P></P>
<P>
is the function which takes an argument, and returns the value of the
argument + 1.
</P>
<A NAME="toc7"></A>
<H2>Local definitions</H2>
<P>
To give local definition to some names, use:
</P>
<PRE>
let x1 = exp1
...
xn = expn
in exp
</PRE>
<P></P>
<P>
Here, the variables <CODE>x1</CODE> to <CODE>xn</CODE> are in scope in all the expressions
<CODE>exp1</CODE> to <CODE>expn</CODE>, and in <CODE>exp</CODE>. Thus let-defined functions can be
mutually recursive.
</P>
<A NAME="toc8"></A>
<H2>Types</H2>
<A NAME="function_types"></A>
<H3>Function types</H3>
<P>
Functions types are of the form:
</P>
<PRE>
A -&gt; B
</PRE>
<P></P>
<P>
This is the type of functions which take an argument of type
<CODE>A</CODE> and returns a result of type <CODE>B</CODE>.
</P>
<P>
To write functions which take more than one argument, we use <I>currying</I>.
A function which takes n arguments is a function which takes one
argument and returns a function which takes n-1 arguments. Thus,
</P>
<PRE>
A -&gt; (B -&gt; C)
</PRE>
<P></P>
<P>
or, equivalently, since <CODE>-&gt;</CODE> associates to the right:
</P>
<PRE>
A -&gt; B -&gt; C
</PRE>
<P></P>
<P>
is the type of functions which take teo arguments, the first of type
<CODE>A</CODE> and the second of type <CODE>B</CODE>. This arrangement lets us do
<I>partial application</I> of function to fewer arguments than the function
is declared to take, returning a new function which takes the rest
of the arguments.
</P>
<H4>Dependent function types</H4>
<P>
In a function type, the value of an argument can be used later
in the type. Such dependent function types are written:
</P>
<PRE>
(x : A) -&gt; B
</PRE>
<P></P>
<P>
Here, <CODE>x</CODE> is in scope in <CODE>B</CODE>.
</P>
<A NAME="toc10"></A>
<H3>Basic types</H3>
<H4>Integers</H4>
<P>
The type of integers is called <CODE>Integer</CODE>.
Standard decmial integer literals, such as <CODE>0</CODE> and <CODE>1234</CODE> are used to
represent values of this type.
</P>
<H4>Floating-point numbers</H4>
<P>
The only currently supported floating-point type is <CODE>Double</CODE>, which supports
IEEE-754 double-precision floating-point numbers. Double literals are written
in decimal notation, e.g. <CODE>123.456</CODE>.
</P>
<H4>Strings</H4>
<P>
There is a primitive <CODE>String</CODE> type. String literals are written
with double quotes, e.g. <CODE>"this is a string"</CODE>.
FIXME: This might be replaced by a list of
characters representation in the future.
</P>
<H4>Booleans</H4>
<P>
Booleans are not a built-in type, though some features of the Transfer language
depend on them. The <CODE>Bool</CODE> type is defined in the
<A HREF="#prelude">Standard prelude</A>.
</P>
<PRE>
data Bool : Type where
True : Bool
False : Bool
</PRE>
<P></P>
<P>
In addition to normal pattern matching on booleans, you can use the built-in
if-expression:
</P>
<PRE>
if exp1 then exp2 else exp3
</PRE>
<P></P>
<P>
where <CODE>exp1</CODE> must be an expression of type <CODE>Bool</CODE>.
</P>
<A NAME="toc11"></A>
<H3>Records</H3>
<H4>Record types</H4>
<P>
Record types are created by using a <CODE>sig</CODE> expression:
</P>
<PRE>
sig { l1 : T1; ... ; ln : Tn }
</PRE>
<P></P>
<P>
Here, <CODE>l1</CODE> to <CODE>ln</CODE> are the field labels and <CODE>T1</CODE> to <CODE>Tn</CODE> are field types.
</P>
<H4>Record values</H4>
<P>
Record values are constructed using <CODE>rec</CODE> expressions:
</P>
<PRE>
rec { l1 = exp1; ... ; ln = expn }
</PRE>
<P></P>
<H4>Record projection</H4>
<P>
Fields are selected from records using the <CODE>.</CODE> operator. This expression selects
the field <CODE>l</CODE> from the record value <CODE>r</CODE>:
</P>
<PRE>
r.l
</PRE>
<P></P>
<H4>Records and layout syntax</H4>
<P>
The curly braces and semicolons are simply explicit layout syntax, so
the record type and record expression above can also be written as:
</P>
<PRE>
sig l1 : T1
...
ln : Tn
</PRE>
<P></P>
<PRE>
rec l1 = exp1
...
ln = expn
</PRE>
<P></P>
<A NAME="record_subtyping"></A>
<H4>Record subtyping</H4>
<P>
A record of some type R1 can be used as a record of any type R2
such that for every field <CODE>p1 : T1</CODE> in R2, <CODE>p1 : T1</CODE> is also a
field of T1.
</P>
<A NAME="tuples"></A>
<H3>Tuples</H3>
<P>
Tuples on the form:
</P>
<PRE>
(exp1, ..., expn)
</PRE>
<P></P>
<P>
are syntactic sugar for records with fields <CODE>p1</CODE> to <CODE>pn</CODE>. The expression
above is equivalent to:
</P>
<PRE>
rec { p1 = exp1; ... ; pn = expn }
</PRE>
<P></P>
<A NAME="toc13"></A>
<H3>Lists</H3>
<P>
The <CODE>List</CODE> type is not built-in, though there is some special syntax for it.
The list type is declared as:
</P>
<PRE>
data List : Type -&gt; Type where
Nil : (A:Type) -&gt; List A
Cons : (A:Type) -&gt; A -&gt; List A -&gt; List A
</PRE>
<P></P>
<P>
The empty list can be written as <CODE>[]</CODE>. There is an operator <CODE>::</CODE> which can
be used instead of <CODE>Cons</CODE>. These are just syntactic sugar for expressions
using <CODE>Nil</CODE> and <CODE>Cons</CODE>, with the type arguments hidden.
</P>
<A NAME="toc14"></A>
<H2>Case expressions</H2>
<P>
Pattern matching is done in pattern equations and with the
<CODE>case</CODE> construct:
</P>
<PRE>
case exp of
p1 | guard1 -&gt; rhs1
...
pn | guardn -&gt; rhsn
</PRE>
<P></P>
<P>
where <CODE>p1</CODE> to <CODE>pn</CODE> are patterns, see <A HREF="#patterns">Patterns</A>.
<CODE>guard1</CODE> to <CODE>guardn</CODE> are boolean expressions. Case arms can also be written
without guards, such as:
</P>
<PRE>
pk -&gt; rhsk
</PRE>
<P></P>
<P>
This is the same as writing:
</P>
<PRE>
pk | True -&gt; rhsk
</PRE>
<P></P>
<A NAME="patterns"></A>
<H2>Patterns</H2>
<A NAME="toc16"></A>
<H3>Constructor patterns</H3>
<P>
Constructor patterns are written as:
</P>
<PRE>
C p1 ... pn
</PRE>
<P></P>
<P>
where <CODE>C</CODE> is a data constructor which takes <CODE>n</CODE> arguments.
If the value to be matched is <CODE>C v1 ... vn</CODE>,
then <CODE>v1</CODE> to <CODE>vn</CODE> will be matched against <CODE>p1</CODE> to <CODE>pn</CODE>.
</P>
<A NAME="toc17"></A>
<H3>Variable patterns</H3>
<P>
A variable pattern is a single identifier:
</P>
<PRE>
x
</PRE>
<P></P>
<P>
A variable pattern matches any value, and binds the variable name to the
value. A variable may not occur more than once in a pattern.
Note that variable patterns may not use the same identifier as data constructors
which are in scope, since they will then be interpreted as constructor
patterns.
</P>
<A NAME="toc18"></A>
<H3>Wildcard patterns</H3>
<P>
Wildcard patterns are written with a single underscore:
</P>
<PRE>
_
</PRE>
<P></P>
<P>
Wildcard patterns match all values and bind no variables.
</P>
<A NAME="toc19"></A>
<H3>Record patterns</H3>
<P>
Record patterns match record values:
</P>
<PRE>
rec { l1 = p1; ... ; ln = pn }
</PRE>
<P></P>
<P>
A record value matches a record pattern if the record value has all the
fields <CODE>l1</CODE> to <CODE>ln</CODE>, and their values match <CODE>p1</CODE> to <CODE>pn</CODE>.
</P>
<P>
Note that a record value may have more fields than the record pattern.
The values of these fields do not influence the pattern matching.
</P>
<A NAME="toc20"></A>
<H3>Disjunctive patterns</H3>
<P>
It is possible to write a pattern on the form:
</P>
<PRE>
p1 || ... || pn
</PRE>
<P></P>
<P>
A value will match this pattern if it matches any of the patterns <CODE>p1</CODE> to <CODE>pn</CODE>.
FIXME: talk about how this is expanded
</P>
<A NAME="toc21"></A>
<H3>List patterns</H3>
<P>
When pattern matching on lists, there are two special constructs.
A whole list can by matched be a list of patterns:
</P>
<PRE>
[p1, ... , pn]
</PRE>
<P></P>
<P>
This pattern will match lists of length n, such that each element
in the list matches the corresponding pattern. The empty list pattern:
</P>
<PRE>
[]
</PRE>
<P></P>
<P>
is a special case of this. It matches the empty list, oddly enough.
</P>
<P>
Non-empty lists can also be matched with <CODE>::</CODE>-patterns:
</P>
<PRE>
p1::p2
</PRE>
<P></P>
<P>
This pattern matches non-empty lists such that the first element of
the list matches <CODE>p1</CODE> and the rest of the list matches <CODE>p2</CODE>.
</P>
<A NAME="toc22"></A>
<H3>Tuple patterns</H3>
<P>
Tuples patterns on the form:
</P>
<PRE>
(p1, ... , pn)
</PRE>
<P></P>
<P>
are syntactic sugar for record patterns, in the same way as
tuple expressions, see <A HREF="#tuples">Tuples</A>.
</P>
<A NAME="toc23"></A>
<H3>String literal patterns</H3>
<P>
String literals can be used as patterns.
</P>
<A NAME="toc24"></A>
<H3>Integer literal patterns</H3>
<P>
Integer literals can be used as patterns.
</P>
<A NAME="metavariables"></A>
<H2>Metavariables</H2>
<P>
Metavariables are written as questions marks:
</P>
<PRE>
?
</PRE>
<P></P>
<P>
A metavariable is a way to tell the type checker that:
"you should be able to figure out what this should be,
I can't be bothered to tell you".
</P>
<P>
Metavariables can be used to avoid having to give type
and dictionary arguments explicitly.
</P>
<A NAME="toc26"></A>
<H2>Overloaded functions</H2>
<P>
In Transfer, functions can be overloaded by having them take a record
of functions as an argument. For example, the functions for equality
and inequality in the Transfer <A HREF="#prelude">Prelude</A> are defined as:
</P>
<PRE>
Eq : Type -&gt; Type
Eq A = sig eq : A -&gt; A -&gt; Bool
eq : (A : Type) -&gt; Eq A -&gt; A -&gt; A -&gt; Bool
eq _ d = d.eq
neq : (A : Type) -&gt; Eq A -&gt; A -&gt; A -&gt; Bool
neq A d x y = not (eq A d x y)
</PRE>
<P></P>
<P>
We call <CODE>Eq</CODE> a <I>type class</I>, though it's actually just a record type
used to pass function implementations to overloaded functions. We
call a value of type <CODE>Eq A</CODE> an Eq <I>dictionary</I> for the type A.
The dictionary is used to look up the version of some function for the
particular type we want to use the function on. Thus, in order to use
the <CODE>eq</CODE> function on two integers, we need a dictionary of type
<CODE>Eq Integer</CODE>:
</P>
<PRE>
eq_Integer : Eq Integer
eq_Integer = rec eq = prim_eq_Integer
</PRE>
<P></P>
<P>
where <CODE>prim_eq_Integer</CODE> is the built-in equality function for
integers. To check whether two numbers <CODE>x</CODE> and <CODE>y</CODE> are equal, we
can then call the overloaded <CODE>eq</CODE> function with the dictionary:
</P>
<PRE>
eq Integer eq_Integer x y
</PRE>
<P></P>
<P>
Giving the type at which to use the overloaded function, and the appropriate
dictionary can be cumbersome. <A HREF="#metavariables">Metavariables</A> come to the rescue:
</P>
<PRE>
eq ? ? x y
</PRE>
<P></P>
<P>
The type checker can in most cases figure out the values of the type and
dictionary arguments. <B>NOTE: this is not implemented yet.</B>
</P>
<A NAME="toc27"></A>
<H3>Type class extension</H3>
<P>
By using record subtyping, see <A HREF="#record_subtyping">Record subtyping</A>, we can
create type classes which extend other type classes. A dictionary for the
new type class can also be used as a dictionary for old type class.
</P>
<P>
For example, we can extend the <CODE>Eq</CODE> type class above to <CODE>Ord</CODE>, a type
class for orderings:
</P>
<PRE>
Ord : Type -&gt; Type
Ord A = sig eq : A -&gt; A -&gt; Bool
compare : A -&gt; A -&gt; Ordering
</PRE>
<P></P>
<P>
To extend an existing class, we keep the fields of the class we want to
extend, and add any new fields that we want. Because of record subtyping,
for any type <CODE>A</CODE>, a value of type <CODE>Ord A</CODE> is also a value of type <CODE>Eq A</CODE>.
</P>
<A NAME="toc28"></A>
<H3>Extending multiple classes</H3>
<P>
A type class can also extend several classes, by simply having all the fields
from all the classes we want to extend. The <CODE>Num</CODE> class in the
<A HREF="#prelude">Standard prelude</A> is an example of this.
</P>
<A NAME="prelude"></A>
<H2>Standard prelude</H2>
<P>
The standard prelude, see <A HREF="../transfer/lib/prelude.tra">prelude.tra</A>,
contains definitions of a number of standard types, functions and
type classes.
</P>
<A NAME="toc30"></A>
<H2>Operators</H2>
<P>
Most built-in operators in the Transfer language are translated
to calls to overloaded functions. This means that they can be
used at any type for which there is a dictionary for the type class
in question.
</P>
<A NAME="toc31"></A>
<H3>Unary operators</H3>
<TABLE CELLPADDING="4" BORDER="1">
<TR>
<TH>Operator</TH>
<TH>Precedence</TH>
<TH>Translation</TH>
</TR>
<TR>
<TD><CODE>-</CODE></TD>
<TD ALIGN="center">10</TD>
<TD ALIGN="center"><CODE>-x =&gt; negate ? ? x</CODE></TD>
</TR>
</TABLE>
<P></P>
<A NAME="toc32"></A>
<H3>Binary operators</H3>
<TABLE CELLPADDING="4" BORDER="1">
<TR>
<TH>Operator</TH>
<TH>Precedence</TH>
<TH>Associativity</TH>
<TH>Translation of <CODE>x op y</CODE></TH>
</TR>
<TR>
<TD ALIGN="center"><CODE>&gt;&gt;=</CODE></TD>
<TD ALIGN="center">3</TD>
<TD ALIGN="center">left</TD>
<TD ALIGN="center"><CODE>bind ? ? x y</CODE></TD>
</TR>
<TR>
<TD ALIGN="center"><CODE>&gt;&gt;</CODE></TD>
<TD ALIGN="center">3</TD>
<TD ALIGN="center">left</TD>
<TD ALIGN="center"><CODE>bind ? ? x (\_ -&gt; y)</CODE></TD>
</TR>
<TR>
<TD ALIGN="center"><CODE>||</CODE></TD>
<TD ALIGN="center">4</TD>
<TD ALIGN="center">right</TD>
<TD ALIGN="center"><CODE>if x then True else y</CODE></TD>
</TR>
<TR>
<TD ALIGN="center"><CODE>&amp;&amp;</CODE></TD>
<TD ALIGN="center">5</TD>
<TD ALIGN="center">right</TD>
<TD ALIGN="center"><CODE>if x then y else False</CODE></TD>
</TR>
<TR>
<TD ALIGN="center"><CODE>==</CODE></TD>
<TD ALIGN="center">6</TD>
<TD ALIGN="center">none</TD>
<TD ALIGN="center"><CODE>eq ? ? x y</CODE></TD>
</TR>
<TR>
<TD ALIGN="center"><CODE>/=</CODE></TD>
<TD ALIGN="center">6</TD>
<TD ALIGN="center">none</TD>
<TD ALIGN="center"><CODE>neq ? ? x y</CODE></TD>
</TR>
<TR>
<TD ALIGN="center"><CODE>&lt;</CODE></TD>
<TD ALIGN="center">6</TD>
<TD ALIGN="center">none</TD>
<TD ALIGN="center"><CODE>lt ? ? x y</CODE></TD>
</TR>
<TR>
<TD ALIGN="center"><CODE>&lt;=</CODE></TD>
<TD ALIGN="center">6</TD>
<TD ALIGN="center">none</TD>
<TD ALIGN="center"><CODE>le ? ? x y</CODE></TD>
</TR>
<TR>
<TD ALIGN="center"><CODE>&gt;</CODE></TD>
<TD ALIGN="center">6</TD>
<TD ALIGN="center">none</TD>
<TD ALIGN="center"><CODE>gt ? ? x y</CODE></TD>
</TR>
<TR>
<TD ALIGN="center"><CODE>&gt;=</CODE></TD>
<TD ALIGN="center">6</TD>
<TD ALIGN="center">none</TD>
<TD ALIGN="center"><CODE>ge ? ? x y</CODE></TD>
</TR>
<TR>
<TD ALIGN="center"><CODE>::</CODE></TD>
<TD ALIGN="center">7</TD>
<TD ALIGN="center">right</TD>
<TD ALIGN="center"><CODE>Cons ? ? x y</CODE></TD>
</TR>
<TR>
<TD ALIGN="center"><CODE>+</CODE></TD>
<TD ALIGN="center">8</TD>
<TD ALIGN="center">left</TD>
<TD ALIGN="center"><CODE>plus ? ? x y</CODE></TD>
</TR>
<TR>
<TD ALIGN="center"><CODE>-</CODE></TD>
<TD ALIGN="center">8</TD>
<TD ALIGN="center">left</TD>
<TD ALIGN="center"><CODE>minus ? ? x y</CODE></TD>
</TR>
<TR>
<TD ALIGN="center"><CODE>*</CODE></TD>
<TD ALIGN="center">9</TD>
<TD ALIGN="center">left</TD>
<TD ALIGN="center"><CODE>times ? ? x y</CODE></TD>
</TR>
<TR>
<TD ALIGN="center"><CODE>/</CODE></TD>
<TD ALIGN="center">9</TD>
<TD ALIGN="center">left</TD>
<TD ALIGN="center"><CODE>div ? ? x y</CODE></TD>
</TR>
<TR>
<TD ALIGN="center"><CODE>%</CODE></TD>
<TD ALIGN="center">9</TD>
<TD ALIGN="center">left</TD>
<TD ALIGN="center"><CODE>mod ? ? x y</CODE></TD>
</TR>
</TABLE>
<P></P>
<A NAME="toc33"></A>
<H2>Compositional functions</H2>
<A NAME="toc34"></A>
<H2>do notation</H2>
<P>
Sequences of operations in the Monad type class can be written
using do-notation, like in Haskell:
</P>
<PRE>
do x &lt;- f
y &lt;- g x
h y
</PRE>
<P></P>
<P>
is equivalent to:
</P>
<PRE>
f &gt;&gt;= \x -&gt; g x &gt;&gt;= \y -&gt; h y
</PRE>
<!-- html code generated by txt2tags 2.0 (http://txt2tags.sf.net) -->
<!-- cmdline: txt2tags transfer-reference.txt -->
</BODY></HTML>

View File

@@ -1,649 +0,0 @@
Transfer language reference
Author: Björn Bringert <bringert@cs.chalmers.se>
Last update: %%date(%c)
% NOTE: this is a txt2tags file.
% Create an html file from this file using:
% txt2tags transfer.txt
%!target:html
%!options(html): --toc
%!encoding:utf-8
**WARNING: The Transfer language is still experimental. Its syntax, type system and semantics may change without notice. I will try to help you with any problems this might cause, but I will not refrain from changing the language solely for reasons of backwards compatibility.**
This document describes the features of the Transfer language.
See the [Transfer tutorial transfer-tutorial.html]
for an example of a Transfer program, and how to compile and use
Transfer programs.
Transfer is a dependently typed functional programming language
with eager evaluation. The language supports generalized algebraic
datatypes, pattern matching and function overloading.
== Current implementation status ==
**Not all features of the Transfer language have been implemented yet**. The most
important missing piece is the type checker. This means that there are almost
no checks done on Transfer programs before they are run. It also means that
the values of metavariables are not inferred. Thus metavariables cannot
be used where their values matter. For example, dictionaries for overloaded
functions must be given explicitly, not as metavariables.
== Layout syntax==
Transfer uses layout syntax, where the indentation of a piece of code
determines which syntactic block it belongs to.
To give the block structure without using layout
syntax, you can enclose the block in curly braces and
separate the parts of the blocks with semicolons.
For example, this case expression:
```
case x of
p1 -> e1
p2 -> e2
```
is equivalent to this one:
```
case x of {
p1 -> e1 ;
p2 -> e2
}
```
Here the layout is insignificant, as the structure is given with
braces and semicolons. Thus it is equivalent to:
```
case x of { p1 -> e1 ; p2 -> e2 }
```
== Imports ==
A Transfer module starts with some imports. Most modules will have to
import the prelude, which contains definitons used by most programs:
```
import prelude
```
For more information about the standard prelude, see [Standard prelude #prelude].
== Function declarations ==
Functions need to be given a type and a definition. The type is given
by a typing judgement on the form:
```
f : T
```
where ``f`` is the function's name, and ``T`` its type. See
[Function types #function_types] for a how the types of functions
are written.
The definition of the function is then given as a sequence of pattern
equations. The first equation whose patterns match the function arguments
is used when the function is called. Pattern equations are on the form:
```
f p11 ... p1m = exp1
...
f pn1 ... pnm = expn
```
where ``p11`` to ``pnm`` are patterns, see [Patterns #patterns].
Pattern equations can also have guards, boolean expressions which determine
whether to use the equation when the pattern has been matched. Pattern equations
with guards are written:
```
f p11 ... p1m | guard1 = exp1
...
f pn1 ... pnm | guardn = expn
```
Pattern equations with and without guards can be mixed in the definiton of
a function.
Any variables bound in the patterns are in scope in the guards and
right hand sides of each pattern equation.
== Data type declarations ==
Transfer supports Generalized Algebraic Datatypes.
They are declared thusly:
```
data D : T where
c1 : Tc1
...
cn : Tcn
```
Here ``D`` is the name of the data type, ``T`` is the type of the type
constructor, ``c1`` to ``cn`` are the data constructor names, and
``Tc1`` to ``Tcn`` are their types.
FIXME: explain the constraints on the types of type and data constructors.
== Lambda expressions ==
//Lambda expressions// are terms which express functions, without
giving names to them. For example:
```
\x -> x + 1
```
is the function which takes an argument, and returns the value of the
argument + 1.
== Local definitions ==
To give local definition to some names, use:
```
let x1 = exp1
...
xn = expn
in exp
```
Here, the variables ``x1`` to ``xn`` are in scope in all the expressions
``exp1`` to ``expn``, and in ``exp``. Thus let-defined functions can be
mutually recursive.
== Types ==
=== Function types ===[function_types]
Functions types are of the form:
```
A -> B
```
This is the type of functions which take an argument of type
``A`` and returns a result of type ``B``.
To write functions which take more than one argument, we use //currying//.
A function which takes n arguments is a function which takes one
argument and returns a function which takes n-1 arguments. Thus,
```
A -> (B -> C)
```
or, equivalently, since ``->`` associates to the right:
```
A -> B -> C
```
is the type of functions which take teo arguments, the first of type
``A`` and the second of type ``B``. This arrangement lets us do
//partial application// of function to fewer arguments than the function
is declared to take, returning a new function which takes the rest
of the arguments.
==== Dependent function types ====
In a function type, the value of an argument can be used later
in the type. Such dependent function types are written:
```
(x : A) -> B
```
Here, ``x`` is in scope in ``B``.
=== Basic types ===
==== Integers ====
The type of integers is called ``Integer``.
Standard decmial integer literals, such as ``0`` and ``1234`` are used to
represent values of this type.
==== Floating-point numbers ====
The only currently supported floating-point type is ``Double``, which supports
IEEE-754 double-precision floating-point numbers. Double literals are written
in decimal notation, e.g. ``123.456``.
==== Strings ====
There is a primitive ``String`` type. String literals are written
with double quotes, e.g. ``"this is a string"``.
FIXME: This might be replaced by a list of
characters representation in the future.
==== Booleans ====
Booleans are not a built-in type, though some features of the Transfer language
depend on them. The ``Bool`` type is defined in the
[Standard prelude #prelude].
```
data Bool : Type where
True : Bool
False : Bool
```
In addition to normal pattern matching on booleans, you can use the built-in
if-expression:
```
if exp1 then exp2 else exp3
```
where ``exp1`` must be an expression of type ``Bool``.
=== Records ===
==== Record types ====
Record types are created by using a ``sig`` expression:
```
sig { l1 : T1; ... ; ln : Tn }
```
Here, ``l1`` to ``ln`` are the field labels and ``T1`` to ``Tn`` are field types.
==== Record values ====
Record values are constructed using ``rec`` expressions:
```
rec { l1 = exp1; ... ; ln = expn }
```
==== Record projection ====
Fields are selected from records using the ``.`` operator. This expression selects
the field ``l`` from the record value ``r``:
```
r.l
```
==== Records and layout syntax ====
The curly braces and semicolons are simply explicit layout syntax, so
the record type and record expression above can also be written as:
```
sig l1 : T1
...
ln : Tn
```
```
rec l1 = exp1
...
ln = expn
```
==== Record subtyping ====[record_subtyping]
A record of some type R1 can be used as a record of any type R2
such that for every field ``p1 : T1`` in R2, ``p1 : T1`` is also a
field of T1.
=== Tuples ===[tuples]
Tuples on the form:
```
(exp1, ..., expn)
```
are syntactic sugar for records with fields ``p1`` to ``pn``. The expression
above is equivalent to:
```
rec { p1 = exp1; ... ; pn = expn }
```
=== Lists ===
The ``List`` type is not built-in, though there is some special syntax for it.
The list type is declared as:
```
data List : Type -> Type where
Nil : (A:Type) -> List A
Cons : (A:Type) -> A -> List A -> List A
```
The empty list can be written as ``[]``. There is an operator ``::`` which can
be used instead of ``Cons``. These are just syntactic sugar for expressions
using ``Nil`` and ``Cons``, with the type arguments hidden.
== Case expressions ==
Pattern matching is done in pattern equations and with the
``case`` construct:
```
case exp of
p1 | guard1 -> rhs1
...
pn | guardn -> rhsn
```
where ``p1`` to ``pn`` are patterns, see [Patterns #patterns].
``guard1`` to ``guardn`` are boolean expressions. Case arms can also be written
without guards, such as:
```
pk -> rhsk
```
This is the same as writing:
```
pk | True -> rhsk
```
== Patterns ==[patterns]
=== Constructor patterns ===
Constructor patterns are written as:
```
C p1 ... pn
```
where ``C`` is a data constructor which takes ``n`` arguments.
If the value to be matched is ``C v1 ... vn``,
then ``v1`` to ``vn`` will be matched against ``p1`` to ``pn``.
=== Variable patterns ===
A variable pattern is a single identifier:
```
x
```
A variable pattern matches any value, and binds the variable name to the
value. A variable may not occur more than once in a pattern.
Note that variable patterns may not use the same identifier as data constructors
which are in scope, since they will then be interpreted as constructor
patterns.
=== Wildcard patterns ===
Wildcard patterns are written with a single underscore:
```
_
```
Wildcard patterns match all values and bind no variables.
=== Record patterns ===
Record patterns match record values:
```
rec { l1 = p1; ... ; ln = pn }
```
A record value matches a record pattern if the record value has all the
fields ``l1`` to ``ln``, and their values match ``p1`` to ``pn``.
Note that a record value may have more fields than the record pattern.
The values of these fields do not influence the pattern matching.
=== Disjunctive patterns ===
It is possible to write a pattern on the form:
```
p1 || ... || pn
```
A value will match this pattern if it matches any of the patterns ``p1`` to ``pn``.
FIXME: talk about how this is expanded
=== List patterns ===
When pattern matching on lists, there are two special constructs.
A whole list can by matched be a list of patterns:
```
[p1, ... , pn]
```
This pattern will match lists of length n, such that each element
in the list matches the corresponding pattern. The empty list pattern:
```
[]
```
is a special case of this. It matches the empty list, oddly enough.
Non-empty lists can also be matched with ``::``-patterns:
```
p1::p2
```
This pattern matches non-empty lists such that the first element of
the list matches ``p1`` and the rest of the list matches ``p2``.
=== Tuple patterns ===
Tuples patterns on the form:
```
(p1, ... , pn)
```
are syntactic sugar for record patterns, in the same way as
tuple expressions, see [Tuples #tuples].
=== String literal patterns ===
String literals can be used as patterns.
=== Integer literal patterns ===
Integer literals can be used as patterns.
== Metavariables ==[metavariables]
Metavariables are written as questions marks:
```
?
```
A metavariable is a way to tell the type checker that:
"you should be able to figure out what this should be,
I can't be bothered to tell you".
Metavariables can be used to avoid having to give type
and dictionary arguments explicitly.
== Overloaded functions ==
In Transfer, functions can be overloaded by having them take a record
of functions as an argument. For example, the functions for equality
and inequality in the Transfer [Prelude #prelude] are defined as:
```
Eq : Type -> Type
Eq A = sig eq : A -> A -> Bool
eq : (A : Type) -> Eq A -> A -> A -> Bool
eq _ d = d.eq
neq : (A : Type) -> Eq A -> A -> A -> Bool
neq A d x y = not (eq A d x y)
```
We call ``Eq`` a //type class//, though it's actually just a record type
used to pass function implementations to overloaded functions. We
call a value of type ``Eq A`` an Eq //dictionary// for the type A.
The dictionary is used to look up the version of some function for the
particular type we want to use the function on. Thus, in order to use
the ``eq`` function on two integers, we need a dictionary of type
``Eq Integer``:
```
eq_Integer : Eq Integer
eq_Integer = rec eq = prim_eq_Integer
```
where ``prim_eq_Integer`` is the built-in equality function for
integers. To check whether two numbers ``x`` and ``y`` are equal, we
can then call the overloaded ``eq`` function with the dictionary:
```
eq Integer eq_Integer x y
```
Giving the type at which to use the overloaded function, and the appropriate
dictionary can be cumbersome. [Metavariables #metavariables] come to the rescue:
```
eq ? ? x y
```
The type checker can in most cases figure out the values of the type and
dictionary arguments. **NOTE: this is not implemented yet.**
=== Type class extension ===
By using record subtyping, see [Record subtyping #record_subtyping], we can
create type classes which extend other type classes. A dictionary for the
new type class can also be used as a dictionary for old type class.
For example, we can extend the ``Eq`` type class above to ``Ord``, a type
class for orderings:
```
Ord : Type -> Type
Ord A = sig eq : A -> A -> Bool
compare : A -> A -> Ordering
```
To extend an existing class, we keep the fields of the class we want to
extend, and add any new fields that we want. Because of record subtyping,
for any type ``A``, a value of type ``Ord A`` is also a value of type ``Eq A``.
=== Extending multiple classes ===
A type class can also extend several classes, by simply having all the fields
from all the classes we want to extend. The ``Num`` class in the
[Standard prelude #prelude] is an example of this.
== Standard prelude ==[prelude]
The standard prelude, see [prelude.tra ../transfer/lib/prelude.tra],
contains definitions of a number of standard types, functions and
type classes.
== Operators ==
Most built-in operators in the Transfer language are translated
to calls to overloaded functions. This means that they can be
used at any type for which there is a dictionary for the type class
in question.
=== Unary operators ===
|| Operator | Precedence | Translation |
| ``-`` | 10 | ``-x => negate ? ? x`` |
=== Binary operators ===
|| Operator | Precedence | Associativity | Translation of ``x op y`` |
| ``>>=`` | 3 | left | ``bind ? ? x y`` |
| ``>>`` | 3 | left | ``bind ? ? x (\_ -> y)`` |
| ``||`` | 4 | right | ``if x then True else y`` |
| ``&&`` | 5 | right | ``if x then y else False`` |
| ``==`` | 6 | none | ``eq ? ? x y`` |
| ``/=`` | 6 | none | ``neq ? ? x y`` |
| ``<`` | 6 | none | ``lt ? ? x y`` |
| ``<=`` | 6 | none | ``le ? ? x y`` |
| ``>`` | 6 | none | ``gt ? ? x y`` |
| ``>=`` | 6 | none | ``ge ? ? x y`` |
| ``::`` | 7 | right | ``Cons ? ? x y`` |
| ``+`` | 8 | left | ``plus ? ? x y`` |
| ``-`` | 8 | left | ``minus ? ? x y`` |
| ``*`` | 9 | left | ``times ? ? x y`` |
| ``/`` | 9 | left | ``div ? ? x y`` |
| ``%`` | 9 | left | ``mod ? ? x y`` |
== Compositional functions ==
== do notation ==
Sequences of operations in the Monad type class can be written
using do-notation, like in Haskell:
```
do x <- f
y <- g x
h y
```
is equivalent to:
```
f >>= \x -> g x >>= \y -> h y
```

View File

@@ -1,214 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META NAME="generator" CONTENT="http://txt2tags.sf.net">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<TITLE>Transfer tutorial</TITLE>
</HEAD><BODY BGCOLOR="white" TEXT="black">
<P ALIGN="center"><CENTER><H1>Transfer tutorial</H1>
<FONT SIZE="4">
<I>Author: Björn Bringert &lt;bringert@cs.chalmers.se&gt;</I><BR>
Last update: Fri Dec 9 11:55:35 2005
</FONT></CENTER>
<P></P>
<HR NOSHADE SIZE=1>
<P></P>
<UL>
<LI><A HREF="#toc1">Objective</A>
<LI><A HREF="#toc2">Abstract syntax</A>
<LI><A HREF="#toc3">Concrete syntax</A>
<LI><A HREF="#toc4">Generate tree module</A>
<LI><A HREF="#toc5">Write transfer code</A>
<LI><A HREF="#toc6">Compiling Transfer programs</A>
<LI><A HREF="#toc7">Using Transfer programs in GF</A>
<UL>
<LI><A HREF="#toc8">Loading the grammars</A>
<LI><A HREF="#toc9">Loading the Transfer program</A>
<LI><A HREF="#toc10">Calling Transfer functions</A>
<UL>
<LI><A HREF="#toc11">Transfer between different abstract syntaxes</A>
</UL>
</UL>
</UL>
<P></P>
<HR NOSHADE SIZE=1>
<P></P>
<P>
<B>WARNING: The Transfer language is still experimental. Its syntax, type system and semantics may change without notice. I will try to help you with any problems this might cause, but I will not refrain from changing the language solely for reasons of backwards compatibility.</B>
</P>
<A NAME="toc1"></A>
<H1>Objective</H1>
<P>
We want to write a Transfer program which we can use to do aggregation
in sentences which use conjunctions on the sentence, noun phrase and
verb phrase levels. For example, we want to be able to transform
the sentence "John walks and Mary walks" to the sentence
"John and Mary walk". We would also like to transform
"John walks and John swims" to "John walks and swims".
</P>
<P>
Thus that what we want to do is:
</P>
<UL>
<LI>Transform sentence conjunction where the verb phrases in the sentences
are identical to noun phrase conjunction.
<LI>Transform sentence conjunction where the noun phrases in the sentences
are identical to verb phrase conjunction.
</UL>
<P>
This needs to be done recursively and thoughout the sentence, to be
able to handle cases like "John walks and Mary walks and Bill walks", and
"John runs and Mary walks and Bill walks".
</P>
<P>
FIXME: what about John walks and Mary runs and Bill walks"?
</P>
<A NAME="toc2"></A>
<H1>Abstract syntax</H1>
<P>
We will use the abstract syntax defined in
<A HREF="../transfer/examples/aggregation/Abstract.gf">Abstract.gf</A>.
</P>
<A NAME="toc3"></A>
<H1>Concrete syntax</H1>
<P>
There is an English concrete syntax for this grammar in
<A HREF="../transfer/examples/aggregation/English.gf">English.gf</A>.
</P>
<A NAME="toc4"></A>
<H1>Generate tree module</H1>
<P>
To be able to write Transfer programs which use the types defined in
an abstract syntax, we first need to generate a Transfer file with
a data type defintition corresponding to the abstract syntax.
This is done with the <CODE>transfer</CODE> grammar printer:
</P>
<PRE>
$ gf
&gt; i English.gf
&gt; pg -printer=transfer | wf tree.tra
</PRE>
<P></P>
<P>
Note that you need to load a concrete syntax which uses the abstract
syntax that you want to create a Transfer data type for. Loading just the
abstract syntax module is not enough. FIXME: why?
</P>
<P>
The command sequence above writes a Transfer data type definition to the
file <A HREF="../transfer/examples/aggregation/tree.tra">tree.tra</A>.
</P>
<A NAME="toc5"></A>
<H1>Write transfer code</H1>
<P>
We write the Transfer program
<A HREF="../transfer/examples/aggregation/aggregate.tra">aggregate.tra</A>.
</P>
<P>
FIXME: explain the code
</P>
<A NAME="toc6"></A>
<H1>Compiling Transfer programs</H1>
<P>
Transfer programs are written in the human-friendly Transfer language,
but GF only understands the simpler Transfer Core language. Therefore,
before using a Transfer program, you must first compile it to
Transfer Core. This is done using the <CODE>transferc</CODE> command:
</P>
<PRE>
$ transferc -i&lt;lib&gt; &lt;transfer program&gt;
</PRE>
<P></P>
<P>
Here, <CODE>&lt;lib&gt;</CODE> is the path to search for any modules which you import
in your Transfer program. You can give several <CODE>-i</CODE> flags.
</P>
<P>
So, to compile <CODE>aggregate.tra</CODE> which we created above, we use:
</P>
<PRE>
$ transferc aggregate.tra
</PRE>
<P></P>
<P>
The creates the Transfer Core file <CODE>aggregate.trc</CODE>.
</P>
<A NAME="toc7"></A>
<H1>Using Transfer programs in GF</H1>
<A NAME="toc8"></A>
<H2>Loading the grammars</H2>
<P>
To use a Transfer Core program to transform abstract syntax terms
in GF, you must first load the grammars which you want to use the
program with. For the example above, we need the grammar <CODE>English.gf</CODE>
and its dependencies. We load this grammar with:
</P>
<PRE>
&gt; i English.gf
</PRE>
<P></P>
<A NAME="toc9"></A>
<H2>Loading the Transfer program</H2>
<P>
There are two steps to using a Transfer Core program in GF. First you load
the program into GF. This is done with the <CODE>i</CODE> command, which is also
used when loading grammar modules. To load the <CODE>aggregate.trc</CODE> which
we created above, we use:
</P>
<PRE>
&gt; i aggregate.trc
</PRE>
<P></P>
<A NAME="toc10"></A>
<H2>Calling Transfer functions</H2>
<P>
To call a Transfer function on a term, we use the <CODE>at</CODE> command.
The <CODE>at</CODE> command takes the name of a Transfer function and an abstract
syntax term, and applies the function to the term:
</P>
<PRE>
&gt; at aggregS ConjS And (Pred John Walk) (Pred Mary Walk)
Pred (ConjNP And John Mary) Walk
</PRE>
<P></P>
<P>
Of course, the input and output terms of the <CODE>at</CODE> command can
be read from and written to pipes:
</P>
<PRE>
&gt; p "John walks and Mary walks" | at aggregS | l
John and Mary walk
</PRE>
<P></P>
<P>
To see what is going on between the steps, we can use <CODE>-tr</CODE> flags
to the commands:
</P>
<PRE>
&gt; p -tr "John walks and Mary walks" | at -tr aggregS | l
ConjS And (Pred John Walk) (Pred Mary Walk)
Pred (ConjNP And John Mary) Walk
John and Mary walk
</PRE>
<P></P>
<A NAME="toc11"></A>
<H3>Transfer between different abstract syntaxes</H3>
<P>
If the transfer function which you wan to call takes as input a term in one
abstract syntax, and returns a term in a different abstract syntax, you
can use the <CODE>-lang</CODE> flag with the <CODE>at</CODE> command. This is needed since the
<CODE>at</CODE> command type checks the result it produces, and it needs to
know which abstract sytnax to type check it in.
</P>
<!-- html code generated by txt2tags 2.0 (http://txt2tags.sf.net) -->
<!-- cmdline: txt2tags transfer-tutorial.txt -->
</BODY></HTML>

View File

@@ -1,165 +0,0 @@
Transfer tutorial
Author: Björn Bringert <bringert@cs.chalmers.se>
Last update: %%date(%c)
% NOTE: this is a txt2tags file.
% Create an html file from this file using:
% txt2tags -t html --toc darcs.txt
%!target:html
%!options(html): --toc
%!encoding:utf-8
**WARNING: The Transfer language is still experimental. Its syntax, type system and semantics may change without notice. I will try to help you with any problems this might cause, but I will not refrain from changing the language solely for reasons of backwards compatibility.**
= Objective =
We want to write a Transfer program which we can use to do aggregation
in sentences which use conjunctions on the sentence, noun phrase and
verb phrase levels. For example, we want to be able to transform
the sentence "John walks and Mary walks" to the sentence
"John and Mary walk". We would also like to transform
"John walks and John swims" to "John walks and swims".
Thus that what we want to do is:
- Transform sentence conjunction where the verb phrases in the sentences
are identical to noun phrase conjunction.
- Transform sentence conjunction where the noun phrases in the sentences
are identical to verb phrase conjunction.
This needs to be done recursively and thoughout the sentence, to be
able to handle cases like "John walks and Mary walks and Bill walks", and
"John runs and Mary walks and Bill walks".
FIXME: what about John walks and Mary runs and Bill walks"?
= Abstract syntax =
We will use the abstract syntax defined in
[Abstract.gf ../transfer/examples/aggregation/Abstract.gf].
= Concrete syntax =
There is an English concrete syntax for this grammar in
[English.gf ../transfer/examples/aggregation/English.gf].
= Generate tree module =
To be able to write Transfer programs which use the types defined in
an abstract syntax, we first need to generate a Transfer file with
a data type defintition corresponding to the abstract syntax.
This is done with the ``transfer`` grammar printer:
```
$ gf
> i English.gf
> pg -printer=transfer | wf tree.tra
```
Note that you need to load a concrete syntax which uses the abstract
syntax that you want to create a Transfer data type for. Loading just the
abstract syntax module is not enough. FIXME: why?
The command sequence above writes a Transfer data type definition to the
file [tree.tra ../transfer/examples/aggregation/tree.tra].
= Write transfer code =
We write the Transfer program
[aggregate.tra ../transfer/examples/aggregation/aggregate.tra].
FIXME: explain the code
= Compiling Transfer programs =
Transfer programs are written in the human-friendly Transfer language,
but GF only understands the simpler Transfer Core language. Therefore,
before using a Transfer program, you must first compile it to
Transfer Core. This is done using the ``transferc`` command:
```
$ transferc -i<lib> <transfer program>
```
Here, ``<lib>`` is the path to search for any modules which you import
in your Transfer program. You can give several ``-i`` flags.
So, to compile ``aggregate.tra`` which we created above, we use:
```
$ transferc aggregate.tra
```
The creates the Transfer Core file ``aggregate.trc``.
= Using Transfer programs in GF =
== Loading the grammars ==
To use a Transfer Core program to transform abstract syntax terms
in GF, you must first load the grammars which you want to use the
program with. For the example above, we need the grammar ``English.gf``
and its dependencies. We load this grammar with:
```
> i English.gf
```
== Loading the Transfer program ==
There are two steps to using a Transfer Core program in GF. First you load
the program into GF. This is done with the ``i`` command, which is also
used when loading grammar modules. To load the ``aggregate.trc`` which
we created above, we use:
```
> i aggregate.trc
```
== Calling Transfer functions ==
To call a Transfer function on a term, we use the ``at`` command.
The ``at`` command takes the name of a Transfer function and an abstract
syntax term, and applies the function to the term:
```
> at aggregS ConjS And (Pred John Walk) (Pred Mary Walk)
Pred (ConjNP And John Mary) Walk
```
Of course, the input and output terms of the ``at`` command can
be read from and written to pipes:
```
> p "John walks and Mary walks" | at aggregS | l
John and Mary walk
```
To see what is going on between the steps, we can use ``-tr`` flags
to the commands:
```
> p -tr "John walks and Mary walks" | at -tr aggregS | l
ConjS And (Pred John Walk) (Pred Mary Walk)
Pred (ConjNP And John Mary) Walk
John and Mary walk
```
=== Transfer between different abstract syntaxes ===
If the transfer function which you wan to call takes as input a term in one
abstract syntax, and returns a term in a different abstract syntax, you
can use the ``-lang`` flag with the ``at`` command. This is needed since the
``at`` command type checks the result it produces, and it needs to
know which abstract sytnax to type check it in.

View File

@@ -1,34 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META NAME="generator" CONTENT="http://txt2tags.sf.net">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<TITLE>The GF Transfer language</TITLE>
</HEAD><BODY BGCOLOR="white" TEXT="black">
<P ALIGN="center"><CENTER><H1>The GF Transfer language</H1>
<FONT SIZE="4">
<I>Author: Björn Bringert &lt;bringert@cs.chalmers.se&gt;</I><BR>
Last update: Fri Dec 9 11:54:38 2005
</FONT></CENTER>
<P>
<B>WARNING: The Transfer language is still experimental. Its syntax, type system and semantics may change without notice. I will try to help you with any problems this might cause, but I will not refrain from changing the language solely for reasons of backwards compatibility.</B>
</P>
<P>
The GF Transfer language is a programming language which can be
used to write functions which work on abstract syntax terms.
</P>
<H1>Transfer tutorial</H1>
<P>
The <A HREF="transfer-tutorial.html">Transfer tutorial</A> shows an example of how to
write and use a simple transfer function for a GF grammar.
</P>
<H1>Transfer reference</H1>
<P>
The <A HREF="transfer-reference.html">Transfer reference</A> aims to cover
all constructs in the Transfer language.
</P>
<!-- html code generated by txt2tags 2.0 (http://txt2tags.sf.net) -->
<!-- cmdline: txt2tags transfer.txt -->
</BODY></HTML>

View File

@@ -1,27 +0,0 @@
The GF Transfer language
Author: Björn Bringert <bringert@cs.chalmers.se>
Last update: %%date(%c)
% NOTE: this is a txt2tags file.
% Create an html file from this file using:
% txt2tags transfer.txt
%!target:html
%!encoding:utf-8
**WARNING: The Transfer language is still experimental. Its syntax, type system and semantics may change without notice. I will try to help you with any problems this might cause, but I will not refrain from changing the language solely for reasons of backwards compatibility.**
The GF Transfer language is a programming language which can be
used to write functions which work on abstract syntax terms.
= Transfer tutorial =
The [Transfer tutorial transfer-tutorial.html] shows an example of how to
write and use a simple transfer function for a GF grammar.
= Transfer reference =
The [Transfer reference transfer-reference.html] aims to cover
all constructs in the Transfer language.

View File

@@ -1,183 +0,0 @@
Idea: in GFC, represent tables as just lists values, without showing
the parameters.
Concrete syntax:
table T [t1 ; ... ; tn]
where t1,...,tn are terms. This is treated as equivalent to
table {p1 => t1 ; ... ; pn => tn}
where p1,...,pn is the canonical listing of patterns of type T.
Advantage: reduce the size of GFC files.
Disadvantages: you don't get the sharing optimization, e.g.
table {A|B => v} instead of table T [v ; v]
Moreover, it is slower to select from the table, because
one first has to look up the position index of the argument.
Usage: when compiling a module, use the -val option:
i -val -src Foo.gf
Summary of results, testing with lib/resource/french/TestVerbesFre.gf:
without -val with -val ratio
compilation time 129 s 84 s 65 %
time to read back gfcm 109 s 32 s 29 %
size of generated gfcm 28 M 9 M 32 %
memory use in compilation 376 M 251 M 67 %
memory use in reading gfcm 1120 M 524 M 47 %
No significant loss in linearization (which needs selection).
Conclusion: for the case at hand (which prompted the experiment
at the first place), the gain is significant: compilation needs
30 % less resources, and using the compiled grammar needs
50-70 % less.
More testing is desirable to find out if -val is always good.
At the moment, reuse is not possible with gfc modules created
with the -val flag (although it is supported by the GF syntax
already).
10/1/2004
Test the generation of course-of-values tables
---------------------
Without:
i -src TestVerbesFre.gf
129160 msec
> gr -cat=V | l -table
650 msec
gf +RTS -K10M -s
8,469,778,952 bytes allocated in the heap
2,779,891,252 bytes copied during GC
133,108,856 bytes maximum residency (36 sample(s))
32295 collections in generation 0 ( 24,25s)
36 collections in generation 1 ( 24,68s)
376 Mb total memory in use
INIT time 0,01s ( 0,04s elapsed)
MUT time 80,21s (499,76s elapsed)
GC time 48,93s ( 50,01s elapsed)
EXIT time 0,00s ( 0,00s elapsed)
Total time 129,15s (549,81s elapsed)
%GC time 37,9% (9,1% elapsed)
Alloc rate 105,581,886 bytes per MUT second
Productivity 62,1% of total user, 14,6% of total elapsed
wc french/*.gfc french/*.gfr
37 2533 44976 french/CategoriesFre.gfc
0 9 62 french/ConjugNancy.gfc
2 29 137 french/MorphoFre.gfc
29 966 7641 french/NumeralsFre.gfc
136 393891 4415193 french/RulesFre.gfc
151 4211 39290 french/StructuralFre.gfc
123 607 3259 french/SyntaxFre.gfc
285 4702 59892 french/TestResourceFre.gfc
6790 27179 184046 french/TestVerbesAbs.gfc
6781 28170 198376 french/TestVerbesFre.gfc
20 214 1245 french/TypesFre.gfc
6494 45458 254878 french/VerbesAbs.gfc
6494 1272600 23438292 french/VerbesFre.gfc
6449 45143 209154 french/Vs.gfc
6278 47836 426316 french/ConjugNancy.gfr
14465 72471 655006 french/MorphoFre.gfr
238250 798560 8973600 french/SyntaxFre.gfr
492 2557 21908 french/TypesFre.gfr
293276 2747136 38933271 total
pm | wf test0.gfcm
55660 msec
wc test0.gfcm
28041 1784674 28669416 test0.gfcm
> i test0.gfcm
+ reading test0.gfcm 103290 msec
109450 msec
1120 Mb total memory in use
----------------------
After:
i -src -val TestVerbesFre.gf
84650 msec
gr -cat=V | l -table
390 msec
gf +RTS -K10M -s
6,061,907,436 bytes allocated in the heap
1,576,739,488 bytes copied during GC
92,700,188 bytes maximum residency (32 sample(s))
23109 collections in generation 0 ( 13,98s)
32 collections in generation 1 ( 12,02s)
251 Mb total memory in use
INIT time 0,01s ( 0,00s elapsed)
MUT time 59,28s (122,35s elapsed)
GC time 26,00s ( 26,91s elapsed)
EXIT time 0,00s ( 0,00s elapsed)
Total time 85,29s (149,26s elapsed)
%GC time 30,5% (18,0% elapsed)
Alloc rate 102,241,650 bytes per MUT second
Productivity 69,5% of total user, 39,7% of total elapsed
wc french/*.gfc french/*.gfr
37 3894 13600 french/CategoriesFre.gfc
0 9 62 french/ConjugNancy.gfc
2 29 137 french/MorphoFre.gfc
29 938 5726 french/NumeralsFre.gfc
136 354450 3097901 french/RulesFre.gfc
151 3738 22354 french/StructuralFre.gfc
123 607 3259 french/SyntaxFre.gfc
285 2437 18664 french/TestResourceFre.gfc
6790 27179 184046 french/TestVerbesAbs.gfc
6781 27694 191696 french/TestVerbesFre.gfc
20 214 1245 french/TypesFre.gfc
6494 45458 254878 french/VerbesAbs.gfc
6494 442149 5078881 french/VerbesFre.gfc
6449 45143 209154 french/Vs.gfc
6278 47836 426316 french/ConjugNancy.gfr
14465 72471 655006 french/MorphoFre.gfr
238250 798560 8973600 french/SyntaxFre.gfr
492 2557 21908 french/TypesFre.gfr
293276 1875363 19158433 total
pm | wf test1.gfcm
13030 msec
wc test1.gfcm
28041 912901 8894578 test1.gfcm
> i test1.gfcm
+ reading test1.gfcm 24220 msec
32720 msec
524 Mb total memory in use