diff --git a/gitlab-pages/docs/language-basics/loops.md b/gitlab-pages/docs/language-basics/loops.md index e6d26adea..981d45335 100644 --- a/gitlab-pages/docs/language-basics/loops.md +++ b/gitlab-pages/docs/language-basics/loops.md @@ -1,6 +1,6 @@ --- id: loops -title: Loops +title: Iteration --- import Syntax from '@theme/Syntax'; @@ -110,6 +110,7 @@ let gcd = ((x,y) : (nat, nat)) : nat => { + ## Bounded Loops @@ -212,3 +213,5 @@ gitlab-pages/docs/language-basics/src/loops/collection.ligo sum_map 'map ["1"->1; "2"->2; "3"->3]' # Outputs: ( "123", 6 ) ``` + + \ No newline at end of file diff --git a/gitlab-pages/docs/reference/big_map.md b/gitlab-pages/docs/reference/big_map.md index 104751667..529b87290 100644 --- a/gitlab-pages/docs/reference/big_map.md +++ b/gitlab-pages/docs/reference/big_map.md @@ -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 [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. - -type big_map ('key, 'value) - - -type ('key, 'value) big_map - - -type big_map ('key, 'value) - - - - -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) -``` - - - - -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 -``` - - - - -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); -``` - - - -Be aware that a `big_map` cannot appear inside another `big_map`. - function empty : big_map ('key, 'value) @@ -77,6 +31,9 @@ Create an empty big_map. ```pascaligo group=big_map +type move is int * int +type register is big_map (address, move) + const empty : register = Big_map.empty ``` @@ -90,6 +47,9 @@ const empty_alternative : register = big_map [] ```cameligo group=big_map +type move = int * int +type register = (address, move) big_map + let empty : register = Big_map.empty ``` @@ -97,6 +57,9 @@ let empty : register = Big_map.empty ```reasonligo group=big_map +type move = (int, int); +type register = big_map(address, move); + let empty: register = Big_map.empty ``` diff --git a/gitlab-pages/docs/reference/bytes.md b/gitlab-pages/docs/reference/bytes.md index 68e61d8cd..86326150c 100644 --- a/gitlab-pages/docs/reference/bytes.md +++ b/gitlab-pages/docs/reference/bytes.md @@ -8,16 +8,6 @@ hide_table_of_contents: true import Syntax from '@theme/Syntax'; import SyntaxTitle from '@theme/SyntaxTitle'; - -type bytes - - -type bytes - - -type bytes - - function concat : bytes -> bytes -> bytes diff --git a/gitlab-pages/docs/reference/crypto.md b/gitlab-pages/docs/reference/crypto.md index ba8d146fd..4d3b88dec 100644 --- a/gitlab-pages/docs/reference/crypto.md +++ b/gitlab-pages/docs/reference/crypto.md @@ -8,42 +8,6 @@ hide_table_of_contents: true import Syntax from '@theme/Syntax'; import SyntaxTitle from '@theme/SyntaxTitle'; - -type key - - -type key - - -type key - - -A public cryptographic key. - - -type key_hash - - -type key_hash - - -type key_hash - - -The hash of a public cryptographic key. - - -type signature - - -type signature - - -type signature - - -A cryptographic signature. - function blake2b : bytes -> bytes diff --git a/gitlab-pages/docs/reference/current.md b/gitlab-pages/docs/reference/current.md index 03e617edf..786bd56f4 100644 --- a/gitlab-pages/docs/reference/current.md +++ b/gitlab-pages/docs/reference/current.md @@ -8,80 +8,6 @@ hide_table_of_contents: true import Syntax from '@theme/Syntax'; import SyntaxTitle from '@theme/SyntaxTitle'; - -type timestamp - - -type timestamp - - -type timestamp - - -A date in the real world. - - -type tez - - -type tez - - -type tez - - -A specific type for tokens. - - -type address - - -type address - - -type address - - -An untyped address which can refer to a smart contract or account. - - -type contract('parameter) - - -type 'parameter contract - - -type contract('parameter) - - -A typed contract. - -Use `unit` as `parameter` to indicate an implicit account. - - -type operation - - -type operation - - -type operation - - -An operation emitted by the contract - - -type chain_id - - -type chain_id - - -type chain_id - - -The identifier of a chain, used to indicate test or main chains. - function balance : tez @@ -94,8 +20,6 @@ let balance: tez Get the balance for the contract. - - ```pascaligo @@ -598,53 +522,17 @@ let main = (p : unit) : address => Tezos.source; -function failwith : string -> unit +function failwith : 'a -> unit -function failwith : string -> unit +function failwith : 'a -> unit -function failwith : string -> unit +function failwith: 'a -> unit -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. - - -Note that `Current.failwith` is deprecated. Use `Tezos.failwith` or `failwith` instead. - - -Note that `Current.failwith` is deprecated. Use `Tezos.failwith` or `failwith` instead. - - - - -```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) -``` - - - - -```cameligo -let main (p,s : int * unit) = if p > 10 then failwith "Failure." -``` - - - - -```reasonligo -let main = ((p,s) : (int, unit)) => - if (p > 10) { failwith ("Failure."); }; -``` - - function chain_id : chain_id diff --git a/gitlab-pages/docs/reference/list.md b/gitlab-pages/docs/reference/list.md index e85e5b543..3ed7a60c9 100644 --- a/gitlab-pages/docs/reference/list.md +++ b/gitlab-pages/docs/reference/list.md @@ -8,18 +8,6 @@ hide_table_of_contents: true import Syntax from '@theme/Syntax'; import SyntaxTitle from '@theme/SyntaxTitle'; - -type list ('t) - - -type 't list - - -type list('t) - - -A sequence of elements of the same type. - function length : nat diff --git a/gitlab-pages/docs/reference/map.md b/gitlab-pages/docs/reference/map.md index bf26f6bcf..37d30f2e3 100644 --- a/gitlab-pages/docs/reference/map.md +++ b/gitlab-pages/docs/reference/map.md @@ -8,50 +8,6 @@ hide_table_of_contents: true import Syntax from '@theme/Syntax'; import SyntaxTitle from '@theme/SyntaxTitle'; - -type map ('key, 'value) - - -type ('key, 'value) map - - -type map ('key, 'value) - - - - -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) -``` - - - - -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 -``` - - - - -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); -``` - - - function empty : map ('key, 'value) @@ -67,6 +23,9 @@ Create an empty map. ```pascaligo group=maps +type move is int * int +type register is map (address, move) + const empty : register = Map.empty ``` @@ -80,6 +39,9 @@ const empty : register = map [] ```cameligo group=maps +type move = int * int +type register = (address, move) map + let empty : register = Map.empty ``` @@ -87,6 +49,9 @@ let empty : register = Map.empty ```reasonligo group=maps +type move = (int, int); +type register = map (address, move); + let empty : register = Map.empty ``` diff --git a/gitlab-pages/docs/reference/set.md b/gitlab-pages/docs/reference/set.md index 9478a2048..22c725d61 100644 --- a/gitlab-pages/docs/reference/set.md +++ b/gitlab-pages/docs/reference/set.md @@ -10,16 +10,6 @@ import SyntaxTitle from '@theme/SyntaxTitle'; Sets are unordered collections of unique values of the same type. - -type set ('value) - - -type 'value set - - -type set('value) - - function empty : set('value) diff --git a/gitlab-pages/docs/reference/string.md b/gitlab-pages/docs/reference/string.md index afe9ebaa3..8a1b8ae51 100644 --- a/gitlab-pages/docs/reference/string.md +++ b/gitlab-pages/docs/reference/string.md @@ -8,18 +8,6 @@ hide_table_of_contents: true import Syntax from '@theme/Syntax'; import SyntaxTitle from '@theme/SyntaxTitle'; - -type string - - -type string - - -type string - - -A sequence of characters. - function length : string -> nat diff --git a/gitlab-pages/docs/reference/toplevel.md b/gitlab-pages/docs/reference/toplevel.md index b1b4e7b3c..e82c43791 100644 --- a/gitlab-pages/docs/reference/toplevel.md +++ b/gitlab-pages/docs/reference/toplevel.md @@ -8,7 +8,303 @@ hide_table_of_contents: true import Syntax from '@theme/Syntax'; import SyntaxTitle from '@theme/SyntaxTitle'; -These functions are available without any needed prefix. +These types and functions are available without any needed prefix. + + +type address + + +type address + + +type address + + +An untyped address which can refer to a smart contract or account. + + +type big_map ('key, 'value) + + +type ('key, 'value) big_map + + +type big_map ('key, 'value) + + + + +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) +``` + + + + +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 +``` + + + + +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); +``` + + + +Be aware that a `big_map` cannot appear inside another `big_map`. + + +type bool + + +type bool + + +type bool + + + +type bytes + + +type bytes + + +type bytes + + + + +type contract('parameter) + + +type 'parameter contract + + +type contract('parameter) + + +A typed contract. + +Use `unit` as `parameter` to indicate an implicit account. + + +type chain_id + + +type chain_id + + +type chain_id + + +The identifier of a chain, used to indicate test or main chains. + + +type int + + +type int + + +type int + + +An integer. + +The only size limit to integers is gas. + + +type key + + +type key + + +type key + + +A public cryptographic key. + + +type key_hash + + +type key_hash + + +type key_hash + + +The hash of a public cryptographic key. + + +type list ('t) + + +type 't list + + +type list('t) + + +A sequence of elements of the same type. + + +type map ('key, 'value) + + +type ('key, 'value) map + + +type map ('key, 'value) + + + + +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) +``` + + + + +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 +``` + + + + +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); +``` + + + + +type nat + + +type nat + + +type nat + + +A natural number. + +The only size limit to natural numbers is gas. + + +type operation + + +type operation + + +type operation + + +An operation emitted by the contract + + + +type set ('value) + + +type 'value set + + +type set('value) + + + +type signature + + +type signature + + +type signature + + +A cryptographic signature. + + + +type string + + +type string + + +type string + + +A sequence of characters. + + +type tez + + +type tez + + +type tez + + +A specific type for tokens. + + +type timestamp + + +type timestamp + + +type timestamp + + +A date in the real world. + + +type unit + + +type unit + + +type unit + + function is_nat: int -> option(nat) @@ -60,20 +356,56 @@ let (): unit A helper to create a unit. + -function failwith : string -> unit +function failwith : 'a -> unit -val failwith : string -> unit +val failwith : 'a -> unit -let failwith: string => unit +let failwith: 'a => unit -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. + + + +```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) +``` + + + + +```cameligo +let main (p,s : int * unit) = if p > 10 then failwith "Failure." +``` + + + + +```reasonligo +let main = ((p,s) : (int, unit)) => + if (p > 10) { failwith ("Failure."); }; +``` + + + +`Current.failwith` is deprecated. Use `Tezos.failwith` or `failwith` instead. + + +`Current.failwith` is deprecated. Use `Tezos.failwith` or `failwith` instead. + -> ⚠ Using this currently requires in general a type annotation on the -> `failwith` call. function assert : bool -> unit