mirror of
https://github.com/GaloisInc/cryptol.git
synced 2024-09-11 22:17:18 +03:00
Remove [x..]
and [x,y..]
syntax from documentation.
This commit is contained in:
parent
7ea4884fdd
commit
e59c9abfbb
@ -1,4 +1,4 @@
|
||||
% IMPORTANT: The file Syntax.tex is generated automatically from the
|
||||
% markdown in ../../Syntax.md. If you make changes, please make them
|
||||
% there and then regenarte the .tex file using the Makefile.
|
||||
% there and then regenerate the .tex file using the Makefile.
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
% IMPORTANT: The file Syntax.tex is generated automatically from the
|
||||
% markdown in ../../Syntax.md. If you make changes, please make them
|
||||
% there and then regenarte the .tex file using the Makefile.
|
||||
% there and then regenerate the .tex file using the Makefile.
|
||||
|
||||
\section{Layout}\label{layout}
|
||||
\hypertarget{layout}{%
|
||||
\section{Layout}\label{layout}}
|
||||
|
||||
Groups of declarations are organized based on indentation. Declarations
|
||||
with the same indentation belong to the same group. Lines of text that
|
||||
@ -32,7 +33,8 @@ containing \texttt{y} and \texttt{z}. This group ends just before
|
||||
\texttt{g}, because \texttt{g} is indented less than \texttt{y} and
|
||||
\texttt{z}.
|
||||
|
||||
\section{Comments}\label{comments}
|
||||
\hypertarget{comments}{%
|
||||
\section{Comments}\label{comments}}
|
||||
|
||||
Cryptol supports block comments, which start with \texttt{/*} and end
|
||||
with \texttt{*/}, and line comments, which start with \texttt{//} and
|
||||
@ -47,7 +49,8 @@ Examples:
|
||||
/* This is a /* Nested */ block comment */
|
||||
\end{verbatim}
|
||||
|
||||
\section{Identifiers}\label{identifiers}
|
||||
\hypertarget{identifiers}{%
|
||||
\section{Identifiers}\label{identifiers}}
|
||||
|
||||
Cryptol identifiers consist of one or more characters. The first
|
||||
character must be either an English letter or underscore (\texttt{\_}).
|
||||
@ -64,8 +67,9 @@ name name1 name' longer_name
|
||||
Name Name2 Name'' longerName
|
||||
\end{verbatim}
|
||||
|
||||
\hypertarget{keywords-and-built-in-operators}{\section{Keywords and
|
||||
Built-in Operators}\label{keywords-and-built-in-operators}}
|
||||
\hypertarget{keywords-and-built-in-operators}{%
|
||||
\section{Keywords and Built-in
|
||||
Operators}\label{keywords-and-built-in-operators}}
|
||||
|
||||
The following identifiers have special meanings in Cryptol, and may not
|
||||
be used for programmer defined names:
|
||||
@ -116,8 +120,9 @@ left\tabularnewline
|
||||
\bottomrule
|
||||
\end{longtable}
|
||||
|
||||
\hypertarget{built-in-type-level-operators}{%
|
||||
\section{Built-in Type-level
|
||||
Operators}\label{built-in-type-level-operators}
|
||||
Operators}\label{built-in-type-level-operators}}
|
||||
|
||||
Cryptol includes a variety of operators that allow computations on the
|
||||
numeric types used to specify the sizes of sequences.
|
||||
@ -149,7 +154,8 @@ up)\tabularnewline
|
||||
\bottomrule
|
||||
\end{longtable}
|
||||
|
||||
\section{Numeric Literals}\label{numeric-literals}
|
||||
\hypertarget{numeric-literals}{%
|
||||
\section{Numeric Literals}\label{numeric-literals}}
|
||||
|
||||
Numeric literals may be written in binary, octal, decimal, or
|
||||
hexadecimal notation. The base of a literal is determined by its prefix:
|
||||
@ -182,7 +188,8 @@ is inferred from context in which the literal is used. Examples:
|
||||
// a = Integer or [n] where n >= width 10
|
||||
\end{verbatim}
|
||||
|
||||
\section{Bits}\label{bits}
|
||||
\hypertarget{bits}{%
|
||||
\section{Bits}\label{bits}}
|
||||
|
||||
The type \texttt{Bit} has two inhabitants: \texttt{True} and
|
||||
\texttt{False}. These values may be combined using various logical
|
||||
@ -213,7 +220,8 @@ Operator & Associativity & Description\tabularnewline
|
||||
\bottomrule
|
||||
\end{longtable}
|
||||
|
||||
\section{Multi-way Conditionals}\label{multi-way-conditionals}
|
||||
\hypertarget{multi-way-conditionals}{%
|
||||
\section{Multi-way Conditionals}\label{multi-way-conditionals}}
|
||||
|
||||
The \texttt{if\ ...\ then\ ...\ else} construct can be used with
|
||||
multiple branches. For example:
|
||||
@ -227,7 +235,8 @@ x = if y % 2 == 0 then 1
|
||||
else 7
|
||||
\end{verbatim}
|
||||
|
||||
\section{Tuples and Records}\label{tuples-and-records}
|
||||
\hypertarget{tuples-and-records}{%
|
||||
\section{Tuples and Records}\label{tuples-and-records}}
|
||||
|
||||
Tuples and records are used for packaging multiple values together.
|
||||
Tuples are enclosed in parentheses, while records are enclosed in curly
|
||||
@ -297,7 +306,8 @@ f p = x + y where
|
||||
(x, y) = p
|
||||
\end{verbatim}
|
||||
|
||||
\section{Sequences}\label{sequences}
|
||||
\hypertarget{sequences}{%
|
||||
\section{Sequences}\label{sequences}}
|
||||
|
||||
A sequence is a fixed-length collection of elements of the same type.
|
||||
The type of a finite sequence of length \texttt{n}, with elements of
|
||||
@ -310,10 +320,8 @@ with elements of type \texttt{a} has type \texttt{{[}inf{]}\ a}, and
|
||||
\begin{verbatim}
|
||||
[e1,e2,e3] // A sequence with three elements
|
||||
|
||||
[t .. ] // Sequence enumerations
|
||||
[t1, t2 .. ] // Step by t2 - t1
|
||||
[t1 .. t3 ]
|
||||
[t1, t2 .. t3 ]
|
||||
[t1 .. t3 ] // Sequence enumerations
|
||||
[t1, t2 .. t3 ] // Step by t2 - t1
|
||||
[e1 ... ] // Infinite sequence starting at e1
|
||||
[e1, e2 ... ] // Infinite sequence stepping by e2-e1
|
||||
|
||||
@ -321,9 +329,9 @@ with elements of type \texttt{a} has type \texttt{{[}inf{]}\ a}, and
|
||||
| p21 <- e21, p22 <- e22 ]
|
||||
\end{verbatim}
|
||||
|
||||
Note: the bounds in finite unbounded (those with ..) sequences are type
|
||||
expressions, while the bounds in bounded-finite and infinite sequences
|
||||
are value expressions.
|
||||
Note: the bounds in finite sequences (those with \texttt{..}) are type
|
||||
expressions, while the bounds in infinite sequences are value
|
||||
expressions.
|
||||
|
||||
\begin{longtable}[]{@{}ll@{}}
|
||||
\caption{Sequence operations.}\tabularnewline
|
||||
@ -360,14 +368,16 @@ There are also lifted pointwise operations.
|
||||
p1 # p2 // Split sequence pattern
|
||||
\end{verbatim}
|
||||
|
||||
\section{Functions}\label{functions}
|
||||
\hypertarget{functions}{%
|
||||
\section{Functions}\label{functions}}
|
||||
|
||||
\begin{verbatim}
|
||||
\p1 p2 -> e // Lambda expression
|
||||
f p1 p2 = e // Function definition
|
||||
\end{verbatim}
|
||||
|
||||
\section{Local Declarations}\label{local-declarations}
|
||||
\hypertarget{local-declarations}{%
|
||||
\section{Local Declarations}\label{local-declarations}}
|
||||
|
||||
\begin{verbatim}
|
||||
e where ds
|
||||
@ -377,7 +387,9 @@ Note that by default, any local declarations without type signatures are
|
||||
monomorphized. If you need a local declaration to be polymorphic, use an
|
||||
explicit type signature.
|
||||
|
||||
\section{Explicit Type Instantiation}\label{explicit-type-instantiation}
|
||||
\hypertarget{explicit-type-instantiation}{%
|
||||
\section{Explicit Type
|
||||
Instantiation}\label{explicit-type-instantiation}}
|
||||
|
||||
If \texttt{f} is a polymorphic value with type:
|
||||
|
||||
@ -392,8 +404,9 @@ you can evaluate \texttt{f}, passing it a type parameter:
|
||||
f `{ tyParam = 13 }
|
||||
\end{verbatim}
|
||||
|
||||
\hypertarget{demoting-numeric-types-to-values}{%
|
||||
\section{Demoting Numeric Types to
|
||||
Values}\label{demoting-numeric-types-to-values}
|
||||
Values}\label{demoting-numeric-types-to-values}}
|
||||
|
||||
The value corresponding to a numeric type may be accessed using the
|
||||
following notation:
|
||||
@ -410,7 +423,8 @@ accommodate the value of the type:
|
||||
`t : {n} (fin n, n >= width t) => [n]
|
||||
\end{verbatim}
|
||||
|
||||
\section{Explicit Type Annotations}\label{explicit-type-annotations}
|
||||
\hypertarget{explicit-type-annotations}{%
|
||||
\section{Explicit Type Annotations}\label{explicit-type-annotations}}
|
||||
|
||||
Explicit type annotations may be added on expressions, patterns, and in
|
||||
argument definitions.
|
||||
@ -423,19 +437,22 @@ p : t
|
||||
f (x : t) = ...
|
||||
\end{verbatim}
|
||||
|
||||
\section{Type Signatures}\label{type-signatures}
|
||||
\hypertarget{type-signatures}{%
|
||||
\section{Type Signatures}\label{type-signatures}}
|
||||
|
||||
\begin{verbatim}
|
||||
f,g : {a,b} (fin a) => [a] b
|
||||
\end{verbatim}
|
||||
|
||||
\section{Type Synonym Declarations}\label{type-synonym-declarations}
|
||||
\hypertarget{type-synonym-declarations}{%
|
||||
\section{Type Synonym Declarations}\label{type-synonym-declarations}}
|
||||
|
||||
\begin{verbatim}
|
||||
type T a b = [a] b
|
||||
\end{verbatim}
|
||||
|
||||
\section{Modules}\label{modules}
|
||||
\hypertarget{modules}{%
|
||||
\section{Modules}\label{modules}}
|
||||
|
||||
A \textbf{\emph{module}} is used to group some related definitions.
|
||||
|
||||
@ -448,7 +465,8 @@ f : [8]
|
||||
f = 10
|
||||
\end{verbatim}
|
||||
|
||||
\section{Hierarchical Module Names}\label{hierarchical-module-names}
|
||||
\hypertarget{hierarchical-module-names}{%
|
||||
\section{Hierarchical Module Names}\label{hierarchical-module-names}}
|
||||
|
||||
Module may have either simple or \textbf{\emph{hierarchical}} names.
|
||||
Hierarchical names are constructed by gluing together ordinary
|
||||
@ -467,7 +485,8 @@ when searching for module \texttt{Hash::SHA256}, Cryptol will look for a
|
||||
file named \texttt{SHA256.cry} in a directory called \texttt{Hash},
|
||||
contained in one of the directories specified by \texttt{CRYPTOLPATH}.
|
||||
|
||||
\section{Module Imports}\label{module-imports}
|
||||
\hypertarget{module-imports}{%
|
||||
\section{Module Imports}\label{module-imports}}
|
||||
|
||||
To use the definitions from one module in another module, we use
|
||||
\texttt{import} declarations:
|
||||
@ -488,7 +507,8 @@ import M // import all definitions from `M`
|
||||
g = f // `f` was imported from `M`
|
||||
\end{verbatim}
|
||||
|
||||
\section{Import Lists}\label{import-lists}
|
||||
\hypertarget{import-lists}{%
|
||||
\section{Import Lists}\label{import-lists}}
|
||||
|
||||
Sometimes, we may want to import only some of the definitions from a
|
||||
module. To do so, we use an import declaration with an
|
||||
@ -512,7 +532,8 @@ Using explicit import lists helps reduce name collisions. It also tends
|
||||
to make code easier to understand, because it makes it easy to see the
|
||||
source of definitions.
|
||||
|
||||
\section{Hiding Imports}\label{hiding-imports}
|
||||
\hypertarget{hiding-imports}{%
|
||||
\section{Hiding Imports}\label{hiding-imports}}
|
||||
|
||||
Sometimes a module may provide many definitions, and we want to use most
|
||||
of them but with a few exceptions (e.g., because those would result to a
|
||||
@ -535,7 +556,8 @@ import M hiding (h) // Import everything but `h`
|
||||
x = f + g
|
||||
\end{verbatim}
|
||||
|
||||
\section{Qualified Module Imports}\label{qualified-module-imports}
|
||||
\hypertarget{qualified-module-imports}{%
|
||||
\section{Qualified Module Imports}\label{qualified-module-imports}}
|
||||
|
||||
Another way to avoid name collisions is by using a
|
||||
\textbf{\emph{qualified}} import.
|
||||
@ -578,7 +600,8 @@ Such declarations will introduces all definitions from \texttt{A} and
|
||||
\texttt{X} but to use them, you would have to qualify using the prefix
|
||||
\texttt{B:::}.
|
||||
|
||||
\section{Private Blocks}\label{private-blocks}
|
||||
\hypertarget{private-blocks}{%
|
||||
\section{Private Blocks}\label{private-blocks}}
|
||||
|
||||
In some cases, definitions in a module might use helper functions that
|
||||
are not intended to be used outside the module. It is good practice to
|
||||
@ -619,7 +642,8 @@ private
|
||||
helper2 = 3
|
||||
\end{verbatim}
|
||||
|
||||
\section{Parameterized Modules}\label{parameterized-modules}
|
||||
\hypertarget{parameterized-modules}{%
|
||||
\section{Parameterized Modules}\label{parameterized-modules}}
|
||||
|
||||
\begin{verbatim}
|
||||
module M where
|
||||
@ -637,7 +661,9 @@ f : [n]
|
||||
f = 1 + x
|
||||
\end{verbatim}
|
||||
|
||||
\section{Named Module Instantiations}\label{named-module-instantiations}
|
||||
\hypertarget{named-module-instantiations}{%
|
||||
\section{Named Module
|
||||
Instantiations}\label{named-module-instantiations}}
|
||||
|
||||
One way to use a parameterized module is through a named instantiation:
|
||||
|
||||
@ -674,8 +700,9 @@ Note that the only purpose of the body of \texttt{N} (the declarations
|
||||
after the \texttt{where} keyword) is to define the parameters for
|
||||
\texttt{M}.
|
||||
|
||||
\hypertarget{parameterized-instantiations}{%
|
||||
\section{Parameterized
|
||||
Instantiations}\label{parameterized-instantiations}
|
||||
Instantiations}\label{parameterized-instantiations}}
|
||||
|
||||
It is possible for a module instantiations to be itself parameterized.
|
||||
This could be useful if we need to define some of a module's parameters
|
||||
@ -710,8 +737,9 @@ In this case \texttt{N} has a single parameter \texttt{x}. The result of
|
||||
instantiating \texttt{N} would result in instantiating \texttt{M} using
|
||||
the value of \texttt{x} and \texttt{12} for the value of \texttt{y}.
|
||||
|
||||
\hypertarget{importing-parameterized-modules}{%
|
||||
\section{Importing Parameterized
|
||||
Modules}\label{importing-parameterized-modules}
|
||||
Modules}\label{importing-parameterized-modules}}
|
||||
|
||||
It is also possible to import a parameterized module without using a
|
||||
module instantiation:
|
||||
|
@ -282,19 +282,17 @@ an infinite stream of bits.
|
||||
|
||||
[e1,e2,e3] // A sequence with three elements
|
||||
|
||||
[t .. ] // Sequence enumerations
|
||||
[t1, t2 .. ] // Step by t2 - t1
|
||||
[t1 .. t3 ]
|
||||
[t1, t2 .. t3 ]
|
||||
[t1 .. t3 ] // Sequence enumerations
|
||||
[t1, t2 .. t3 ] // Step by t2 - t1
|
||||
[e1 ... ] // Infinite sequence starting at e1
|
||||
[e1, e2 ... ] // Infinite sequence stepping by e2-e1
|
||||
|
||||
[ e | p11 <- e11, p12 <- e12 // Sequence comprehensions
|
||||
| p21 <- e21, p22 <- e22 ]
|
||||
|
||||
Note: the bounds in finite unbounded (those with ..) sequences are
|
||||
type expressions, while the bounds in bounded-finite and infinite
|
||||
sequences are value expressions.
|
||||
Note: the bounds in finite sequences (those with `..`) are type
|
||||
expressions, while the bounds in infinite sequences are value
|
||||
expressions.
|
||||
|
||||
Operator Description
|
||||
--------------------------- -----------
|
||||
|
Loading…
Reference in New Issue
Block a user