☰
API-Documentation: module base
Constructors
feature to signal an abort of a computation.
contains the final value of a computation.
used e.g. in Sequence.reduce
Any -- parent feature of all features that do not have an explicit parent
array -- one-dimensional immutable array
This is the result type of array(type, i32, i32 -> T) which creates an
initialized immutable array
Note: This uses dummy unit-type args to avoid
name clash with routine array(T,length,init).
array(length0, length1) -- two-dimensional immutable array
array provides two-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
two index parameters.
array(length0, length1, length2) -- three-dimensional immutable array
array provides three-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
three index parameters.
Binary -- function that takes exactly two arguments and returns a result
T is the result type of the function, U1 and U2 are the argument types of the function
codepoint -- represents a unicode codepoint
composition -- a collection of features for function composition
see https://mlochbaum.github.io/BQN/tutorial/combinator.html
Talk at Strange Loop 2016 by Amar Shah: Point-Free or Die: Tacit Programming in Haskell and Beyond
https://www.youtube.com/watch?v=seVSlKazsNk
Talk at CppNorth 2023 by Conor Hoekstra: Function Composition in Programming Languages - Conor Hoekstra - CppNorth 2023
https://www.youtube.com/watch?v=JELcdZLre3s
Paper by Conor Hoekstra: Combinatory Logic and Combinators in Array Languages
https://web.archive.org/web/20220617020347id_/https://dl.acm.org/doi/pdf/10.1145/3520306.3534504
BQN tutorial: https://mlochbaum.github.io/BQN/tutorial/index.html
Talk for Fullstack Academy by Gabriel Lebec: Lambda Calculus - Fundamentals of Lambda Calculus & Functional
Pragramming in JavaScript
https://www.youtube.com/watch?v=3VQ382QG-y4
David C Keenan
To Dissect a Mockingbird: A Graphical Notation for the Lambda Calculus with Animated Reduction
https://dkeenan.com/Lambda/
Haskell package data.aviary.birds:
https://hackage.haskell.org/package/data-aviary-0.4.0/docs/Data-Aviary-Birds.html
Bird names from Raymond M Smullyan. 2000. To Mock a Mockingbird: and other
logic puzzles including an amazing adventure in combinatory logic. Oxford
University Press, USA.
Combinator birds: https://www.angelfire.com/tx4/cus/combinator/birds.html
concur -- unit feature to group concurrency related features
Cons -- feature used to define abstract Cons cells
A Cons is a ref to a cell that contains a head and a tail
cons -- feature used to define simple, non-lazy Cons cells
A cons is a cell that contains a head and a tail
Const_String -- feature used for string constants in Fuzion source code
Const_String cannot be called directly, instances are created implicitly by the
backend.
container -- unit feature to group features that provide some kind of
data structure to store and retrieve values
eff -- unit feature to group features that relate in some way to effects
effect -- abstract parent feature for effects
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
a constructor for holding an effect type and instance
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
feature to signal an abort of a computation.
contains the final value of a computation.
used e.g. in Sequence.reduce
contains the final value of a computation.
used e.g. in Sequence.reduce
Any -- parent feature of all features that do not have an explicit parent
array -- one-dimensional immutable array
This is the result type of array(type, i32, i32 -> T) which creates an
initialized immutable array
Note: This uses dummy unit-type args to avoid
name clash with routine array(T,length,init).
array(length0, length1) -- two-dimensional immutable array
array provides two-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
two index parameters.
array(length0, length1, length2) -- three-dimensional immutable array
array provides three-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
three index parameters.
Binary -- function that takes exactly two arguments and returns a result
T is the result type of the function, U1 and U2 are the argument types of the function
codepoint -- represents a unicode codepoint
composition -- a collection of features for function composition
see https://mlochbaum.github.io/BQN/tutorial/combinator.html
Talk at Strange Loop 2016 by Amar Shah: Point-Free or Die: Tacit Programming in Haskell and Beyond
https://www.youtube.com/watch?v=seVSlKazsNk
Talk at CppNorth 2023 by Conor Hoekstra: Function Composition in Programming Languages - Conor Hoekstra - CppNorth 2023
https://www.youtube.com/watch?v=JELcdZLre3s
Paper by Conor Hoekstra: Combinatory Logic and Combinators in Array Languages
https://web.archive.org/web/20220617020347id_/https://dl.acm.org/doi/pdf/10.1145/3520306.3534504
BQN tutorial: https://mlochbaum.github.io/BQN/tutorial/index.html
Talk for Fullstack Academy by Gabriel Lebec: Lambda Calculus - Fundamentals of Lambda Calculus & Functional
Pragramming in JavaScript
https://www.youtube.com/watch?v=3VQ382QG-y4
David C Keenan
To Dissect a Mockingbird: A Graphical Notation for the Lambda Calculus with Animated Reduction
https://dkeenan.com/Lambda/
Haskell package data.aviary.birds:
https://hackage.haskell.org/package/data-aviary-0.4.0/docs/Data-Aviary-Birds.html
Bird names from Raymond M Smullyan. 2000. To Mock a Mockingbird: and other
logic puzzles including an amazing adventure in combinatory logic. Oxford
University Press, USA.
Combinator birds: https://www.angelfire.com/tx4/cus/combinator/birds.html
concur -- unit feature to group concurrency related features
Cons -- feature used to define abstract Cons cells
A Cons is a ref to a cell that contains a head and a tail
cons -- feature used to define simple, non-lazy Cons cells
A cons is a cell that contains a head and a tail
Const_String -- feature used for string constants in Fuzion source code
Const_String cannot be called directly, instances are created implicitly by the
backend.
container -- unit feature to group features that provide some kind of
data structure to store and retrieve values
eff -- unit feature to group features that relate in some way to effects
effect -- abstract parent feature for effects
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
a constructor for holding an effect type and instance
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
Any -- parent feature of all features that do not have an explicit parent
array -- one-dimensional immutable array
This is the result type of array(type, i32, i32 -> T) which creates an
initialized immutable array
Note: This uses dummy unit-type args to avoid
name clash with routine array(T,length,init).
array(length0, length1) -- two-dimensional immutable array
array provides two-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
two index parameters.
array(length0, length1, length2) -- three-dimensional immutable array
array provides three-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
three index parameters.
Binary -- function that takes exactly two arguments and returns a result
T is the result type of the function, U1 and U2 are the argument types of the function
codepoint -- represents a unicode codepoint
composition -- a collection of features for function composition
see https://mlochbaum.github.io/BQN/tutorial/combinator.html
Talk at Strange Loop 2016 by Amar Shah: Point-Free or Die: Tacit Programming in Haskell and Beyond
https://www.youtube.com/watch?v=seVSlKazsNk
Talk at CppNorth 2023 by Conor Hoekstra: Function Composition in Programming Languages - Conor Hoekstra - CppNorth 2023
https://www.youtube.com/watch?v=JELcdZLre3s
Paper by Conor Hoekstra: Combinatory Logic and Combinators in Array Languages
https://web.archive.org/web/20220617020347id_/https://dl.acm.org/doi/pdf/10.1145/3520306.3534504
BQN tutorial: https://mlochbaum.github.io/BQN/tutorial/index.html
Talk for Fullstack Academy by Gabriel Lebec: Lambda Calculus - Fundamentals of Lambda Calculus & Functional
Pragramming in JavaScript
https://www.youtube.com/watch?v=3VQ382QG-y4
David C Keenan
To Dissect a Mockingbird: A Graphical Notation for the Lambda Calculus with Animated Reduction
https://dkeenan.com/Lambda/
Haskell package data.aviary.birds:
https://hackage.haskell.org/package/data-aviary-0.4.0/docs/Data-Aviary-Birds.html
Bird names from Raymond M Smullyan. 2000. To Mock a Mockingbird: and other
logic puzzles including an amazing adventure in combinatory logic. Oxford
University Press, USA.
Combinator birds: https://www.angelfire.com/tx4/cus/combinator/birds.html
concur -- unit feature to group concurrency related features
Cons -- feature used to define abstract Cons cells
A Cons is a ref to a cell that contains a head and a tail
cons -- feature used to define simple, non-lazy Cons cells
A cons is a cell that contains a head and a tail
Const_String -- feature used for string constants in Fuzion source code
Const_String cannot be called directly, instances are created implicitly by the
backend.
container -- unit feature to group features that provide some kind of
data structure to store and retrieve values
eff -- unit feature to group features that relate in some way to effects
effect -- abstract parent feature for effects
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
a constructor for holding an effect type and instance
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
array -- one-dimensional immutable array
This is the result type of array(type, i32, i32 -> T) which creates an
initialized immutable array
Note: This uses dummy unit-type args to avoid
name clash with routine array(T,length,init).
This is the result type of array(type, i32, i32 -> T) which creates an
initialized immutable array
Note: This uses dummy unit-type args to avoid
name clash with routine array(T,length,init).
array(length0, length1) -- two-dimensional immutable array
array provides two-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
two index parameters.
array(length0, length1, length2) -- three-dimensional immutable array
array provides three-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
three index parameters.
Binary -- function that takes exactly two arguments and returns a result
T is the result type of the function, U1 and U2 are the argument types of the function
codepoint -- represents a unicode codepoint
composition -- a collection of features for function composition
see https://mlochbaum.github.io/BQN/tutorial/combinator.html
Talk at Strange Loop 2016 by Amar Shah: Point-Free or Die: Tacit Programming in Haskell and Beyond
https://www.youtube.com/watch?v=seVSlKazsNk
Talk at CppNorth 2023 by Conor Hoekstra: Function Composition in Programming Languages - Conor Hoekstra - CppNorth 2023
https://www.youtube.com/watch?v=JELcdZLre3s
Paper by Conor Hoekstra: Combinatory Logic and Combinators in Array Languages
https://web.archive.org/web/20220617020347id_/https://dl.acm.org/doi/pdf/10.1145/3520306.3534504
BQN tutorial: https://mlochbaum.github.io/BQN/tutorial/index.html
Talk for Fullstack Academy by Gabriel Lebec: Lambda Calculus - Fundamentals of Lambda Calculus & Functional
Pragramming in JavaScript
https://www.youtube.com/watch?v=3VQ382QG-y4
David C Keenan
To Dissect a Mockingbird: A Graphical Notation for the Lambda Calculus with Animated Reduction
https://dkeenan.com/Lambda/
Haskell package data.aviary.birds:
https://hackage.haskell.org/package/data-aviary-0.4.0/docs/Data-Aviary-Birds.html
Bird names from Raymond M Smullyan. 2000. To Mock a Mockingbird: and other
logic puzzles including an amazing adventure in combinatory logic. Oxford
University Press, USA.
Combinator birds: https://www.angelfire.com/tx4/cus/combinator/birds.html
concur -- unit feature to group concurrency related features
Cons -- feature used to define abstract Cons cells
A Cons is a ref to a cell that contains a head and a tail
cons -- feature used to define simple, non-lazy Cons cells
A cons is a cell that contains a head and a tail
Const_String -- feature used for string constants in Fuzion source code
Const_String cannot be called directly, instances are created implicitly by the
backend.
container -- unit feature to group features that provide some kind of
data structure to store and retrieve values
eff -- unit feature to group features that relate in some way to effects
effect -- abstract parent feature for effects
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
a constructor for holding an effect type and instance
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
array(length0, length1) -- two-dimensional immutable array
array provides two-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
two index parameters.
array provides two-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
two index parameters.
array(length0, length1, length2) -- three-dimensional immutable array
array provides three-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
three index parameters.
Binary -- function that takes exactly two arguments and returns a result
T is the result type of the function, U1 and U2 are the argument types of the function
codepoint -- represents a unicode codepoint
composition -- a collection of features for function composition
see https://mlochbaum.github.io/BQN/tutorial/combinator.html
Talk at Strange Loop 2016 by Amar Shah: Point-Free or Die: Tacit Programming in Haskell and Beyond
https://www.youtube.com/watch?v=seVSlKazsNk
Talk at CppNorth 2023 by Conor Hoekstra: Function Composition in Programming Languages - Conor Hoekstra - CppNorth 2023
https://www.youtube.com/watch?v=JELcdZLre3s
Paper by Conor Hoekstra: Combinatory Logic and Combinators in Array Languages
https://web.archive.org/web/20220617020347id_/https://dl.acm.org/doi/pdf/10.1145/3520306.3534504
BQN tutorial: https://mlochbaum.github.io/BQN/tutorial/index.html
Talk for Fullstack Academy by Gabriel Lebec: Lambda Calculus - Fundamentals of Lambda Calculus & Functional
Pragramming in JavaScript
https://www.youtube.com/watch?v=3VQ382QG-y4
David C Keenan
To Dissect a Mockingbird: A Graphical Notation for the Lambda Calculus with Animated Reduction
https://dkeenan.com/Lambda/
Haskell package data.aviary.birds:
https://hackage.haskell.org/package/data-aviary-0.4.0/docs/Data-Aviary-Birds.html
Bird names from Raymond M Smullyan. 2000. To Mock a Mockingbird: and other
logic puzzles including an amazing adventure in combinatory logic. Oxford
University Press, USA.
Combinator birds: https://www.angelfire.com/tx4/cus/combinator/birds.html
concur -- unit feature to group concurrency related features
Cons -- feature used to define abstract Cons cells
A Cons is a ref to a cell that contains a head and a tail
cons -- feature used to define simple, non-lazy Cons cells
A cons is a cell that contains a head and a tail
Const_String -- feature used for string constants in Fuzion source code
Const_String cannot be called directly, instances are created implicitly by the
backend.
container -- unit feature to group features that provide some kind of
data structure to store and retrieve values
eff -- unit feature to group features that relate in some way to effects
effect -- abstract parent feature for effects
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
a constructor for holding an effect type and instance
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
array(length0, length1, length2) -- three-dimensional immutable array
array provides three-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
three index parameters.
array provides three-dimensional immutable arrays. These are actually
one-dimensional immutable arrays with an additional access function with
three index parameters.
Binary -- function that takes exactly two arguments and returns a result
T is the result type of the function, U1 and U2 are the argument types of the function
codepoint -- represents a unicode codepoint
composition -- a collection of features for function composition
see https://mlochbaum.github.io/BQN/tutorial/combinator.html
Talk at Strange Loop 2016 by Amar Shah: Point-Free or Die: Tacit Programming in Haskell and Beyond
https://www.youtube.com/watch?v=seVSlKazsNk
Talk at CppNorth 2023 by Conor Hoekstra: Function Composition in Programming Languages - Conor Hoekstra - CppNorth 2023
https://www.youtube.com/watch?v=JELcdZLre3s
Paper by Conor Hoekstra: Combinatory Logic and Combinators in Array Languages
https://web.archive.org/web/20220617020347id_/https://dl.acm.org/doi/pdf/10.1145/3520306.3534504
BQN tutorial: https://mlochbaum.github.io/BQN/tutorial/index.html
Talk for Fullstack Academy by Gabriel Lebec: Lambda Calculus - Fundamentals of Lambda Calculus & Functional
Pragramming in JavaScript
https://www.youtube.com/watch?v=3VQ382QG-y4
David C Keenan
To Dissect a Mockingbird: A Graphical Notation for the Lambda Calculus with Animated Reduction
https://dkeenan.com/Lambda/
Haskell package data.aviary.birds:
https://hackage.haskell.org/package/data-aviary-0.4.0/docs/Data-Aviary-Birds.html
Bird names from Raymond M Smullyan. 2000. To Mock a Mockingbird: and other
logic puzzles including an amazing adventure in combinatory logic. Oxford
University Press, USA.
Combinator birds: https://www.angelfire.com/tx4/cus/combinator/birds.html
concur -- unit feature to group concurrency related features
Cons -- feature used to define abstract Cons cells
A Cons is a ref to a cell that contains a head and a tail
cons -- feature used to define simple, non-lazy Cons cells
A cons is a cell that contains a head and a tail
Const_String -- feature used for string constants in Fuzion source code
Const_String cannot be called directly, instances are created implicitly by the
backend.
container -- unit feature to group features that provide some kind of
data structure to store and retrieve values
eff -- unit feature to group features that relate in some way to effects
effect -- abstract parent feature for effects
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
a constructor for holding an effect type and instance
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
Binary -- function that takes exactly two arguments and returns a result
T is the result type of the function, U1 and U2 are the argument types of the function
codepoint -- represents a unicode codepoint
composition -- a collection of features for function composition
see https://mlochbaum.github.io/BQN/tutorial/combinator.html
Talk at Strange Loop 2016 by Amar Shah: Point-Free or Die: Tacit Programming in Haskell and Beyond
https://www.youtube.com/watch?v=seVSlKazsNk
Talk at CppNorth 2023 by Conor Hoekstra: Function Composition in Programming Languages - Conor Hoekstra - CppNorth 2023
https://www.youtube.com/watch?v=JELcdZLre3s
Paper by Conor Hoekstra: Combinatory Logic and Combinators in Array Languages
https://web.archive.org/web/20220617020347id_/https://dl.acm.org/doi/pdf/10.1145/3520306.3534504
BQN tutorial: https://mlochbaum.github.io/BQN/tutorial/index.html
Talk for Fullstack Academy by Gabriel Lebec: Lambda Calculus - Fundamentals of Lambda Calculus & Functional
Pragramming in JavaScript
https://www.youtube.com/watch?v=3VQ382QG-y4
David C Keenan
To Dissect a Mockingbird: A Graphical Notation for the Lambda Calculus with Animated Reduction
https://dkeenan.com/Lambda/
Haskell package data.aviary.birds:
https://hackage.haskell.org/package/data-aviary-0.4.0/docs/Data-Aviary-Birds.html
Bird names from Raymond M Smullyan. 2000. To Mock a Mockingbird: and other
logic puzzles including an amazing adventure in combinatory logic. Oxford
University Press, USA.
Combinator birds: https://www.angelfire.com/tx4/cus/combinator/birds.html
concur -- unit feature to group concurrency related features
Cons -- feature used to define abstract Cons cells
A Cons is a ref to a cell that contains a head and a tail
cons -- feature used to define simple, non-lazy Cons cells
A cons is a cell that contains a head and a tail
Const_String -- feature used for string constants in Fuzion source code
Const_String cannot be called directly, instances are created implicitly by the
backend.
container -- unit feature to group features that provide some kind of
data structure to store and retrieve values
eff -- unit feature to group features that relate in some way to effects
effect -- abstract parent feature for effects
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
a constructor for holding an effect type and instance
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
Binary -- function that takes exactly two arguments and returns a result
T is the result type of the function, U1 and U2 are the argument types of the function
T is the result type of the function, U1 and U2 are the argument types of the function
codepoint -- represents a unicode codepoint
composition -- a collection of features for function composition
see https://mlochbaum.github.io/BQN/tutorial/combinator.html
Talk at Strange Loop 2016 by Amar Shah: Point-Free or Die: Tacit Programming in Haskell and Beyond
https://www.youtube.com/watch?v=seVSlKazsNk
Talk at CppNorth 2023 by Conor Hoekstra: Function Composition in Programming Languages - Conor Hoekstra - CppNorth 2023
https://www.youtube.com/watch?v=JELcdZLre3s
Paper by Conor Hoekstra: Combinatory Logic and Combinators in Array Languages
https://web.archive.org/web/20220617020347id_/https://dl.acm.org/doi/pdf/10.1145/3520306.3534504
BQN tutorial: https://mlochbaum.github.io/BQN/tutorial/index.html
Talk for Fullstack Academy by Gabriel Lebec: Lambda Calculus - Fundamentals of Lambda Calculus & Functional
Pragramming in JavaScript
https://www.youtube.com/watch?v=3VQ382QG-y4
David C Keenan
To Dissect a Mockingbird: A Graphical Notation for the Lambda Calculus with Animated Reduction
https://dkeenan.com/Lambda/
Haskell package data.aviary.birds:
https://hackage.haskell.org/package/data-aviary-0.4.0/docs/Data-Aviary-Birds.html
Bird names from Raymond M Smullyan. 2000. To Mock a Mockingbird: and other
logic puzzles including an amazing adventure in combinatory logic. Oxford
University Press, USA.
Combinator birds: https://www.angelfire.com/tx4/cus/combinator/birds.html
concur -- unit feature to group concurrency related features
Cons -- feature used to define abstract Cons cells
A Cons is a ref to a cell that contains a head and a tail
cons -- feature used to define simple, non-lazy Cons cells
A cons is a cell that contains a head and a tail
Const_String -- feature used for string constants in Fuzion source code
Const_String cannot be called directly, instances are created implicitly by the
backend.
container -- unit feature to group features that provide some kind of
data structure to store and retrieve values
eff -- unit feature to group features that relate in some way to effects
effect -- abstract parent feature for effects
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
a constructor for holding an effect type and instance
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
codepoint -- represents a unicode codepoint
composition -- a collection of features for function composition
see https://mlochbaum.github.io/BQN/tutorial/combinator.html
Talk at Strange Loop 2016 by Amar Shah: Point-Free or Die: Tacit Programming in Haskell and Beyond
https://www.youtube.com/watch?v=seVSlKazsNk
Talk at CppNorth 2023 by Conor Hoekstra: Function Composition in Programming Languages - Conor Hoekstra - CppNorth 2023
https://www.youtube.com/watch?v=JELcdZLre3s
Paper by Conor Hoekstra: Combinatory Logic and Combinators in Array Languages
https://web.archive.org/web/20220617020347id_/https://dl.acm.org/doi/pdf/10.1145/3520306.3534504
BQN tutorial: https://mlochbaum.github.io/BQN/tutorial/index.html
Talk for Fullstack Academy by Gabriel Lebec: Lambda Calculus - Fundamentals of Lambda Calculus & Functional
Pragramming in JavaScript
https://www.youtube.com/watch?v=3VQ382QG-y4
David C Keenan
To Dissect a Mockingbird: A Graphical Notation for the Lambda Calculus with Animated Reduction
https://dkeenan.com/Lambda/
Haskell package data.aviary.birds:
https://hackage.haskell.org/package/data-aviary-0.4.0/docs/Data-Aviary-Birds.html
Bird names from Raymond M Smullyan. 2000. To Mock a Mockingbird: and other
logic puzzles including an amazing adventure in combinatory logic. Oxford
University Press, USA.
Combinator birds: https://www.angelfire.com/tx4/cus/combinator/birds.html
concur -- unit feature to group concurrency related features
Cons -- feature used to define abstract Cons cells
A Cons is a ref to a cell that contains a head and a tail
cons -- feature used to define simple, non-lazy Cons cells
A cons is a cell that contains a head and a tail
Const_String -- feature used for string constants in Fuzion source code
Const_String cannot be called directly, instances are created implicitly by the
backend.
container -- unit feature to group features that provide some kind of
data structure to store and retrieve values
eff -- unit feature to group features that relate in some way to effects
effect -- abstract parent feature for effects
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
a constructor for holding an effect type and instance
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
composition -- a collection of features for function composition
see https://mlochbaum.github.io/BQN/tutorial/combinator.html
Talk at Strange Loop 2016 by Amar Shah: Point-Free or Die: Tacit Programming in Haskell and Beyond
https://www.youtube.com/watch?v=seVSlKazsNk
Talk at CppNorth 2023 by Conor Hoekstra: Function Composition in Programming Languages - Conor Hoekstra - CppNorth 2023
https://www.youtube.com/watch?v=JELcdZLre3s
Paper by Conor Hoekstra: Combinatory Logic and Combinators in Array Languages
https://web.archive.org/web/20220617020347id_/https://dl.acm.org/doi/pdf/10.1145/3520306.3534504
BQN tutorial: https://mlochbaum.github.io/BQN/tutorial/index.html
Talk for Fullstack Academy by Gabriel Lebec: Lambda Calculus - Fundamentals of Lambda Calculus & Functional
Pragramming in JavaScript
https://www.youtube.com/watch?v=3VQ382QG-y4
David C Keenan
To Dissect a Mockingbird: A Graphical Notation for the Lambda Calculus with Animated Reduction
https://dkeenan.com/Lambda/
Haskell package data.aviary.birds:
https://hackage.haskell.org/package/data-aviary-0.4.0/docs/Data-Aviary-Birds.html
Bird names from Raymond M Smullyan. 2000. To Mock a Mockingbird: and other
logic puzzles including an amazing adventure in combinatory logic. Oxford
University Press, USA.
Combinator birds: https://www.angelfire.com/tx4/cus/combinator/birds.html
see https://mlochbaum.github.io/BQN/tutorial/combinator.html
Talk at Strange Loop 2016 by Amar Shah: Point-Free or Die: Tacit Programming in Haskell and Beyond
https://www.youtube.com/watch?v=seVSlKazsNk
Talk at CppNorth 2023 by Conor Hoekstra: Function Composition in Programming Languages - Conor Hoekstra - CppNorth 2023
https://www.youtube.com/watch?v=JELcdZLre3s
Paper by Conor Hoekstra: Combinatory Logic and Combinators in Array Languages
https://web.archive.org/web/20220617020347id_/https://dl.acm.org/doi/pdf/10.1145/3520306.3534504
BQN tutorial: https://mlochbaum.github.io/BQN/tutorial/index.html
Talk for Fullstack Academy by Gabriel Lebec: Lambda Calculus - Fundamentals of Lambda Calculus & Functional
Pragramming in JavaScript
https://www.youtube.com/watch?v=3VQ382QG-y4
David C Keenan
To Dissect a Mockingbird: A Graphical Notation for the Lambda Calculus with Animated Reduction
https://dkeenan.com/Lambda/
Haskell package data.aviary.birds:
https://hackage.haskell.org/package/data-aviary-0.4.0/docs/Data-Aviary-Birds.html
Bird names from Raymond M Smullyan. 2000. To Mock a Mockingbird: and other
logic puzzles including an amazing adventure in combinatory logic. Oxford
University Press, USA.
Combinator birds: https://www.angelfire.com/tx4/cus/combinator/birds.html
concur -- unit feature to group concurrency related features
Cons -- feature used to define abstract Cons cells
A Cons is a ref to a cell that contains a head and a tail
cons -- feature used to define simple, non-lazy Cons cells
A cons is a cell that contains a head and a tail
Const_String -- feature used for string constants in Fuzion source code
Const_String cannot be called directly, instances are created implicitly by the
backend.
container -- unit feature to group features that provide some kind of
data structure to store and retrieve values
eff -- unit feature to group features that relate in some way to effects
effect -- abstract parent feature for effects
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
a constructor for holding an effect type and instance
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
concur -- unit feature to group concurrency related features
Cons -- feature used to define abstract Cons cells
A Cons is a ref to a cell that contains a head and a tail
cons -- feature used to define simple, non-lazy Cons cells
A cons is a cell that contains a head and a tail
Const_String -- feature used for string constants in Fuzion source code
Const_String cannot be called directly, instances are created implicitly by the
backend.
container -- unit feature to group features that provide some kind of
data structure to store and retrieve values
eff -- unit feature to group features that relate in some way to effects
effect -- abstract parent feature for effects
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
a constructor for holding an effect type and instance
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
Cons -- feature used to define abstract Cons cells
A Cons is a ref to a cell that contains a head and a tail
A Cons is a ref to a cell that contains a head and a tail
cons -- feature used to define simple, non-lazy Cons cells
A cons is a cell that contains a head and a tail
Const_String -- feature used for string constants in Fuzion source code
Const_String cannot be called directly, instances are created implicitly by the
backend.
container -- unit feature to group features that provide some kind of
data structure to store and retrieve values
eff -- unit feature to group features that relate in some way to effects
effect -- abstract parent feature for effects
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
a constructor for holding an effect type and instance
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
cons -- feature used to define simple, non-lazy Cons cells
A cons is a cell that contains a head and a tail
A cons is a cell that contains a head and a tail
Const_String -- feature used for string constants in Fuzion source code
Const_String cannot be called directly, instances are created implicitly by the
backend.
container -- unit feature to group features that provide some kind of
data structure to store and retrieve values
eff -- unit feature to group features that relate in some way to effects
effect -- abstract parent feature for effects
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
a constructor for holding an effect type and instance
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
Const_String -- feature used for string constants in Fuzion source code
Const_String cannot be called directly, instances are created implicitly by the
backend.
Const_String cannot be called directly, instances are created implicitly by the
backend.
container -- unit feature to group features that provide some kind of
data structure to store and retrieve values
eff -- unit feature to group features that relate in some way to effects
effect -- abstract parent feature for effects
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
a constructor for holding an effect type and instance
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
container -- unit feature to group features that provide some kind of
data structure to store and retrieve values
data structure to store and retrieve values
eff -- unit feature to group features that relate in some way to effects
effect -- abstract parent feature for effects
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
a constructor for holding an effect type and instance
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
eff -- unit feature to group features that relate in some way to effects
effect -- abstract parent feature for effects
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
a constructor for holding an effect type and instance
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
effect -- abstract parent feature for effects
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
effect provides a means to perform effectful operations. Instances
of effect are instated in the current environment while their code is
executed. The code may perform operations of the instated effect
via <type>.env. These operations may either return normally (resume) or
abort the current computation, i.e., return directly to the call that
instated the effect.
Effects are identified by their type, including any actual type parameters.
Effect instances must be assignable to the effect type. This means that if
the effect type is a value type, the instance must be an instance of exactly
that type while if the effect type is a ref type, the instance might be of
a type that inherits from the effect type that is --possibly after boxing--
assignable to that type.
Effect operations may replace an instated instance by a new value.
This gives operations a means to become stateful.
In case an effect performs an abort, the code the effect was instated for
will be abandoned and the function passed via tha `def` argument to
`instate` will be used to produce a result from the last effect instance.
Effects may redefine the `finally` feature that is executed directly after
an instated effect was removed, independent of the reason why it is removed.
This means, finally is executed after code running in the effect returns
normally, after a call to an operation that results in an abort or when
a surrounding effect is aborted.
a constructor for holding an effect type and instance
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
a constructor for holding an effect type and instance
this allows defining operators
this allows defining operators
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
encodings -- unit feature to group encodings
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
envir -- unit feature to group environment related features
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
error represents an error condition described by a message string
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
NYI: Future versions of error might be equipped with a stack trace if
debugging is enabled
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
exit -- effect that terminates a computation in exit
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
Exit_Handler -- abstract exit
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
f32 -- 32 bit floating point values
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f32 are binary32-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
f64 -- 64 bit floating point values
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
f64 are binary64-numbers as defined in the IEEE 754-2019 standard, see
https://ieeexplore.ieee.org/servlet/opac?punumber=8766227
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
boolean value "false"
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
Note that this value is of unit type >>false_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := false_
you will get a variable of type >>false_<<, it will not be possible to assign
>>true_<< to it. You can use >>false<< as an alternative to get type >>bool<<.
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
float -- floating point values
float is the abstract parent of concrete floating point features such as
f32 or f64.
float is the abstract parent of concrete floating point features such as
f32 or f64.
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
Function -- generic function with arbitrary number of arguments and result
R is the result type of the function, A are the argument types of the function
R is the result type of the function, A are the argument types of the function
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
fuzion -- unit feature to group fuzion-infrustructure related features
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
type of the reference to the cell that holds a value of type T which can be updated
using the handles interface
using the handles interface
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
handle value created by 'handles2.new'
§handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
§
handles provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
an example of using handles is shown below, handle (singular) is an
alias to initialize a new handle with the given initial value. handle0 T
is the type that allows passing around handles.
the example also shows the difference between handles and the mutate effect:
while both provide a way to store and update a mutable value, a handle can be
passed around between features. meanwhile, mutables are not a type that can be
given to other features, only values can. handles essentially provide an
abstraction of pointers, implemented natively in Fuzion.
§handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
§
handles2 provide a means to create handles that refer to update-able
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
cells.
handles is a state monad. It provides features to create several
handles that refer to modifiable value and features to 'get', 'put' or
'update' this value.
For performance, this implementation uses mutable state. It can consequently
only be used as a one-way monad.
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
has_interval -- feature for integers that can define an interval
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
i128 -- 128-bit signed integer values
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
i16 -- 16-bit signed integer values
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
i32 -- 32-bit signed integer values
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
i64 -- 64-bit signed integer values
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
i8 -- 8-bit signed integer values
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
int -- signed integer values of arbitrary size
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
integer -- abstract ancestor of integer numbers
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
integer is the abstract ancestor of integer numbers that provides operations
from numeric plus a division remainder operation %, bitwise logical operations,
shift operations and gcd. Also, integers can be used to build fractions.
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
internationalization -- unit feature to group features related to specific
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
geographical, political, or cultural regions such as formatting of dates,
numbers, currencies, etc.
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
An interval `from..through` that includes `from`, `from+step`, `from+step+step`,
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
etc. up to and including `through`.
In case step is positive (negative), the first value larger (smaller) than
through will not be included.
In case `step.sign = (from ⋄ through).sign`, this `Set` is empty, e.g.,
`interval 1 2 -1` and `interval 2 1 1` are both empty.
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
io -- unit feature to group io related features
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
Lazy has special compiler support.
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
It can be used to require lazy evaluation of arguments.
A good example is `or` in bool:
In the following example the expression
`4+5>10` will never be executed:
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
monad -- generic monad
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
A monad in X is just a monoid in the category of endofunctors of X, with
product × replaced by composition of endofunctors and unit set by the
identity endofunctor.
Don't be scared, in Java terms: A monad is a means to compose functions
applied to generic types.
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
Monoid -- parent feature for monoids
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
A monoid is an abstraction for a type with an associative operation and
an identity element. Examples are (integers/infix +/0), (float/infix *,1),
(string/concat/""), etc.
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
mutate -- an effect that permits creation and mutation of mutable values.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
This effect is typically used to work with mutable values. You can create
a mutable value as follows
v := mutate.env.new i32 42
and then modify it using
v <- 666
To read it, call 'get' as in
say "v is {v.get}"
Convenience feature 'mut' and type inference allow the creation to be
written as
v := mut 42
NYI: syntax sugar to read mutable field using
w := v + 1
instead of
w := v.get + 1
is not supported yet.
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
net -- unit feature to group net related features
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
nil -- value for options that are not present
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
This is a unit type that is preferred to represent instances that are
not present, e.g, in an option.
Nullary -- function that takes no argument and returns a result
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
Nullary -- function that takes no argument and returns a result
T is the result type of the function
T is the result type of the function
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
num -- unit feature to group features that relate in some way to numbers
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
numeric -- parent of all numeric features
executes `f` only the first time when
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
executes `f` only the first time when
calling `get` caching its result.
calling `get` caching its result.
§(A type, OMA type :oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):monad A, OMA,effect is [Contains abstract features]oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
§
(A
type
, OMA type
:oneway_monad oneway_monad.A oneway_monad.OMA, mode oneway_monad_mode.val):
monad A, OMA,effect is
[Contains abstract features]
oneway_monad -- heir feature of all one-way monads.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
oneway_monad is the heir feature of all one-way monads. A one-way monad is
a monadic feature that can be accessed as a effect through the environment
and that will be replaced in the environment whenever a new instance is
created. Alternatively, this can be used as a monad that wraps around a
function result type A.
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
enum of the mode argument.
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
panic -- effect that terminates a computation in panic
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
property -- unit feature to group features that can be inherited by other
features if they fulfill certain properties such as defining a partial
order
features if they fulfill certain properties such as defining a partial
order
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
quantor -- unit type feature containing quantors ∀ and ∃.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
quantor provides for_all and exists-quantors for use in contracts qualified
for analysis.
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
random -- effect that provides random numbers
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
Random_Handler -- abstract source of random numbers
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
This provides the random number input to be used by the 'random' effect.
Implementation may be dumb sequences of pseudo-random numbers or high-quality
cryptographic random number generators
A Random_Handler contains an immutable state, repeated calls to 'get' result
in the same value. To produce a sequence of different random numbers, 'next'
must be used to create a new instance of 'Random_Handler' before 'get' can be
used to obtain the new random number.
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
Sequence -- ancestor for features that can be converted to a 'list'
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
Sequences are empty, finite or infinite ordered collections of instances
of a given type. Sequences may calculate elements lazily on demand.
Sequence is a 'ref' type, i.e., different sub-features may be assigned
to a field of type 'Sequence'.
Heirs of Sequence must implement 'as_list'.
§(T type, S type, val T, get S, mode oneway_monad_mode.val):oneway_monad T, state T S is [Contains abstract features]state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
§
(T
type
, S type
, val T, get S, mode oneway_monad_mode.val):
oneway_monad T, state T S is
[Contains abstract features]
state -- represent a state using a monad
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
this can be used both as plain or as a oneway monad to store a state
in a way orthogonal to the actual computation.
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
string -- immutable sequences of utf8 encoded unicode characters
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
time -- unit feature to group time related features
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
transducers map one reducing function to
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
another reducing function. this enables composition
and reuse of map, filter, reduce etc.
see https://clojure.org/reference/transducers
for in depth information on transducers
usage example:
human(age i32) is
td := (transducer (Sequence i32) i32 human).type
ages := td.map (x -> x.age)
gt_ten := td.filter (x -> x > 10)
xf := ages ∘ gt_ten
say ([human 4, human 12, human 30].into xf) # [12,30]
TA result type
B input type
C transduced type
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
boolean value "true"
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
Note that this value is of unit type >>true_<<, not of type >>bool<<, i.e.,
if it is used for type inference as in
my_boolean := true_
you will get a variable of type >>true_<<, it will not be possible to assign
>>false_<< to it. You can use >>true<< as an alternative to get type >>bool<<.
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
try -- simple exception effect
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
try provides an operation 'cause' that immediately stops execution and
returns an 'error' wrapped in an 'outcome'.
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
effect that uses the try effect to be able
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
to raise errors and abort itself.
contrary to `try` there is no need to implement `type.new(h error->void)`
NYI: BUG: moving this to eff leads to NullPointerException: Cannot read field "universe" because "dev.flang.ast.Types.resolved" is null
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
tuple -- feature used to define tuple types
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
tuple types provide algebraic product types of all the generic arguments
provided to tuple.
The values within a tuple 'tuple A B C' can be accessed via the tuple's
argument field 'values' followed by a selector referring to the generic
argument's position: 'values.0', 'values.1' and 'values.2', respectively.
Syntactic sugar of the Fuzion language permits an alternative notation
to create values of tuple types as follows
t := (a, b, c, ... )
is equivalent to
t := tuple a b c ...
The actual generic types are inferred from the static types of the values
'a', 'b', 'c', ... the tuple is created from.
Similarly, syntactic sugar for the destructuring of tuples can be used
to access the values as in
(a, b, c, ...) := t
In destructurings, we can denote values we are not interested in using
'_' as in
(_, b) := ("first", "second")
which will set 'b' to '"second"' and drop the first element of the tuple.
As an example, say we want to identify a person by its name and its age,
so we can define
a := ("Alice" , 11)
b := ("Bob" , 22)
c := ("Claire", 33)
Then, we could extract Bob's age using
(_, age) := b
or Claire's name using
(name, _) := c
Destructuring also works for general features, e.g.
point (x,y i32) is {}
p := point 3, 4
(px, py) := p # will set px to 3 and py to 4
and the destructured value can then be used to create a tuple
t := (px, py) # will create tuple<i32,i32> instance
however, tuples are not assignment compatible with general features even
if they would destructure into the same types, i.e.,
u tuple i32 i32 = p # will cause compile time error
q point = (7, 12) # will cause compile time error
The unit tuple '()' can be used as a short-hand to create the empty tuple
'tuple'. The empty tuple can be destructured like any other tuple
using
() := ()
even though this has no effect.
An instance of the single tuple 'tuple A' with sole element 'a' can not
be created using syntactic sugar '(a)', this will produce the plain
value of 'a' instead. However, destructuring of a single tuple is possible:
(a0) := tuple a
which is equivalent to
a0 := a
NYI: A single tuple 'tuple A' is currently not assignment compatible with
type 'A', which would make handling of general tuples easier.
tuples and destructuring can be used to swap two elements or create a
permutation as in
(a, b) := (b, a)
(o, t, a, n) := (n, a, t, o)
A tuple type with no actual generic arguments is isomorphic to 'unit', i.e, it
is a type that has only one single value: '()'.
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
Type -- parent feature of all type features
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
type features 'f.type' are declared implicitly for every feature f.
Type features do not contain state, they are unit types.
All type features inherit directly (Any.type) or indirectly (all
others type features) from this feature.
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
u128 -- 128-bit unsigned integer values
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
u16 -- 16-bit unsigned integer values
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
u32 -- 32-bit unsigned integer values
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
u64 -- 64-bit unsigned integer values
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
u8 -- 8-bit unsigned integer values
unsigned integer of arbitrary size, including zero
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
unsigned integer of arbitrary size, including zero
represented by its bit sequence
represented by its bit sequence
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
Unary -- function that takes exactly one argument and returns a result
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
T is the result type of the function, U is the argument type of the function
For unary functions, function composition is possible if the result type of
the first function matches the argument type of the second function.
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
unique_id -- effect that generates a unique id
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
unit -- value to be used as result of features that do not return a result
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
NOTE: unit corresponds to type void in C, Java, etc.
unit is the preferred result type for features that return without producing
a result value. These are features that typically have an outside effect
such as
println(String s) unit => ...
or features that change the state of an instance such as
increment(delta i64) unit =>
Universe can not be called but you can use it in a call as part of a full qualifier, e.g.:
`universe.this.say "hello"`