Merge branch 'doc-failwith' into 'dev'
Documentation improvements See merge request ligolang/ligo!666
This commit is contained in:
commit
c6ad617524
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: loops
|
id: loops
|
||||||
title: Loops
|
title: Iteration
|
||||||
---
|
---
|
||||||
|
|
||||||
import Syntax from '@theme/Syntax';
|
import Syntax from '@theme/Syntax';
|
||||||
@ -110,6 +110,7 @@ let gcd = ((x,y) : (nat, nat)) : nat => {
|
|||||||
|
|
||||||
</Syntax>
|
</Syntax>
|
||||||
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
## Bounded Loops
|
## Bounded Loops
|
||||||
|
|
||||||
@ -212,3 +213,5 @@ gitlab-pages/docs/language-basics/src/loops/collection.ligo sum_map
|
|||||||
'map ["1"->1; "2"->2; "3"->3]'
|
'map ["1"->1; "2"->2; "3"->3]'
|
||||||
# Outputs: ( "123", 6 )
|
# Outputs: ( "123", 6 )
|
||||||
```
|
```
|
||||||
|
|
||||||
|
</Syntax>
|
@ -13,55 +13,9 @@ Lazily means that storage is read or written per key on demand. Therefore
|
|||||||
there are no `map`, `fold`, and `iter` operations as in
|
there are no `map`, `fold`, and `iter` operations as in
|
||||||
[Map](./map-reference).
|
[Map](./map-reference).
|
||||||
|
|
||||||
The gast costs of big maps are higher than standard maps as data is lazily
|
The gas costs of big maps are higher than standard maps as data is lazily
|
||||||
deserialized.
|
deserialized.
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
|
||||||
type big_map ('key, 'value)
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="cameligo">
|
|
||||||
type ('key, 'value) big_map
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="reasonligo">
|
|
||||||
type big_map ('key, 'value)
|
|
||||||
</SyntaxTitle>
|
|
||||||
|
|
||||||
<Syntax syntax="pascaligo">
|
|
||||||
|
|
||||||
The type of a big map from values of type `key` to
|
|
||||||
values of type `value` is `big_map (key, value)`.
|
|
||||||
|
|
||||||
```pascaligo group=big_map
|
|
||||||
type move is int * int
|
|
||||||
type register is big_map (address, move)
|
|
||||||
```
|
|
||||||
|
|
||||||
</Syntax>
|
|
||||||
<Syntax syntax="cameligo">
|
|
||||||
|
|
||||||
The type of a big map from values of type `key` to values
|
|
||||||
of type `value` is `(key, value) big_map`.
|
|
||||||
|
|
||||||
```cameligo group=big_map
|
|
||||||
type move = int * int
|
|
||||||
type register = (address, move) big_map
|
|
||||||
```
|
|
||||||
|
|
||||||
</Syntax>
|
|
||||||
<Syntax syntax="reasonligo">
|
|
||||||
|
|
||||||
The type of a big map from values of type `key` to
|
|
||||||
values of type `value` is `big_map(key, value)`.
|
|
||||||
|
|
||||||
```reasonligo group=big_map
|
|
||||||
type move = (int, int);
|
|
||||||
type register = big_map(address, move);
|
|
||||||
```
|
|
||||||
|
|
||||||
</Syntax>
|
|
||||||
|
|
||||||
Be aware that a `big_map` cannot appear inside another `big_map`.
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
<SyntaxTitle syntax="pascaligo">
|
||||||
function empty : big_map ('key, 'value)
|
function empty : big_map ('key, 'value)
|
||||||
</SyntaxTitle>
|
</SyntaxTitle>
|
||||||
@ -77,6 +31,9 @@ Create an empty big_map.
|
|||||||
<Syntax syntax="pascaligo">
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=big_map
|
```pascaligo group=big_map
|
||||||
|
type move is int * int
|
||||||
|
type register is big_map (address, move)
|
||||||
|
|
||||||
const empty : register = Big_map.empty
|
const empty : register = Big_map.empty
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -90,6 +47,9 @@ const empty_alternative : register = big_map []
|
|||||||
<Syntax syntax="cameligo">
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=big_map
|
```cameligo group=big_map
|
||||||
|
type move = int * int
|
||||||
|
type register = (address, move) big_map
|
||||||
|
|
||||||
let empty : register = Big_map.empty
|
let empty : register = Big_map.empty
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -97,6 +57,9 @@ let empty : register = Big_map.empty
|
|||||||
<Syntax syntax="reasonligo">
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=big_map
|
```reasonligo group=big_map
|
||||||
|
type move = (int, int);
|
||||||
|
type register = big_map(address, move);
|
||||||
|
|
||||||
let empty: register = Big_map.empty
|
let empty: register = Big_map.empty
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -8,16 +8,6 @@ hide_table_of_contents: true
|
|||||||
import Syntax from '@theme/Syntax';
|
import Syntax from '@theme/Syntax';
|
||||||
import SyntaxTitle from '@theme/SyntaxTitle';
|
import SyntaxTitle from '@theme/SyntaxTitle';
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
|
||||||
type bytes
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="cameligo">
|
|
||||||
type bytes
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="reasonligo">
|
|
||||||
type bytes
|
|
||||||
</SyntaxTitle>
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
<SyntaxTitle syntax="pascaligo">
|
||||||
function concat : bytes -> bytes -> bytes
|
function concat : bytes -> bytes -> bytes
|
||||||
</SyntaxTitle>
|
</SyntaxTitle>
|
||||||
|
@ -8,42 +8,6 @@ hide_table_of_contents: true
|
|||||||
import Syntax from '@theme/Syntax';
|
import Syntax from '@theme/Syntax';
|
||||||
import SyntaxTitle from '@theme/SyntaxTitle';
|
import SyntaxTitle from '@theme/SyntaxTitle';
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
|
||||||
type key
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="cameligo">
|
|
||||||
type key
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="reasonligo">
|
|
||||||
type key
|
|
||||||
</SyntaxTitle>
|
|
||||||
|
|
||||||
A public cryptographic key.
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
|
||||||
type key_hash
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="cameligo">
|
|
||||||
type key_hash
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="reasonligo">
|
|
||||||
type key_hash
|
|
||||||
</SyntaxTitle>
|
|
||||||
|
|
||||||
The hash of a public cryptographic key.
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
|
||||||
type signature
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="cameligo">
|
|
||||||
type signature
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="reasonligo">
|
|
||||||
type signature
|
|
||||||
</SyntaxTitle>
|
|
||||||
|
|
||||||
A cryptographic signature.
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
<SyntaxTitle syntax="pascaligo">
|
||||||
function blake2b : bytes -> bytes
|
function blake2b : bytes -> bytes
|
||||||
</SyntaxTitle>
|
</SyntaxTitle>
|
||||||
|
@ -8,80 +8,6 @@ hide_table_of_contents: true
|
|||||||
import Syntax from '@theme/Syntax';
|
import Syntax from '@theme/Syntax';
|
||||||
import SyntaxTitle from '@theme/SyntaxTitle';
|
import SyntaxTitle from '@theme/SyntaxTitle';
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
|
||||||
type timestamp
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="cameligo">
|
|
||||||
type timestamp
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="reasonligo">
|
|
||||||
type timestamp
|
|
||||||
</SyntaxTitle>
|
|
||||||
|
|
||||||
A date in the real world.
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
|
||||||
type tez
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="cameligo">
|
|
||||||
type tez
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="reasonligo">
|
|
||||||
type tez
|
|
||||||
</SyntaxTitle>
|
|
||||||
|
|
||||||
A specific type for tokens.
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
|
||||||
type address
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="cameligo">
|
|
||||||
type address
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="reasonligo">
|
|
||||||
type address
|
|
||||||
</SyntaxTitle>
|
|
||||||
|
|
||||||
An untyped address which can refer to a smart contract or account.
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
|
||||||
type contract('parameter)
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="cameligo">
|
|
||||||
type 'parameter contract
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="reasonligo">
|
|
||||||
type contract('parameter)
|
|
||||||
</SyntaxTitle>
|
|
||||||
|
|
||||||
A typed contract.
|
|
||||||
|
|
||||||
Use `unit` as `parameter` to indicate an implicit account.
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
|
||||||
type operation
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="cameligo">
|
|
||||||
type operation
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="reasonligo">
|
|
||||||
type operation
|
|
||||||
</SyntaxTitle>
|
|
||||||
|
|
||||||
An operation emitted by the contract
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
|
||||||
type chain_id
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="cameligo">
|
|
||||||
type chain_id
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="reasonligo">
|
|
||||||
type chain_id
|
|
||||||
</SyntaxTitle>
|
|
||||||
|
|
||||||
The identifier of a chain, used to indicate test or main chains.
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
<SyntaxTitle syntax="pascaligo">
|
||||||
function balance : tez
|
function balance : tez
|
||||||
</SyntaxTitle>
|
</SyntaxTitle>
|
||||||
@ -94,8 +20,6 @@ let balance: tez
|
|||||||
|
|
||||||
Get the balance for the contract.
|
Get the balance for the contract.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<Syntax syntax="pascaligo">
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo
|
```pascaligo
|
||||||
@ -598,53 +522,17 @@ let main = (p : unit) : address => Tezos.source;
|
|||||||
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
<SyntaxTitle syntax="pascaligo">
|
||||||
function failwith : string -> unit
|
function failwith : 'a -> unit
|
||||||
</SyntaxTitle>
|
</SyntaxTitle>
|
||||||
<SyntaxTitle syntax="cameligo">
|
<SyntaxTitle syntax="cameligo">
|
||||||
function failwith : string -> unit
|
function failwith : 'a -> unit
|
||||||
</SyntaxTitle>
|
</SyntaxTitle>
|
||||||
<SyntaxTitle syntax="reasonligo">
|
<SyntaxTitle syntax="reasonligo">
|
||||||
function failwith : string -> unit
|
function failwith: 'a -> unit
|
||||||
</SyntaxTitle>
|
</SyntaxTitle>
|
||||||
|
|
||||||
Cause the contract to fail with an error message.
|
[See `failwith`](toplevel.md#failwith)
|
||||||
|
|
||||||
> ⚠ Using this currently requires in general a type annotation on the
|
|
||||||
> `failwith` call.
|
|
||||||
|
|
||||||
<Syntax syntax="cameligo">
|
|
||||||
Note that `Current.failwith` is deprecated. Use `Tezos.failwith` or `failwith` instead.
|
|
||||||
</Syntax>
|
|
||||||
<Syntax syntax="reasonligo">
|
|
||||||
Note that `Current.failwith` is deprecated. Use `Tezos.failwith` or `failwith` instead.
|
|
||||||
</Syntax>
|
|
||||||
|
|
||||||
<Syntax syntax="pascaligo">
|
|
||||||
|
|
||||||
```pascaligo
|
|
||||||
function main (const p : int; const s : unit) : list (operation) * unit is
|
|
||||||
block {
|
|
||||||
if p > 10 then failwith ("Failure.") else skip
|
|
||||||
}
|
|
||||||
with ((nil : list (operation)), s)
|
|
||||||
```
|
|
||||||
|
|
||||||
</Syntax>
|
|
||||||
<Syntax syntax="cameligo">
|
|
||||||
|
|
||||||
```cameligo
|
|
||||||
let main (p,s : int * unit) = if p > 10 then failwith "Failure."
|
|
||||||
```
|
|
||||||
|
|
||||||
</Syntax>
|
|
||||||
<Syntax syntax="reasonligo">
|
|
||||||
|
|
||||||
```reasonligo
|
|
||||||
let main = ((p,s) : (int, unit)) =>
|
|
||||||
if (p > 10) { failwith ("Failure."); };
|
|
||||||
```
|
|
||||||
|
|
||||||
</Syntax>
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
<SyntaxTitle syntax="pascaligo">
|
||||||
function chain_id : chain_id
|
function chain_id : chain_id
|
||||||
|
@ -8,18 +8,6 @@ hide_table_of_contents: true
|
|||||||
import Syntax from '@theme/Syntax';
|
import Syntax from '@theme/Syntax';
|
||||||
import SyntaxTitle from '@theme/SyntaxTitle';
|
import SyntaxTitle from '@theme/SyntaxTitle';
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
|
||||||
type list ('t)
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="cameligo">
|
|
||||||
type 't list
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="reasonligo">
|
|
||||||
type list('t)
|
|
||||||
</SyntaxTitle>
|
|
||||||
|
|
||||||
A sequence of elements of the same type.
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
<SyntaxTitle syntax="pascaligo">
|
||||||
function length : nat
|
function length : nat
|
||||||
</SyntaxTitle>
|
</SyntaxTitle>
|
||||||
|
@ -8,50 +8,6 @@ hide_table_of_contents: true
|
|||||||
import Syntax from '@theme/Syntax';
|
import Syntax from '@theme/Syntax';
|
||||||
import SyntaxTitle from '@theme/SyntaxTitle';
|
import SyntaxTitle from '@theme/SyntaxTitle';
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
|
||||||
type map ('key, 'value)
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="cameligo">
|
|
||||||
type ('key, 'value) map
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="reasonligo">
|
|
||||||
type map ('key, 'value)
|
|
||||||
</SyntaxTitle>
|
|
||||||
|
|
||||||
<Syntax syntax="pascaligo">
|
|
||||||
|
|
||||||
The type of a map from values of type `key` to
|
|
||||||
values of type `value` is `map (key, value)`.
|
|
||||||
|
|
||||||
```pascaligo group=maps
|
|
||||||
type move is int * int
|
|
||||||
type register is map (address, move)
|
|
||||||
```
|
|
||||||
|
|
||||||
</Syntax>
|
|
||||||
<Syntax syntax="cameligo">
|
|
||||||
|
|
||||||
The type of a map from values of type `key` to values
|
|
||||||
of type `value` is `(key, value) map`.
|
|
||||||
|
|
||||||
```cameligo group=maps
|
|
||||||
type move = int * int
|
|
||||||
type register = (address, move) map
|
|
||||||
```
|
|
||||||
|
|
||||||
</Syntax>
|
|
||||||
<Syntax syntax="reasonligo">
|
|
||||||
|
|
||||||
The type of a map from values of type `key` to
|
|
||||||
values of type `value` is `map (key, value)`.
|
|
||||||
|
|
||||||
```reasonligo group=maps
|
|
||||||
type move = (int, int);
|
|
||||||
type register = map (address, move);
|
|
||||||
```
|
|
||||||
|
|
||||||
</Syntax>
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
<SyntaxTitle syntax="pascaligo">
|
||||||
function empty : map ('key, 'value)
|
function empty : map ('key, 'value)
|
||||||
</SyntaxTitle>
|
</SyntaxTitle>
|
||||||
@ -67,6 +23,9 @@ Create an empty map.
|
|||||||
<Syntax syntax="pascaligo">
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
```pascaligo group=maps
|
```pascaligo group=maps
|
||||||
|
type move is int * int
|
||||||
|
type register is map (address, move)
|
||||||
|
|
||||||
const empty : register = Map.empty
|
const empty : register = Map.empty
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -80,6 +39,9 @@ const empty : register = map []
|
|||||||
<Syntax syntax="cameligo">
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
```cameligo group=maps
|
```cameligo group=maps
|
||||||
|
type move = int * int
|
||||||
|
type register = (address, move) map
|
||||||
|
|
||||||
let empty : register = Map.empty
|
let empty : register = Map.empty
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -87,6 +49,9 @@ let empty : register = Map.empty
|
|||||||
<Syntax syntax="reasonligo">
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
```reasonligo group=maps
|
```reasonligo group=maps
|
||||||
|
type move = (int, int);
|
||||||
|
type register = map (address, move);
|
||||||
|
|
||||||
let empty : register = Map.empty
|
let empty : register = Map.empty
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -10,16 +10,6 @@ import SyntaxTitle from '@theme/SyntaxTitle';
|
|||||||
|
|
||||||
Sets are unordered collections of unique values of the same type.
|
Sets are unordered collections of unique values of the same type.
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
|
||||||
type set ('value)
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="cameligo">
|
|
||||||
type 'value set
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="reasonligo">
|
|
||||||
type set('value)
|
|
||||||
</SyntaxTitle>
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
<SyntaxTitle syntax="pascaligo">
|
||||||
function empty : set('value)
|
function empty : set('value)
|
||||||
</SyntaxTitle>
|
</SyntaxTitle>
|
||||||
|
@ -8,18 +8,6 @@ hide_table_of_contents: true
|
|||||||
import Syntax from '@theme/Syntax';
|
import Syntax from '@theme/Syntax';
|
||||||
import SyntaxTitle from '@theme/SyntaxTitle';
|
import SyntaxTitle from '@theme/SyntaxTitle';
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
|
||||||
type string
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="cameligo">
|
|
||||||
type string
|
|
||||||
</SyntaxTitle>
|
|
||||||
<SyntaxTitle syntax="reasonligo">
|
|
||||||
type string
|
|
||||||
</SyntaxTitle>
|
|
||||||
|
|
||||||
A sequence of characters.
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
<SyntaxTitle syntax="pascaligo">
|
||||||
function length : string -> nat
|
function length : string -> nat
|
||||||
</SyntaxTitle>
|
</SyntaxTitle>
|
||||||
|
@ -8,7 +8,303 @@ hide_table_of_contents: true
|
|||||||
import Syntax from '@theme/Syntax';
|
import Syntax from '@theme/Syntax';
|
||||||
import SyntaxTitle from '@theme/SyntaxTitle';
|
import SyntaxTitle from '@theme/SyntaxTitle';
|
||||||
|
|
||||||
These functions are available without any needed prefix.
|
These types and functions are available without any needed prefix.
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type address
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type address
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type address
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
An untyped address which can refer to a smart contract or account.
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type big_map ('key, 'value)
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type ('key, 'value) big_map
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type big_map ('key, 'value)
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
|
The type of a big map from values of type `key` to
|
||||||
|
values of type `value` is `big_map (key, value)`.
|
||||||
|
|
||||||
|
```pascaligo group=big_map
|
||||||
|
type move is int * int
|
||||||
|
type register is big_map (address, move)
|
||||||
|
```
|
||||||
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
|
The type of a big map from values of type `key` to values
|
||||||
|
of type `value` is `(key, value) big_map`.
|
||||||
|
|
||||||
|
```cameligo group=big_map
|
||||||
|
type move = int * int
|
||||||
|
type register = (address, move) big_map
|
||||||
|
```
|
||||||
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
|
The type of a big map from values of type `key` to
|
||||||
|
values of type `value` is `big_map(key, value)`.
|
||||||
|
|
||||||
|
```reasonligo group=big_map
|
||||||
|
type move = (int, int);
|
||||||
|
type register = big_map(address, move);
|
||||||
|
```
|
||||||
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
Be aware that a `big_map` cannot appear inside another `big_map`.
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type bool
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type bool
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type bool
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type bytes
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type bytes
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type bytes
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type contract('parameter)
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type 'parameter contract
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type contract('parameter)
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
A typed contract.
|
||||||
|
|
||||||
|
Use `unit` as `parameter` to indicate an implicit account.
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type chain_id
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type chain_id
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type chain_id
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
The identifier of a chain, used to indicate test or main chains.
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type int
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type int
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type int
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
An integer.
|
||||||
|
|
||||||
|
The only size limit to integers is gas.
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type key
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type key
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type key
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
A public cryptographic key.
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type key_hash
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type key_hash
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type key_hash
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
The hash of a public cryptographic key.
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type list ('t)
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type 't list
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type list('t)
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
A sequence of elements of the same type.
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type map ('key, 'value)
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type ('key, 'value) map
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type map ('key, 'value)
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
|
The type of a map from values of type `key` to
|
||||||
|
values of type `value` is `map (key, value)`.
|
||||||
|
|
||||||
|
```pascaligo group=maps
|
||||||
|
type move is int * int
|
||||||
|
type register is map (address, move)
|
||||||
|
```
|
||||||
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
|
The type of a map from values of type `key` to values
|
||||||
|
of type `value` is `(key, value) map`.
|
||||||
|
|
||||||
|
```cameligo group=maps
|
||||||
|
type move = int * int
|
||||||
|
type register = (address, move) map
|
||||||
|
```
|
||||||
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
|
The type of a map from values of type `key` to
|
||||||
|
values of type `value` is `map (key, value)`.
|
||||||
|
|
||||||
|
```reasonligo group=maps
|
||||||
|
type move = (int, int);
|
||||||
|
type register = map (address, move);
|
||||||
|
```
|
||||||
|
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type nat
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type nat
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type nat
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
A natural number.
|
||||||
|
|
||||||
|
The only size limit to natural numbers is gas.
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type operation
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type operation
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type operation
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
An operation emitted by the contract
|
||||||
|
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type set ('value)
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type 'value set
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type set('value)
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type signature
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type signature
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type signature
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
A cryptographic signature.
|
||||||
|
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type string
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type string
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type string
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
A sequence of characters.
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type tez
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type tez
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type tez
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
A specific type for tokens.
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type timestamp
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type timestamp
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type timestamp
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
A date in the real world.
|
||||||
|
|
||||||
|
<SyntaxTitle syntax="pascaligo">
|
||||||
|
type unit
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="cameligo">
|
||||||
|
type unit
|
||||||
|
</SyntaxTitle>
|
||||||
|
<SyntaxTitle syntax="reasonligo">
|
||||||
|
type unit
|
||||||
|
</SyntaxTitle>
|
||||||
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
<SyntaxTitle syntax="pascaligo">
|
||||||
function is_nat: int -> option(nat)
|
function is_nat: int -> option(nat)
|
||||||
@ -60,20 +356,56 @@ let (): unit
|
|||||||
|
|
||||||
A helper to create a unit.
|
A helper to create a unit.
|
||||||
|
|
||||||
|
<a name="failwith"></a>
|
||||||
<SyntaxTitle syntax="pascaligo">
|
<SyntaxTitle syntax="pascaligo">
|
||||||
function failwith : string -> unit
|
function failwith : 'a -> unit
|
||||||
</SyntaxTitle>
|
</SyntaxTitle>
|
||||||
<SyntaxTitle syntax="cameligo">
|
<SyntaxTitle syntax="cameligo">
|
||||||
val failwith : string -> unit
|
val failwith : 'a -> unit
|
||||||
</SyntaxTitle>
|
</SyntaxTitle>
|
||||||
<SyntaxTitle syntax="reasonligo">
|
<SyntaxTitle syntax="reasonligo">
|
||||||
let failwith: string => unit
|
let failwith: 'a => unit
|
||||||
</SyntaxTitle>
|
</SyntaxTitle>
|
||||||
|
|
||||||
Cause the contract to fail with an error message.
|
Cause the contract to fail with an error message or integer. Other types are
|
||||||
|
not supported at the moment.
|
||||||
|
|
||||||
|
Using this currently requires in general a type annotation on the
|
||||||
|
`failwith` call.
|
||||||
|
|
||||||
|
<Syntax syntax="pascaligo">
|
||||||
|
|
||||||
|
```pascaligo
|
||||||
|
function main (const p : int; const s : unit) : list (operation) * unit is
|
||||||
|
block {
|
||||||
|
if p > 10 then failwith ("Failure.") else skip
|
||||||
|
}
|
||||||
|
with ((nil : list (operation)), s)
|
||||||
|
```
|
||||||
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
|
||||||
|
```cameligo
|
||||||
|
let main (p,s : int * unit) = if p > 10 then failwith "Failure."
|
||||||
|
```
|
||||||
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
|
||||||
|
```reasonligo
|
||||||
|
let main = ((p,s) : (int, unit)) =>
|
||||||
|
if (p > 10) { failwith ("Failure."); };
|
||||||
|
```
|
||||||
|
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="cameligo">
|
||||||
|
`Current.failwith` is deprecated. Use `Tezos.failwith` or `failwith` instead.
|
||||||
|
</Syntax>
|
||||||
|
<Syntax syntax="reasonligo">
|
||||||
|
`Current.failwith` is deprecated. Use `Tezos.failwith` or `failwith` instead.
|
||||||
|
</Syntax>
|
||||||
|
|
||||||
> ⚠ Using this currently requires in general a type annotation on the
|
|
||||||
> `failwith` call.
|
|
||||||
|
|
||||||
<SyntaxTitle syntax="pascaligo">
|
<SyntaxTitle syntax="pascaligo">
|
||||||
function assert : bool -> unit
|
function assert : bool -> unit
|
||||||
|
Loading…
Reference in New Issue
Block a user