1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-11-23 22:14:53 +02:00

fix: document statereaderioeither

Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
Dr. Carsten Leue
2025-11-18 16:06:56 +01:00
parent 77dde302ef
commit 6d94697128
6 changed files with 1084 additions and 13 deletions

View File

@@ -29,17 +29,57 @@ import (
)
type (
Endomorphism[A any] = endomorphism.Endomorphism[A]
Lens[S, A any] = lens.Lens[S, A]
State[S, A any] = state.State[S, A]
Pair[L, R any] = pair.Pair[L, R]
Reader[R, A any] = reader.Reader[R, A]
Either[E, A any] = either.Either[E, A]
IO[A any] = io.IO[A]
IOEither[E, A any] = ioeither.IOEither[E, A]
ReaderIOEither[R, E, A any] = readerioeither.ReaderIOEither[R, E, A]
ReaderEither[R, E, A any] = readereither.ReaderEither[R, E, A]
// Endomorphism represents a function from A to A.
Endomorphism[A any] = endomorphism.Endomorphism[A]
// Lens is an optic that focuses on a field of type A within a structure of type S.
Lens[S, A any] = lens.Lens[S, A]
// State represents a stateful computation that takes an initial state S and returns
// a pair of the new state S and a value A.
State[S, A any] = state.State[S, A]
// Pair represents a tuple of two values.
Pair[L, R any] = pair.Pair[L, R]
// Reader represents a computation that depends on an environment/context of type R
// and produces a value of type A.
Reader[R, A any] = reader.Reader[R, A]
// Either represents a value that can be either a Left (error) or Right (success).
Either[E, A any] = either.Either[E, A]
// IO represents a computation that performs side effects and produces a value of type A.
IO[A any] = io.IO[A]
// IOEither represents a computation that performs side effects and can fail with an error E
// or succeed with a value A.
IOEither[E, A any] = ioeither.IOEither[E, A]
// ReaderIOEither represents a computation that depends on an environment R,
// performs side effects, and can fail with an error E or succeed with a value A.
ReaderIOEither[R, E, A any] = readerioeither.ReaderIOEither[R, E, A]
// ReaderEither represents a computation that depends on an environment R and can fail
// with an error E or succeed with a value A (without side effects).
ReaderEither[R, E, A any] = readereither.ReaderEither[R, E, A]
// StateReaderIOEither represents a stateful computation that:
// - Takes an initial state S
// - Depends on an environment/context R
// - Performs side effects (IO)
// - Can fail with an error E or succeed with a value A
// - Returns a pair of the new state S and the result
//
// This is the main type of this package, combining State, Reader, IO, and Either monads.
StateReaderIOEither[S, R, E, A any] = Reader[S, ReaderIOEither[R, E, Pair[S, A]]]
Kleisli[S, R, E, A, B any] = Reader[A, StateReaderIOEither[S, R, E, B]]
Operator[S, R, E, A, B any] = Reader[StateReaderIOEither[S, R, E, A], StateReaderIOEither[S, R, E, B]]
// Kleisli represents a Kleisli arrow - a function that takes a value A and returns
// a StateReaderIOEither computation producing B.
// This is used for monadic composition via Chain.
Kleisli[S, R, E, A, B any] = Reader[A, StateReaderIOEither[S, R, E, B]]
// Operator represents a function that transforms one StateReaderIOEither into another.
// This is commonly used for building composable operations via Map, Chain, etc.
Operator[S, R, E, A, B any] = Reader[StateReaderIOEither[S, R, E, A], StateReaderIOEither[S, R, E, B]]
)