generic

package
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package generic provides generic array operations for custom Reader types.

Code generated by go generate; DO NOT EDIT. This file was generated by robots at 2025-03-09 23:53:11.926993 +0100 CET m=+0.002100401

Package generic provides generic implementations of Reader operations that work with custom reader types. These functions use Go's type constraints to work with any type that matches the Reader pattern (func(R) A).

Most functions in this package are deprecated in favor of the non-generic versions in the parent reader package, which provide better type inference and simpler usage.

Use this package when you need to work with custom reader types or when you need explicit control over type parameters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ap deprecated

func Ap[GA ~func(R) A, GB ~func(R) B, GAB ~func(R) func(A) B, R, A, B any](fa GA) func(GAB) GB

Ap applies a function to an argument under a type constructor.

Deprecated:

func ApplicativeMonoid

func ApplicativeMonoid[GA ~func(R) A, R, A any](m M.Monoid[A]) M.Monoid[GA]

func Ask deprecated

func Ask[GR ~func(R) R, R any]() GR

Ask reads the current context

Deprecated:

func Asks deprecated

func Asks[GA ~func(R) A, R, A any](f GA) GA

Asks projects a value from the global context in a Reader

Deprecated:

func AsksReader deprecated

func AsksReader[GA ~func(R) A, R, A any](f func(R) GA) GA

Deprecated:

func Chain deprecated

func Chain[GA ~func(R) A, GB ~func(R) B, R, A, B any](f func(A) GB) func(GA) GB

Chain composes computations in sequence, using the return value of one computation to determine the next computation.

Deprecated:

func Compose deprecated

func Compose[AB ~func(A) B, BC ~func(B) C, AC ~func(A) C, A, B, C any](ab AB) func(BC) AC

Deprecated:

func Curry0

func Curry0[GA ~func(R) A, R, A any](f func(R) A) GA

Curry0 converts a function that takes a context and returns a value into a generic Reader.

Type Parameters:

  • GA: The generic Reader type (~func(R) A)
  • R: The environment/context type
  • A: The result type

func Curry1

func Curry1[GA ~func(R) A, R, T1, A any](f func(R, T1) A) func(T1) GA

Curry1 converts a function with context as first parameter into a curried function returning a generic Reader. The context parameter is moved to the end (Reader position).

Type Parameters:

  • GA: The generic Reader type (~func(R) A)
  • R: The environment/context type
  • T1: The first parameter type
  • A: The result type

func Curry2

func Curry2[GA ~func(R) A, R, T1, T2, A any](f func(R, T1, T2) A) func(T1) func(T2) GA

Curry2 converts a function with context as first parameter and 2 other parameters into a curried function returning a generic Reader.

Type Parameters:

  • GA: The generic Reader type (~func(R) A)
  • R: The environment/context type
  • T1, T2: The parameter types
  • A: The result type

func Curry3

func Curry3[GA ~func(R) A, R, T1, T2, T3, A any](f func(R, T1, T2, T3) A) func(T1) func(T2) func(T3) GA

Curry3 converts a function with context as first parameter and 3 other parameters into a curried function returning a generic Reader.

Type Parameters:

  • GA: The generic Reader type (~func(R) A)
  • R: The environment/context type
  • T1, T2, T3: The parameter types
  • A: The result type

func Curry4

func Curry4[GA ~func(R) A, R, T1, T2, T3, T4, A any](f func(R, T1, T2, T3, T4) A) func(T1) func(T2) func(T3) func(T4) GA

Curry4 converts a function with context as first parameter and 4 other parameters into a curried function returning a generic Reader.

Type Parameters:

  • GA: The generic Reader type (~func(R) A)
  • R: The environment/context type
  • T1, T2, T3, T4: The parameter types
  • A: The result type

func First deprecated

func First[GAB ~func(A) B, GABC ~func(T.Tuple2[A, C]) T.Tuple2[B, C], A, B, C any](pab GAB) GABC

Deprecated:

func Flap deprecated

func Flap[GAB ~func(R) func(A) B, GB ~func(R) B, R, A, B any](a A) func(GAB) GB

Deprecated:

func Flatten deprecated

func Flatten[GA ~func(R) A, GGA ~func(R) GA, R, A any](mma GGA) GA

Deprecated:

func From0

