Core Types
"I keep six honest serving-men: / (They taught me all I knew) / Their names are What and Where and When / And How and Why and Who."
— Rudyard Kipling, Just So Stories (The Elephant's Child)
Each family asks one of them of a value: what, if anything, it holds; why it failed; when it runs; where its settings come from; how many there are; or who runs it.
A core type holds a value, as Java's Optional does, and the library adds its own. Application code reaches most of them through an Effect Path, and generic code through type class instances; the Foundations introduction says which you are writing.
Read a page when a task needs its type, and skip the group until then. Choosing a Type and What each type supports help you choose.
Pages in this group
- Failure
- Either: A value, or the first typed error
- Validated: A value, or every error found, and Accumulating Assembly for records of validated fields
- Try: A value, or a caught exception
- EitherOrBoth: A value, an error, or a value with warnings
- NonEmptyList: A list with at least one element, such as errors
- Absence
- Deferred
- IO: A side effect described now and run later
- Lazy: A value worked out when first asked for, then kept
- CompletableFuture: Java's asynchronous result, already running
- Virtual threads
- VTask: A deferred task, which
runAsync,ParandScoperun on virtual threads, with Structured Concurrency and Resource Management - VStream: A stream that produces each element when pulled, with HKT and Type Classes, Parallel Operations, Performance, Resource-Safe Streaming and Advanced Features
- VTask: A deferred task, which
- Environment and state
- Collections
- Programs as data
- Identity: A value and nothing else, for generic code with no effect
- Trampoline: A recursion that runs without growing the stack
- Free: A program written as data, for an interpreter to run
- Free Applicative: Independent steps an interpreter can inspect before running them
- EitherF: Two instruction sets joined, so one program can use both
- Coyoneda: A
Functorfor any type, which joins itsmapcalls into one - Const: A value of its first type and none of its second, for folds and getters
Practise the core types together in Tutorial 07: Real World (6 exercises).
Previous: ForState Comprehension Next: Either