☰
outcome
outcome
§(T type):switch outcome.T, error,monad outcome.T, outcome outcome.T is [Contains abstract features]
§(T
type
):
switch outcome.T, error,monad outcome.T, outcome outcome.T is
[Contains abstract features]
Functions
returns o if outcome is ok, otherwise return the outcome's own
error.
error.
collect the contents of this Sequence into an array
create an array backed version of this sequence in case this is not array
backed. This will ensure that operations like index[] or drop perform
in constant time.
returns Sequence.this if is_array_backed.
backed. This will ensure that operations like index[] or drop perform
in constant time.
returns Sequence.this if is_array_backed.
converts switch into a list of either a single element in case
switch.this.exists or `nil`otherwise
switch.this.exists or `nil`otherwise
convert this outcome to an option
if the outcome is an error, the option is empty
if the outcome is an error, the option is empty
convenience feature to work around type inference issues
NYI remove when type inference gets better
NYI remove when type inference gets better
converts outcome to a string
returns the result of T.as_string for a successful outcome, or
"--$e--" for e error.
returns the result of T.as_string for a successful outcome, or
"--$e--" for e error.
create a string representation of this Sequence including all the string
representations of its contents, separated by 'sep'.
NOTE: In case this Sequence is not finite, this will attempt to create an
infinitely long string resulting in failure due to resource exchaustion.
representations of its contents, separated by 'sep'.
NOTE: In case this Sequence is not finite, this will attempt to create an
infinitely long string resulting in failure due to resource exchaustion.
create a string representation of this Sequence including all the string
representations of its contents, separated by ", " and enclosed in '['
and ']'.
NOTE: In case this Sequence is not finite, this will attempt to create an
infinitely long string resulting in failure due to resource exchaustion.
representations of its contents, separated by ", " and enclosed in '['
and ']'.
NOTE: In case this Sequence is not finite, this will attempt to create an
infinitely long string resulting in failure due to resource exchaustion.
call 'as_string' on the elements
the arithmetic mean of the sequence
https://en.wikipedia.org/wiki/Arithmetic_mean
https://en.wikipedia.org/wiki/Arithmetic_mean
create a new list that contains the first elements of
this Sequence for which 'f e' is false
this Sequence for which 'f e' is false
monadic operator
This enables a very idiomatic way of error handling: assume you are trying
to read 42 bytes from a file into a string. Let open be a feature that takes
a file name and returns an outcome of some abstract file descriptor, let read
be a feature that takes an abstract file descriptor and a number of bytes to
read and returns an outcome of a byte (u8) array. We want to read 42 bytes
from a file called "example.txt" into a string, and we wrap this into an outcome,
for handling the case that an error occurs when opening the file (i.e. it does
not exist) or when reading the file (i.e. example.txt is not actually a file but
a directory). Using match expressions, this is very cumbersome:
The monadic operator turns this into:
This enables a very idiomatic way of error handling: assume you are trying
to read 42 bytes from a file into a string. Let open be a feature that takes
a file name and returns an outcome of some abstract file descriptor, let read
be a feature that takes an abstract file descriptor and a number of bytes to
read and returns an outcome of a byte (u8) array. We want to read 42 bytes
from a file called "example.txt" into a string, and we wrap this into an outcome,
for handling the case that an error occurs when opening the file (i.e. it does
not exist) or when reading the file (i.e. example.txt is not actually a file but
a directory). Using match expressions, this is very cumbersome:
The monadic operator turns this into:
chop this Sequence into chunks of `chunk_size`.
the last chunk may be smaller than `chunk_size`.
the last chunk may be smaller than `chunk_size`.
§(U type, V type, b Sequence Sequence.combine.U, f Function Sequence.combine.V Sequence.T Sequence.combine.U):Any => Sequence Sequence.combine.V [Inherited from Sequence]
§(U
type
, V type
, b Sequence Sequence.combine.U, f Function Sequence.combine.V Sequence.T Sequence.combine.U):
Any =>
Sequence Sequence.combine.V [Inherited from Sequence]
create a new Sequence from the result of applying 'f' to the
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
elements all combinations of elements of this Sequence and
all elements of 'b' iterating of 'b' repeatedly as follows
Sequence.this[0] , b[0]
Sequence.this[0] , b[1]
Sequence.this[0] , b[2]
Sequence.this[0] , ...
Sequence.this[0] , b.last
Sequence.this[1] , b[0]
Sequence.this[1] , b[1]
Sequence.this[1] , ...
... , ...
Sequence.this.last, b.last
create a Sequence that consists of all the elements of this Sequence followed
by all the elements of s
by all the elements of s
count the number of elements in this Sequence. Note that this typically
runs forever if executed on an endless list
For lists that are not array backed, this might require time in O(count).
runs forever if executed on an endless list
For lists that are not array backed, this might require time in O(count).
get the number of non-overlapping matches of l within this
get the number of matches of l
create a list that repeats the current Sequence indefinitely. In case 'Sequence.this'
is empty, returns 'nil'
is empty, returns 'nil'
create a list that consists of the elements of this Sequence except the first
n elements
NOTE: this may have performance in O(n) unless it is backed by an immutable array.
n elements
NOTE: this may have performance in O(n) unless it is backed by an immutable array.
Lazily drop the first elements of this Sequence for which predicate 'p' holds.
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
error of an outcome that is known to contain an error
This can only be called in cases where it is known for sure that this
outcome is an error. A runtime error will be created otherwise.
This can only be called in cases where it is known for sure that this
outcome is an error. A runtime error will be created otherwise.
the euclidean norm of this sequence
i.e. the square of the sum of squares of this sequence
i.e. the square of the sum of squares of this sequence
filter elements using predicate f
values for which f is false are dropped
values for which f is false are dropped
get the index of pattern within this Sequence or nil if it does not exist
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
uses the Knuth-Morris-Pratt algorithm
port of racket code from this paper:
https://www.cambridge.org/core/services/aop-cambridge-core/content/view/8EFA77D663D585B68630E372BCE1EBA4/S0956796824000017a.pdf/knuth-morris-pratt-illustrated.pdf
worst-case performance: O( seq_length ) + O( pattern_length )
worst-case space complexity: O( pattern_length )
is this sequence known to be finite? For infinite sequences, features like
count diverge.
count diverge.
get the first element of this Sequence
Sequence must not be empty, causes precondition failure if debug is enabled.
Sequence must not be empty, causes precondition failure if debug is enabled.
get the first element of this Sequence or default if sequence is empty
§(B type, f Unary (Sequence Sequence.flat_map.B) Sequence.T):Any => Sequence Sequence.flat_map.B [Inherited from Sequence]
§(B
type
, f Unary (Sequence Sequence.flat_map.B) Sequence.T):
Any =>
Sequence Sequence.flat_map.B [Inherited from Sequence]
map each element of this Sequence to Sequence
Then flatten the result by one level,
essentially combining all the sequences.
Then flatten the result by one level,
essentially combining all the sequences.
fold the elements of this Sequence using the given monoid.
e.g., to sum the elements of a Sequence of i32, use s.fold i32.sum
e.g., to sum the elements of a Sequence of i32, use s.fold i32.sum
fold the elements of this non-empty Sequence using the given function
e.g., to find the minimum of a Sequence of i32, use `s.fold1 (<=)`
e.g., to find the minimum of a Sequence of i32, use `s.fold1 (<=)`
fold the elements of this Sequence using the given function and initial
value.
In case this Sequence is empty, the result is `e`.
e.g., to find the product of a Sequence of i32, use `s.foldf (*) 1`
value.
In case this Sequence is empty, the result is `e`.
e.g., to find the product of a Sequence of i32, use `s.foldf (*) 1`
create a list and call 'for_each f' on it
apply 'f' to each element 'e' as long as 'f e'
unwraps a switch that is known to contain a value
this can only be called in cases where it is known for sure that this switch
is not nil. A runtime error will be created otherwise.
this can only be called in cases where it is known for sure that this switch
is not nil. A runtime error will be created otherwise.
§(K type, f Unary Sequence.group_by.K Sequence.T):Any => lock_free.map Sequence.group_by.K (list Sequence.T) [Inherited from Sequence]
§(K
type
, f Unary Sequence.group_by.K Sequence.T):
Any =>
lock_free.map Sequence.group_by.K (list Sequence.T) [Inherited from Sequence]
group the elements of this sequence by a key of type K
f determines the key of an element
f determines the key of an element
get a function that, given an index, returns the element at that index
the nth element in the sequence, must exist
determine the index of element x within this list. 0 if x is at the
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
head of the list, 1 if it comes directly after head, etc. nil if x is
not in the list.
adds the corresponding index to
every element in the sequence
every element in the sequence
adds an index to every element
in the sequence starting at start_idx
in the sequence starting at start_idx
consume all elements of this Sequence by f. This is an infix operator alias
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
for for_each.
Ex.: To print all the elements of a list, you can use
1..10 ! say
filter elements using predicate f, infix operator
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
synonym of filter.
NYI: What is better, 'infix |&' or 'infix &', or something else?
infix operand synonym for concat_sequences
monadic operator
§(B type, MB type, f Unary (monad.infix >>=~.MB) monad.A):Any => monad.infix >>=~.MB [Inherited from monad] [Abstract feature]
§(B
type
, MB type
, f Unary (monad.infix >>=~.MB) monad.A):
Any =>
monad.infix >>=~.MB [Inherited from monad]
[Abstract feature]
monadic operator to another monad
Apply f to elements of type A and wrap them in MB.
NYI: This is currently useless since a redefinition is not
allowed for features with generic arguments. Is there a way
we could allow this anyway?
Apply f to elements of type A and wrap them in MB.
NYI: This is currently useless since a redefinition is not
allowed for features with generic arguments. Is there a way
we could allow this anyway?
§(B type, f Unary (Sequence.infix |.B) Sequence.T):Any => Sequence (Sequence.infix |.B) [Inherited from Sequence]
§(B
type
, f Unary (Sequence.infix |.B) Sequence.T):
Any =>
Sequence (Sequence.infix |.B) [Inherited from Sequence]
map the Sequence to a new Sequence applying function f to all elements
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
This is an infix operator alias of map enabling piping code like
l := 1..10 | *10 | 300-
to obtain 290,280,270,...200
Note that map and therefore also this operator is lazy, so
_ := (1..10 | say)
will not print anything while
(1..10 | say).for_each _->unit
will print the elements since `for_each` is not lazy.
filter elements using predicate f, infix operator
synonym of filter.
synonym of filter.
check if predicate f holds for all elements
check if predicate f holds for at least one element
insert element v at position at
§(TA type, xf transducer (Sequence Sequence.into.TA) Sequence.into.TA Sequence.T):Any => list Sequence.into.TA [Inherited from Sequence]
§(TA
type
, xf transducer (Sequence Sequence.into.TA) Sequence.into.TA Sequence.T):
Any =>
list Sequence.into.TA [Inherited from Sequence]
apply transducer to sequence, returning a sequence of results
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
example usage:
human(age i32) is
ages := map (Sequence i32) human i32 (x -> x.age)
gt_ten := filter (Sequence i32) i32 (x -> x > 10)
xf := ages ∘ gt_ten
say ([human(4), human(12), human(30)].into xf) # [12,30]
is this Sequence known to be array backed? If so, this means that operations
like index[] are fast.
like index[] are fast.
check if argument is a valid index in this sequence.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
Note that this may have a performance in O(i) unless this
Sequence is_array_backed.
join operator
NYI: useless since redefinition currently not supported for
feature with generics.
NYI: useless since redefinition currently not supported for
feature with generics.
get the last element of this Sequence
Sequence must not be empty, causes precondition failure if debug is enabled.
This may take time in O(count), in particular, it may not terminate
for an infinite Sequence.
Sequence must not be empty, causes precondition failure if debug is enabled.
This may take time in O(count), in particular, it may not terminate
for an infinite Sequence.
get the last element of this Sequence or default if sequence is empty
§(B type, f Unary Sequence.map.B Sequence.T):Any => Sequence Sequence.map.B [Inherited from Sequence]
§(B
type
, f Unary Sequence.map.B Sequence.T):
Any =>
Sequence Sequence.map.B [Inherited from Sequence]
map the Sequence to a new Sequence applying function f to all elements
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
This performs a lazy mapping, f is called only when the elements
in the resulting list are accessed.
§(B type, f Function Sequence.map_pairs.B Sequence.T Sequence.T):Any => list Sequence.map_pairs.B [Inherited from Sequence]
§(B
type
, f Function Sequence.map_pairs.B Sequence.T Sequence.T):
Any =>
list Sequence.map_pairs.B [Inherited from Sequence]
Map this Sequence to f applied to neighboring pairs of values
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
in this Sequence.
In case this Sequence has less than two elements, the result will
be the empty list.
ex. to obtain a list of differences you, you may use `map_pairs (-)`:
[2,3,5,7,11,13,17,19,23,29].map_pairs a,b->b-a
results in `[1,2,2,4,2,4,2,4,6]`
the median of the sequence
https://en.wikipedia.org/wiki/Median
https://en.wikipedia.org/wiki/Median
the nth element in the sequence if it exists, wrapped in an option,
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
nil otherwise.
Complexity: if Sequence is array backed O(1) otherwise O(n)
returns o if outcome is not ok, otherwise return this outcome's value.
§(U type, b Sequence Sequence.pairs.U):Any => Sequence (tuple Sequence.T Sequence.pairs.U) [Inherited from Sequence]
§(U
type
, b Sequence Sequence.pairs.U):
Any =>
Sequence (tuple Sequence.T Sequence.pairs.U) [Inherited from Sequence]
create a new Sequence from tuples of all combinations of elements
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
of this Sequence and all elements of 'b' iterating of 'b' repeatedly
as follows
(Sequence.this[0] , b[0] )
(Sequence.this[0] , b[1] )
(Sequence.this[0] , b[2] )
(Sequence.this[0] , ... )
(Sequence.this[0] , b.last)
(Sequence.this[1] , b[0] )
(Sequence.this[1] , b[1] )
(Sequence.this[1] , ... )
(... , ... )
(Sequence.this.last, b.last)
calls `f` for element in the Sequence.
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
Unlike `for_each` this returns itself
allowing easier composition with
other Sequence features.
example:
[1,2,3,4,5]
.filter is_prime
.peek say
.drop_while <10
convenience prefix operator to create a string from a value.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
reduce this Sequence to R with an initial value init
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
and a reducing function f.
the reduction is finished once f yields abort or
if the end of the sequence is reached.
§(R type, init Sequence.reduce_or_error.R, f Function (choice Sequence.reduce_or_error.R (abort (outcome Sequence.reduce_or_error.R))) Sequence.reduce_or_error.R Sequence.T):Any => outcome Sequence.reduce_or_error.R [Inherited from Sequence]
§(R
type
, init Sequence.reduce_or_error.R, f Function (choice Sequence.reduce_or_error.R (abort (outcome Sequence.reduce_or_error.R))) Sequence.reduce_or_error.R Sequence.T):
Any =>
outcome Sequence.reduce_or_error.R [Inherited from Sequence]
reduce this Sequence to `outcome R`
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
with an initial value `init` and a reducing function `f`.
the reduction is finished once `f` yields `abort` or
if the end of the sequence is reached.
§(old Sequence Sequence.T, new Sequence Sequence.T):Any => list Sequence.T [Inherited from Sequence]
§(old Sequence Sequence.T, new Sequence Sequence.T)
:
Any =>
list Sequence.T [Inherited from Sequence]
replace all occurrences of old by new
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64):Any => list Sequence.T [Inherited from Sequence]
§(old Sequence Sequence.T, new Sequence Sequence.T, n u64)
:
Any =>
list Sequence.T [Inherited from Sequence]
replace the first n occurrences of old by new
reverse the order of the elements in this Sequence
map this Sequence to a list that contains the result of folding
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
all prefixes using the given monoid.
e.g., for a Sequence of i32 s, s.scan i32.sum creates a list of
partial sums (0..).map x->(s.take x).fold i32.sum
create a slice from this Sequence that consists of the elements starting at index
from (including) up to index to (excluding).
from (including) up to index to (excluding).
§(less_or_equal Function bool Sequence.T Sequence.T):Any => container.sorted_array Sequence.T [Inherited from Sequence]
§(less_or_equal Function bool Sequence.T Sequence.T)
:
Any =>
container.sorted_array Sequence.T [Inherited from Sequence]
sort this Sequence using the total order defined by less_or_equal
§(O type, f Unary Sequence.sort_by.O Sequence.T):Any => container.sorted_array Sequence.T [Inherited from Sequence]
§(O
type
, f Unary Sequence.sort_by.O Sequence.T):
Any =>
container.sorted_array Sequence.T [Inherited from Sequence]
sort this Sequence using total order defined for 'f a[i]'
create a tuple of two Sequences by splitting this at the given index, i.e.,
a Sequence of length 'at' and one of length 'count-at'.
at may be <= 0 or >= count, in which case the resulting tuple will be the
(empty list, Sequence.this.as_list) or (Sequence.this.as_list, empty list), resp.
a Sequence of length 'at' and one of length 'count-at'.
at may be <= 0 or >= count, in which case the resulting tuple will be the
(empty list, Sequence.this.as_list) or (Sequence.this.as_list, empty list), resp.
does this sequence start with l?
the standard deviation of the sequence
https://en.wikipedia.org/wiki/Standard_deviation
https://en.wikipedia.org/wiki/Standard_deviation
create a lazy list of all the tails of this Sequence, including the complete Sequence
as a list and the empty list 'nil'.
as a list and the empty list 'nil'.
create a list that consists only of the first n elements of this
Sequence, fewer if this Sequence has fewer elements
Sequence, fewer if this Sequence has fewer elements
Lazily take the first elements of this Sequence for which predicate 'p' holds.
§(TA type, U type, xf transducer Sequence.transduce.TA Sequence.transduce.U Sequence.T, rf Function Sequence.transduce.TA Sequence.transduce.TA Sequence.transduce.U, init Sequence.transduce.TA):Any => Sequence.transduce.TA [Inherited from Sequence]
§(TA
type
, U type
, xf transducer Sequence.transduce.TA Sequence.transduce.U Sequence.T, rf Function Sequence.transduce.TA Sequence.transduce.TA Sequence.transduce.U, init Sequence.transduce.TA):
Any =>
Sequence.transduce.TA [Inherited from Sequence]
takes a transducer xf, a reducer f and an initial value
returns the result of applying the reducer xf f to the Sequence
returns the result of applying the reducer xf f to the Sequence
value of a switch that is known to contain a value
This can only be called in cases where it is known for sure that this
switch is not a B. A runtime error will be created otherwise.
This can only be called in cases where it is known for sure that this
switch is not a B. A runtime error will be created otherwise.
value of a switch or default if switch contains B
the variance of the sequence
https://en.wikipedia.org/wiki/Variance
https://en.wikipedia.org/wiki/Variance
§(U type, V type, b Sequence Sequence.zip.U, f Function Sequence.zip.V Sequence.T Sequence.zip.U):Any => list Sequence.zip.V [Inherited from Sequence]
§(U
type
, V type
, b Sequence Sequence.zip.U, f Function Sequence.zip.V Sequence.T Sequence.zip.U):
Any =>
list Sequence.zip.V [Inherited from Sequence]
create a new list from the result of applying 'f' to the
elements of this Sequence and 'b' in order.
elements of this Sequence and 'b' in order.
Type Features
string representation of this type to be used for debugging.
result has the form "Type of '<name>'", but this might change in the future
result has the form "Type of '<name>'", but this might change in the future
Maximum number of elements shown for on a call to `as_string` for a non-finite
Sequence.
Sequence.
monoid of Sequences with infix concatentation operation.
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types, so dynamic_type is redefined to just return
Type.type here.
endless hierarchy of types, so dynamic_type is redefined to just return
Type.type here.
Is this type assignable to a type parameter with constraint `T`?
The result of this is a compile-time constant that can be used to specialize
code for a particular type.
is_of_integer_type(n T : numeric) => T : integer
say (is_of_integer_type 1234) # true
say (is_of_integer_type 3.14) # false
it is most useful in conjunction preconditions or `if` statements as in
pair(a,b T) is
=>
or
val(n T) is
The result of this is a compile-time constant that can be used to specialize
code for a particular type.
is_of_integer_type(n T : numeric) => T : integer
say (is_of_integer_type 1234) # true
say (is_of_integer_type 3.14) # false
it is most useful in conjunction preconditions or `if` statements as in
pair(a,b T) is
=>
or
val(n T) is
name of this type, including type parameters, e.g. 'option (list i32)'.
return function
Get a type as a value.
This is a feature with the effect equivalent to Fuzion's `expr.type` call tail.
It is recommended to use `expr.type` and not `expr.type_value`.
`type_value` is here to show how this can be implemented and to illustrate the
difference to `dynamic_type`.
This is a feature with the effect equivalent to Fuzion's `expr.type` call tail.
It is recommended to use `expr.type` and not `expr.type_value`.
`type_value` is here to show how this can be implemented and to illustrate the
difference to `dynamic_type`.
outcome is a choice type that represents the result of a routine that
may either produce something useful or fail producing an error condition.
Several error conditions are needed if there are several very different
reasons for an operation to fail, e.g.
get_data (u User, t Type) outcome data IO_Error Permission_Error is
read_file t Type outcome data IO_Error is
Note that 'outcome data IO_Error' is not assignment compatible with
'outcome data IO_Error Permission_Error', it has to be unwrapped first.
This unwrapping, however, requires very little boilerplate, it is done
using the '?' on the result of the call to 'read_file': This unwraps
'outcome data IO_Error' into 'IO_Error', which would be returned abruptly,
and 'data', which would be returned normally. Both are assignment
compatible to 'outcome data IO_Error Permission_Error', so everything
is fine.