func From0[GRA ~func(C) R, F ~func(C) R, C, R any](f F) func() GRA

From0 converts a function with 1 parameters returning a [R] into a function with 0 parameters returning a [GRA] The first parameter is considered to be the context [C].

func From1

func From1[GRA ~func(C) R, F ~func(C, T0) R, T0, C, R any](f F) func(T0) GRA

From1 converts a function with 2 parameters returning a [R] into a function with 1 parameters returning a [GRA] The first parameter is considered to be the context [C].

func From10

func From10[GRA ~func(C) R, F ~func(C, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) R, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, C, R any](f F) func(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) GRA

From10 converts a function with 11 parameters returning a [R] into a function with 10 parameters returning a [GRA] The first parameter is considered to be the context [C].

func From2

func From2[GRA ~func(C) R, F ~func(C, T0, T1) R, T0, T1, C, R any](f F) func(T0, T1) GRA

From2 converts a function with 3 parameters returning a [R] into a function with 2 parameters returning a [GRA] The first parameter is considered to be the context [C].

func From3

func From3[GRA ~func(C) R, F ~func(C, T0, T1, T2) R, T0, T1, T2, C, R any](f F) func(T0, T1, T2) GRA

From3 converts a function with 4 parameters returning a [R] into a function with 3 parameters returning a [GRA] The first parameter is considered to be the context [C].

func From4

func From4[GRA ~func(C) R, F ~func(C, T0, T1, T2, T3) R, T0, T1, T2, T3, C, R any](f F) func(T0, T1, T2, T3) GRA

From4 converts a function with 5 parameters returning a [R] into a function with 4 parameters returning a [GRA] The first parameter is considered to be the context [C].

func From5

func From5[GRA ~func(C) R, F ~func(C, T0, T1, T2, T3, T4) R, T0, T1, T2, T3, T4, C, R any](f F) func(T0, T1, T2, T3, T4) GRA

From5 converts a function with 6 parameters returning a [R] into a function with 5 parameters returning a [GRA] The first parameter is considered to be the context [C].

func From6

func From6[GRA ~func(C) R, F ~func(C, T0, T1, T2, T3, T4, T5) R, T0, T1, T2, T3, T4, T5, C, R any](f F) func(T0, T1, T2, T3, T4, T5) GRA

From6 converts a function with 7 parameters returning a [R] into a function with 6 parameters returning a [GRA] The first parameter is considered to be the context [C].

func From7

func From7[GRA ~func(C) R, F ~func(C, T0, T1, T2, T3, T4, T5, T6) R, T0, T1, T2, T3, T4, T5, T6, C, R any](f F) func(T0, T1, T2, T3, T4, T5, T6) GRA

From7 converts a function with 8 parameters returning a [R] into a function with 7 parameters returning a [GRA] The first parameter is considered to be the context [C].

func From8

func From8[GRA ~func(C) R, F ~func(C, T0, T1, T2, T3, T4, T5, T6, T7) R, T0, T1, T2, T3, T4, T5, T6, T7, C, R any](f F) func(T0, T1, T2, T3, T4, T5, T6, T7) GRA

From8 converts a function with 9 parameters returning a [R] into a function with 8 parameters returning a [GRA] The first parameter is considered to be the context [C].

func From9

func From9[GRA ~func(C) R, F ~func(C, T0, T1, T2, T3, T4, T5, T6, T7, T8) R, T0, T1, T2, T3, T4, T5, T6, T7, T8, C, R any](f F) func(T0, T1, T2, T3, T4, T5, T6, T7, T8) GRA

From9 converts a function with 10 parameters returning a [R] into a function with 9 parameters returning a [GRA] The first parameter is considered to be the context [C].

func Local deprecated

func Local[GA1 ~func(R1) A, GA2 ~func(R2) A, R2, R1, A any](f func(R2) R1) func(GA1) GA2

Local changes the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s `contramap`).

Deprecated:

func MakeReader deprecated

func MakeReader[GA ~func(R) A, R, A any](r GA) GA

MakeReader creates a reader, i.e. a method that accepts a context and that returns a value

Deprecated:

func Map deprecated

func Map[GA ~func(E) A, GB ~func(E) B, E, A, B any](f func(A) B) func(GA) GB

Map can be used to turn functions `func(A)B` into functions `(fa F[A])F[B]` whose argument and return types use the type constructor `F` to represent some computational context.

