Immutable Data
The bread-and-butter of functional programming is immutable data types.
We have already seen several examples of immutable data types:
In addition, The Flix standard library offers several immutable data types:
List[t]
: An immutable singly-linked list of elements of typet
.Chain[t]
: An immutable chain of elements of typet
with fast append.Vector[t]
: An immutable sequence of elements of typet
with fast lookup.Set[t]
: An immutable set of elements of typet
.Map[k, v]
: An immutable map of keys of typek
to values of typev
.
Other immutable data types include:
Option[t]
: A type that is eitherNone
orSome(t)
.Result[e, t]
: A type that is eitherOk(t)
orErr(e)
.Nel[t]
: An immutable non-empty singly-linked list of elements of typet
.Nec[t]
: An immutable non-empty sequence of elements of typet
that supports fast append.MultiMap[k, v]
: An immutable map of keys of typek
to sets of values of typev
.