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 type- t.
- Chain[t]: An immutable chain of elements of type- twith fast append.
- Vector[t]: An immutable sequence of elements of type- twith fast lookup.
- Set[t]: An immutable set of elements of type- t.
- Map[k, v]: An immutable map of keys of type- kto values of type- v.
Other immutable data types include:
- Option[t]: A type that is either- Noneor- Some(t).
- Result[e, t]: A type that is either- Ok(t)or- Err(e).
- Nel[t]: An immutable non-empty singly-linked list of elements of type- t.
- Nec[t]: An immutable non-empty sequence of elements of type- tthat supports fast append.
- MultiMap[k, v]: An immutable map of keys of type- kto sets of values of type- v.