Deprecated:

func MonadAp deprecated

func MonadAp[GA ~func(R) A, GB ~func(R) B, GAB ~func(R) func(A) B, R, A, B any](fab GAB, fa GA) GB

Deprecated:

func MonadChain deprecated

func MonadChain[GA ~func(R) A, GB ~func(R) B, R, A, B any](ma GA, f func(A) GB) GB

Deprecated:

func MonadFlap deprecated

func MonadFlap[GAB ~func(R) func(A) B, GB ~func(R) B, R, A, B any](fab GAB, a A) GB

Deprecated:

func MonadMap deprecated

func MonadMap[GA ~func(E) A, GB ~func(E) B, E, A, B any](fa GA, f func(A) B) GB

Deprecated:

func MonadTraverseArray

func MonadTraverseArray[GB ~func(R) B, GBS ~func(R) BBS, AAS ~[]A, BBS ~[]B, R, A, B any](tas AAS, f func(A) GB) GBS

MonadTraverseArray transforms each element of an array using a function that returns a generic Reader, then collects the results into a single generic Reader containing an array. This is the monadic version that takes the array as the first parameter.

This generic version works with custom reader types that match the pattern ~func(R) B.

Type Parameters:

  • GB: The generic Reader type for individual elements (~func(R) B)
  • GBS: The generic Reader type for the result array (~func(R) BBS)
  • AAS: The input array type (~[]A)
  • BBS: The output array type (~[]B)
  • R: The environment/context type
  • A: The input element type
  • B: The output element type

func Of deprecated

func Of[GA ~func(R) A, R, A any](a A) GA

Deprecated:

func Promap deprecated

func Promap[GA ~func(E) A, GB ~func(D) B, E, A, D, B any](f func(D) E, g func(A) B) func(GA) GB

Deprecated:

func Second deprecated

func Second[GBC ~func(B) C, GABC ~func(T.Tuple2[A, B]) T.Tuple2[A, C], A, B, C any](pbc GBC) GABC

Deprecated:

func SequenceArray

func SequenceArray[GA ~func(R) A, GAS ~func(R) AAS, AAS ~[]A, GAAS ~[]GA, R, A any](ma GAAS) GAS

SequenceArray converts an array of generic Readers into a single generic Reader containing an array. All Readers in the input array share the same environment and are evaluated with it.

This generic version works with custom reader types that match the pattern ~func(R) A.

Type Parameters:

  • GA: The generic Reader type for individual elements (~func(R) A)
  • GAS: The generic Reader type for the result array (~func(R) AAS)
  • AAS: The array type (~[]A)
  • GAAS: The input array of Readers type (~[]GA)
  • R: The environment/context type
  • A: The element type

func SequenceT1

func SequenceT1[GA ~func(R) A, GTA ~func(R) T.Tuple1[A], R, A any](a GA) GTA

SequenceT1 combines 1 generic Reader into a generic Reader of a 1-tuple.

Type Parameters:

  • GA: The generic Reader type for the input (~func(R) A)
  • GTA: The generic Reader type for the tuple result (~func(R) T.Tuple1[A])
  • R: The environment/context type
  • A: The result type

func SequenceT2

func SequenceT2[GA ~func(R) A, GB ~func(R) B, GTAB ~func(R) T.Tuple2[A, B], R, A, B any](a GA, b GB) GTAB

SequenceT2 combines 2 generic Readers into a generic Reader of a 2-tuple. All Readers share the same environment and are evaluated with it.

Type Parameters:

  • GA, GB: The generic Reader types for the inputs (~func(R) A, ~func(R) B)
  • GTAB: The generic Reader type for the tuple result (~func(R) T.Tuple2[A, B])
  • R: The environment/context type
  • A, B: The result types

func SequenceT3

func SequenceT3[GA ~func(R) A, GB ~func(R) B, GC ~func(R) C, GTABC ~func(R) T.Tuple3[A, B, C], R, A, B, C any](a GA, b GB, c GC) GTABC

SequenceT3 combines 3 generic Readers into a generic Reader of a 3-tuple. All Readers share the same environment and are evaluated with it.

Type Parameters:

  • GA, GB, GC: The generic Reader types for the inputs
  • GTABC: The generic Reader type for the tuple result (~func(R) T.Tuple3[A, B, C])
  • R: The environment/context type
  • A, B, C: The result types

