Prelude
Classes
class Add [a : Type]
A type class for addition.
Signatures
class Applicative [m : Type -> Type] with Functor[m]
A type class for functors that support application, i.e. allow to:
- Make an applicative value out of a normal value (embed it into a default context), e.g. embed
5
intoSome(5)
. - Apply a function-type applicative to a matching argument-type applicative, resulting in an applicative of the function's result type.
The meaning of the application realized by the ap
function is defined by the respective instance.
Conceptually this can be understood as applying functions "contained" in the first applicative to arguments
in the second applicative, where the possible quantity of functions/arguments depends on the type m
.
For example, an Option[a -> b]
can be None
, or contain a function of type a -> b
, and only in the
latter case a function is applied. A List[a -> b]
is an applicative that contains a list of functions,
which are all to be applied to all arguments contained in the arguments list.
A minimal implementation must define point
and at least one of ap
and map2
(if map2
is implemented,
ap
can be defined based on map2
as shown below). If both ap
and map2
are defined,
they must be equivalent to their default definitions:
ap(f: m[a -> b \ e], x: m[a]): m[b] \ ef = map2(identity, f, x)
map2(f: a -> b -> c \ e, x: m[a], y: m[b]): m[c] \ ef = ap(Functor.map(f, x), y)
Signatures
Definitions
Lift a ternary function to work on Applicative
s.
Instances can define more efficient implementations than the default implementation
(which is Applicative.ap(Applicative.map2(f, x1, x2), x3)
).
Lift a 4-ary function to work on Applicative
s.
Instances can define more efficient implementations than the default implementation
(which is Applicative.ap(Applicative.map3(f, x1, x2, x3), x4)
).
Lift a 5-ary function to work on Applicative
s.
Instances can define more efficient implementations than the default implementation
(which is Applicative.ap(Applicative.map3(f, x1, x2, x3), x4)
).
class Closeable [a : Type]
A type class for types that can be closed.
Signatures
Instances
class Collectable [m : Type -> Type]
A class representing collections that can be produced from an Iterator.
Signatures
class CommutativeGroup [a : Type] with Group[a] CommutativeMonoid[a]
A type class for types that form a commutative group (abelian group)
i.e. groups where the combine
function is commutative.
The default instances for number define the additive inverse in the real numbers.
Instances
class CommutativeMonoid [a : Type] with Monoid[a]
A type class for types that form a commutative monoid.
Definitions
Instances
class CommutativeSemiGroup [a : Type] with SemiGroup[a]
A type class for types that form a commutative semigroup.
Definitions
Instances
class Div [a : Type]
A type class for division.
Signatures
class Eq [a : Type]
Signatures
Definitions
Instances
class Filterable [m : Type -> Type] with Functor[m]
A type class for filtering container functors.
Signatures
Definitions
class Foldable [t : Type -> Type]
A type class for data structures that can be folded.
Signatures
Definitions
Returns the number of elements in t
that satisfy the predicate f
.
Returns t
without the longest prefix that satisfies the predicate f
.
Returns an immutable list.
Returns true
if and only if at least one element in t
satisfies the predicate f
.
Returns false
if t
is empty.
Returns an immutable list of all the elements in t
that satisfy the predicate f
.
Optionally returns the first element of t
that satisfies the predicate f
when searching from left to right.
Returns None
if t
is empty.
Optionally returns the first element of t
that satisfies the predicate f
when searching from right to left.
Returns None
if t
is empty.
A monadic version of foldLeft
.
Applies the monadic f
to a start value s
and all elements in t
going
from left to right.
Returns the result of mapping each element and combining the results.
A monadic version of foldRight
.
Applies the monadic f
to a start value s
and all elements in t
going
from right to left.
Returns true
if and only if all elements in t
satisfy the predicate f
.
Returns true
if t
is empty.
Applies f
to each element in t
.
A monadic version of forEach
.
Apply f
to every value in t
. f
is applied for its monadic effect,
the answer it produces is discarded.
Optionally returns the first element of t
.
Returns None
if t
is empty.
Returns true if and only if t
is empty.
Returns the concatenation of the string representation
of each element in t
with sep
inserted between each element.
Returns the concatenation of the string representation
of each element in t
according to f
with sep
inserted between each element.
Optionally returns the last element of t
.
Returns None
if t
is empty.
Optionally finds the largest element of t
according to the Order
on a
.
Returns None
if t
is empty.
Optionally finds the largest element of t
according to the given comparator cmp
.
Returns None
if t
is empty.
Returns true
if and only if the element x
is in t
.
Optionally finds the smallest element of t
according to the Order
on a
.
Returns None
if t
is empty.
Optionally finds the smallest element of t
according to the given comparator cmp
.
Returns None
if t
is empty.
Optionally applies f
to all elements in t
going from left to right until a single value is obtained.
Returns None
if t
is empty.
Optionally applies f
to all elements in t
going from right to left until a single value is obtained.
Returns None
if t
is empty.
Returns the sum of all elements in t
.
Returns the sum of all elements in t
according to the function f
.
Returns the longest prefix of t
that satisfies the predicate f
.
Returns an immutable list.
Returns t
as an array.
Returns t
as a chain.
Returns t
as a DelayList
.
Returns t
as a DelayMap
Returns t
as an immutable list.
Returns t
as a map.
Returns a map with elements of s
as keys and f
applied as values.
Returns t
as a MutDeque
.
Returns t
as a mutable list.
Returns t
as a MutMap
.
Returns the set s
as a MutSet
.
Optionally returns t
as a non empty chain.
Optionally returns t
as a non empty list.
Returns t
as a set.
Returns t
as a vector.
Instances
class FromString [a : Type]
A type class for types that can be constructed from strings.
Signatures
class Functor [m : Type -> Type]
A type class for types that can be mapped over.
Signatures
Instances
class Group [a : Type] with Monoid[a]
A type class for types that form a group.
The default instances for numbers define the additive inverse in the real numbers.
Signatures
Returns the inverse element of x
.
Definitions
Instances
class Hash [a : Type]
A type class for types that can be hashed.
Signatures
Instances
class Iterable [t : Type -> Type]
A type class for immutable data structures that can be iterated.
Signatures
Definitions
class JoinLattice [a : Type] with PartialOrder[a]
Signatures
Instances
class LowerBound [a : Type]
A type class for partially ordered types that have a lower bound.
Signatures
Instances
class MeetLattice [a : Type] with PartialOrder[a]
Signatures
Instances
class Monad [m : Type -> Type] with Applicative[m]
A type class for applicatives that support monadic bind (flatMap
), i.e., allow to apply a function
that takes a normal value and produces a monadic value to a monadic value. That is, the bind mechanism
supports extraction of monadic values, or, viewed differently, allows to combine (flatten) nested
monadic values (flapMap
can be understood as a Functor.map
followed by a flatten
).
Signatures
class MonadZero [m : Type -> Type] with Monad[m]
A type class for Monads that have a zero element.
Signatures
class MonadZip [m : Type -> Type] with Monad[m]
A type class for zipping Monads, typically container monads like List
.
A minimal implementation must define zipWith
and zipWithA
.
Signatures
Generalized version of zipWith
where f
zips an applicative functor across the
(monadic) containers ma
and mb
.
Definitions
Returns a pair of monads, the first containing the element (or elements) of the left part of mx
the second containing the element (or elements) of the right part of mx
.
class Monoid [a : Type] with SemiGroup[a]
A type class for Monoids, objects that support an associative binary
operation combine
and neutral element empty
.
Signatures
Definitions
Instances
class Mul [a : Type]
A type class for multiplication.
Signatures
class Neg [a : Type]
A type class for negation.
Signatures
class Order [a : Type] with Eq[a]
Signatures
Definitions
Returns true
if and only if x > y
.
Returns true
if and only if x >= y
.
Returns true
if and only if x <= y
.
Returns the maximum of x
and y
.
Returns the minimum of x
and y
.
Instances
class PartialOrder [a : Type]
Signatures
Instances
class Reducible [t : Type -> Type]
A type class for types that can be reduced to a summary value.
Reducible
is like a non-empty Foldable
and may only be implemented on non-empty data structures.
Signatures
Definitions
Returns the number of elements in t
that satisfy the predicate f
.
Returns t
as a list without the longest prefix that satisfies the predicate f
.
Returns true
if and only if at least one element in t
satisfies the predicate f
.
Alias for findLeft
.
Optionally returns the first element of t
that satisfies the predicate f
when searching from left to right.
Optionally returns the first element of t
that satisfies the predicate f
when searching from left to right.
Optionally returns the first element of t
that satisfies the predicate f
when searching from right to left.
Alias for reduce
.
Reduce t
using the derived SemiGroup
instance.
Left-associative fold of a structure.
Applies f
to a start value s
and all elements in t
going from left to right.
Right-associative fold of a structure.
Applies f
to a start value s
and all elements in t
going from right to left.
Right-associative fold of a structure.
Applies f
to a start value s
and all elements in t
going from right to left.
A foldRightWithCont
allows early termination by not calling the continuation.
Returns true
if and only if all elements in t
satisfy the predicate f
.
Applies f
to each element in t
.
Returns the first element of t
.
Returns t
as a list without the last element.
Returns t
as a list with a
inserted between every two adjacent elements.
Returns the last element of t
.
Returns the number of elements in t
.
Finds the largest element of t
according to the Order
on a
.
Finds the largest element of t
according to the given comparator cmp
.
Returns true
if and only if the element a
is in t
.
Finds the smallest element of t
according to the Order
on a
.
Finds the smallest element of t
according to the given comparator cmp
.
Reduce t
using the derived SemiGroup
instance.
Applies f
to each element of t
and combines them using the derived SemiGroup
instance.
Right-associative reduction on t
using f
.
Returns the reverse of t
as a list.
Returns the sum of all elements in t
.
Returns the sum of all elements in t
according to the function f
.
Returns the tail of t
as a list.
Returns the longest prefix of t
as a list that satisfies the predicate f
.
Returns t
as an array.
Returns t
as a list.
Returns t
as a map.
Returns t
as a non-empty list.
Returns t
as a set.
Returns t
as a vector.
class SemiGroup [a : Type]
A type class for types that form a semigroup.
Signatures
Definitions
Instances
class Sendable [a : Type]
A type class for types that can be passed to Channel.send
.
Instances
class Sub [a : Type]
A type class for subtraction.
Signatures
class ToJava [t : Type]
A type class for marshaling values to Java.
Signatures
class ToString [a : Type]
A type class for types that can be converted to strings.
Signatures
Instances
class Traversable [t : Type -> Type] with Functor[t] Foldable[t]
A type class for data structures that can be traversed in left-to-right order with an applicative functor.
Signatures
Definitions
Returns the result of running all the actions in the data structure t
.
class UnorderedFoldable [t : Type -> Type]
A type class for unordered data structures that can be folded.
Signatures
Definitions
Returns the number of elements in t
that satisfy the predicate f
.
Returns true
if and only if at least one element in t
satisfies the predicate f
.
Returns false
if t
is empty.
Returns the result of applying CommutativeMonoid.combine
to all the elements in t
.
Returns true
if and only if all elements in t
satisfy the predicate f
.
Returns true
if t
is empty.
Returns true if and only if t
is empty.
Returns true
if and only if the element x
is in t
.
Returns the number of elements in t
.
class UpperBound [a : Type]
A type class for partially ordered types that have an upper bound.
Signatures
Instances
class Witherable [t : Type -> Type] with Traversable[t] Filterable[t]
A type class for data structures that can be traversed in left-to-right order with an applicative partial functor.
Definitions
Enums
enum Benchmark
SourceA benchmark has a name and a function to execute. The function is always impure since timing is considered a side-effect in this context.
enum Boxed with Sendable
SourceRepresents a boxed value.
enum Chain [t : Type] with Sendable
SourceThe Chain type.
A chain is a list represented as an unbalanced binary tree. It supports efficient append and "snoc" - appending elements at the tail of the list.
Note - the constructors Empty
, One
and Chain
should not be used directly.
enum Comparison with EqToStringSendable
Sourceenum DelayList [a : Type] with Sendable
Sourceenum DelayMap [k : Typev : Type] with Sendable
Sourceenum Down [a : Type] with Sendable
SourceThe Down
type allows you to reverse the sort order of a
conveniently.
enum Identity [a : Type] with EqOrderToStringHashSendable
SourceThe Identity Functor / Monad.
enum Iterator [a : Typeef : Effr : Eff]
Sourceenum List [t : Type] with Sendable
SourceThe List type.
A list is either the empty list represented by Nil
, or
an element v
followed by a list vs
represented by v :: vs
.
enum Map [k : Typev : Type] with Sendable
SourceThe Map type.
A map is currently represented internally as a red-black tree.
enum MultiMap [k : Typev : Type] with Sendable
SourceThe MultiMap type.
A MultiMap is a Map that allows multiple values for a key. Multiple values are stored in a Set so duplicates are not allowed.
The key and value types must implement the Eq and Order type classes.
enum MutDeque [a : Typer : Eff]
SourceRepresents a mutable deque.
Explanation of component types (from left to right): The 1st component is a reference the backing array. The 2nd component is a reference to the front index. The 3rd component is a reference to the back index.
If front == back then the deque is empty. Otherwise, the front index always points to an element (going counter-clockwise) and the back index always points to the first empty index (going clockwise).
enum MutList [a : Typer : Eff]
SourceRepresents a mutable list.
Invariant
- The length is always higher than the total capacity of the array.
- The capacity of the array is always 8 or more.
enum MutMap [k : Typev : Typer : Eff]
SourceThe Mutable Map type.
enum MutPriorityQueue [a : Typer : Eff]
SourceRepresents a mutable priority queue. Explanation of component types (left to right): Component 1: The region capability the queue is associated with. Component 2: A reference to the backing array. Component 3: A reference to the number of elements in the mutable priority queue.
The maximum element (if it exists) can always be accessed in constant time.
enum Nec [t : Type] with Sendable
SourceThe NonEmpty Chain type.
A chain is a list represented as an unbalanced binary tree. It supports efficient append and "snoc" - appending elements at the tail of the list.
Note - the constructors NecOne
and Nec
should not be used directly.
enum Option [t : Type] with EqOrderToStringSendable
SourceThe Option type.
An option represents an optional value.
The constructor None
represents an absent value,
whereas the constructor Some(v)
represents the value v
.
enum Proxy [_ : Type]
Sourceenum RedBlackTree [k : Typev : Type] with Sendable
SourceAn immutable red-black tree implementation with keys
of type k
and values of type v
.
A red-black tree is a self-balancing binary search tree. Each node is either red or black, although a transitory color double-black is allowed during deletion. The red-black tree satisfy the following invariants.
- For all nodes with key
x
, the left subtree contains only nodes with keysy
<x
and the right subtree contains only nodes with keysz
>x
. - No red node has a red parent.
- Every path from the root to a leaf contains the same number of black nodes.
enum Result [e : Typet : Type] with EqOrderToStringSendable
SourceThe Result type.
A result represents a successful value or an error value.
The constructor Ok(v)
represents the successful value v
,
whereas the constructor Err(v)
represents the error value v
.
enum Set [t : Type] with Sendable
SourceThe Set type.
A set is currently represented internally as a red-black tree.
enum Validation [e : Typet : Type] with EqOrderToStringSendable
SourceThe Validation type.
enum Void
SourceThe empty type.
Type Aliases
type alias Static = IO
SourceStatic is a type alias for false and denotes the global lifetime.
Definitions
def
!>
[aef]
(
x :
a
f :
a -> Unit \ ef
)
: a
\ ef
Pipes the given value x
into the function f
.
Given a value x
and a function f
returns x
.
def
++
[a]
(
x :
a
y :
a
)
: a
\ Pure
with
SemiGroup[a]
Alias for SemiGroup.combine
.
def
>>
[aef1bef2c]
(
f :
a -> b \ ef1
g :
b -> c \ ef2
)
: a -> c \ ef1 + ef2
\ Pure
Forwards function composition. Applies the function on the left first.
Given the functions f: a -> b
and g: b -> c
returns a function a -> c
def
bug!
[a]
(
m :
String
)
: a
\ Pure
Crashes the current process with the given message m
.
def
constant
[abef]
(
x :
a
)
: b -> a \ ef
\ Pure
The constant function.
def
debug
[a]
(
x :
a
)
: a
\ Pure
Prints the stringified representation of x
.
WARNING: The debug function is pure hence if the result is unused it may be removed by the compiler!
def
debug!
[a]
(
x :
a
)
: a
\ Pure
Prints the stringified representation of x
.
WARNING: The debug function is pure hence if the result is unused it may be removed by the compiler!
def
debug!!
[a]
(
x :
a
)
: a
\ Pure
Prints the stringified representation of x
.
WARNING: The debug function is pure hence if the result is unused it may be removed by the compiler!
def
flip
[abefc]
(
f :
a -> (b -> c \ ef)
)
: b -> (a -> c \ ef)
\ Pure
Returns the function f
with input arguments swapped.
That is, given the function f: (a, b) -> c
, returns a function (b, a) -> c
def
fst
[ab]
(
p :
(a, b)
)
: a
\ Pure
Returns the first component of t
.
def
identity
[aef]
(
x :
a
)
: a
\ ef
def
on
[bef1caef2]
(
f :
b -> (b -> c \ ef1)
g :
a -> b \ ef2
x :
a
y :
a
)
: c
\ ef1 + ef2
Partially applying this function in the form f `on` g
lifts the binary function f
to work on
inputs transformed by g
.
def
println
[a]
(
x :
a
)
: Unit
\ IO
with
ToString[a]
Converts x
to a string and prints it to standard out followed by a new line.
def
snd
[ab]
(
p :
(a, b)
)
: b
\ Pure
Returns the second component of t
.
def
swap
[ab]
(
p :
(a, b)
)
: (b, a)
\ Pure
Returns the pair p
with the components swapped.
That is, returns (y, x)
if p = (x, y)
.
def
touch
[r]
(
_ :
Region[r]
)
: Unit
\ r
Touches the given region capability rc
.
def
unreachable!
[a]
: a
\ Pure
Asserts that this expression is unreachable. Crashes if not.
def
|+|
[a]
(
x :
a
y :
a
)
: a
\ Pure
with
CommutativeSemiGroup[a]
Alias for CommutativeSemiGroup.combine
.
def
|>
[aefb]
(
x :
a
f :
a -> b \ ef
)
: b
\ ef
Pipes the given value x
into the function f
.
Given a value x
and a function f
returns f(x)
.
def
||>
[abefc]
(
x :
(a, b)
f :
a -> (b -> c \ ef)
)
: c
\ ef
Pipes the given pair x
into the function f
.
Given a pair x
and a function f
returns f(x)
.