Compare commits

...

4 Commits

Author SHA1 Message Date
radrow 0320ac959b CHANGELOG update 2021-07-15 20:43:11 +02:00
radrow dcef89b486 Add Option.force_msg 2021-07-15 20:41:38 +02:00
Hans Svensson 4957d01e9e Merge pull request #327 from aeternity/fix_doc
Fix stdlib doc
2021-07-13 20:40:49 +02:00
Hans Svensson 9d76e6186a Fix stdlib doc 2021-07-13 20:01:54 +02:00
3 changed files with 21 additions and 4 deletions
+1
View File
@@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- `Option.force_msg`
### Changed
### Removed
+12 -2
View File
@@ -362,7 +362,7 @@ namespace Chain =
#### tx_hash
```
Auth.tx_hash : option(Chain.tx)
Auth.tx_hash : option(hash)
```
Gets the transaction hash during authentication.
@@ -1293,7 +1293,17 @@ Escapes `option` wrapping by providing default value for `None`.
Option.force(o : option('a)) : 'a
```
Forcefully escapes `option` wrapping assuming it is `Some`. Throws error on `None`.
Forcefully escapes the `option` wrapping assuming it is `Some`.
Aborts on `None`.
#### force_msg
```
Option.force_msg(o : option('a), err : string) : 'a
```
Forcefully escapes the `option` wrapping assuming it is `Some`.
Aborts with `err` error message on `None`.
#### contains
+6
View File
@@ -26,6 +26,12 @@ namespace Option =
None => abort("Forced None value")
Some(x) => x
/** Assume it is `Some` with custom error message
*/
function force_msg(o : option('a), err : string) : 'a = switch(o)
None => abort(err)
Some(x) => x
function contains(e : 'a, o : option('a)) = o == Some(e)
function on_elem(o : option('a), f : 'a => unit) : unit = match((), f, o)