func SequenceT4

func SequenceT4[GA ~func(R) A, GB ~func(R) B, GC ~func(R) C, GD ~func(R) D, GTABCD ~func(R) T.Tuple4[A, B, C, D], R, A, B, C, D any](a GA, b GB, c GC, d GD) GTABCD

SequenceT4 combines 4 generic Readers into a generic Reader of a 4-tuple. All Readers share the same environment and are evaluated with it.

Type Parameters:

  • GA, GB, GC, GD: The generic Reader types for the inputs
  • GTABCD: The generic Reader type for the tuple result (~func(R) T.Tuple4[A, B, C, D])
  • R: The environment/context type
  • A, B, C, D: The result types

func TraverseArray

func TraverseArray[GB ~func(R) B, GBS ~func(R) BBS, AAS ~[]A, BBS ~[]B, R, A, B any](f func(A) GB) func(AAS) GBS

TraverseArray transforms each element of an array using a function that returns a generic Reader, then collects the results into a single generic Reader containing an array.

This generic version works with custom reader types that match the pattern ~func(R) B.

Type Parameters:

  • GB: The generic Reader type for individual elements (~func(R) B)
  • GBS: The generic Reader type for the result array (~func(R) BBS)
  • AAS: The input array type (~[]A)
  • BBS: The output array type (~[]B)
  • R: The environment/context type
  • A: The input element type
  • B: The output element type

func TraverseArrayWithIndex

func TraverseArrayWithIndex[GB ~func(R) B, GBS ~func(R) BBS, AAS ~[]A, BBS ~[]B, R, A, B any](f func(int, A) GB) func(AAS) GBS

TraverseArrayWithIndex transforms each element of an array using a function that takes both the index and the element, returning a generic Reader. The results are collected into a single generic Reader containing an array.

This generic version works with custom reader types that match the pattern ~func(R) B.

Type Parameters:

  • GB: The generic Reader type for individual elements (~func(R) B)
  • GBS: The generic Reader type for the result array (~func(R) BBS)
  • AAS: The input array type (~[]A)
  • BBS: The output array type (~[]B)
  • R: The environment/context type
  • A: The input element type
  • B: The output element type

func Uncurry0

func Uncurry0[GA ~func(R) A, R, A any](f GA) func(R) A

Uncurry0 converts a generic Reader back into a regular function with context as first parameter.

Type Parameters:

  • GA: The generic Reader type (~func(R) A)
  • R: The environment/context type
  • A: The result type

func Uncurry1

func Uncurry1[GA ~func(R) A, R, T1, A any](f func(T1) GA) func(R, T1) A

Uncurry1 converts a curried function returning a generic Reader back into a regular function with context as first parameter.

Type Parameters:

  • GA: The generic Reader type (~func(R) A)
  • R: The environment/context type
  • T1: The first parameter type
  • A: The result type

func Uncurry2

func Uncurry2[GA ~func(R) A, R, T1, T2, A any](f func(T1) func(T2) GA) func(R, T1, T2) A

Uncurry2 converts a curried function with 2 parameters returning a generic Reader back into a regular function with context as first parameter.

Type Parameters:

  • GA: The generic Reader type (~func(R) A)
  • R: The environment/context type
  • T1, T2: The parameter types
  • A: The result type

func Uncurry3

func Uncurry3[GA ~func(R) A, R, T1, T2, T3, A any](f func(T1) func(T2) func(T3) GA) func(R, T1, T2, T3) A

Uncurry3 converts a curried function with 3 parameters returning a generic Reader back into a regular function with context as first parameter.

Type Parameters:

  • GA: The generic Reader type (~func(R) A)
  • R: The environment/context type
  • T1, T2, T3: The parameter types
  • A: The result type

func Uncurry4

func Uncurry4[GA ~func(R) A, R, T1, T2, T3, T4, A any](f func(T1) func(T2) func(T3) func(T4) GA) func(R, T1, T2, T3, T4) A

Uncurry4 converts a curried function with 4 parameters returning a generic Reader back into a regular function with context as first parameter.

Type Parameters:

  • GA: The generic Reader type (~func(R) A)
  • R: The environment/context type
  • T1, T2, T3, T4: The parameter types
  • A: The result type

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL