traversable

package
v2.13.3 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComposeTraverse

func ComposeTraverse[
	A,
	B,
	HKT_F_B,
	HKT_G_A,
	HKT_G_B,
	HKT_T_G_A,
	HKT_T_G_B,
	HKT_F_G_B,
	HKT_F_T_G_B,
	HKT_F_T_A_B any](
	t TraverseType[HKT_G_A, HKT_G_B, HKT_T_G_A, HKT_T_G_B, HKT_F_G_B, HKT_F_T_G_B, HKT_F_T_A_B],
	g TraverseType[A, B, HKT_G_A, HKT_G_B, HKT_F_B, HKT_F_G_B, HKT_F_T_A_B],
) func(

	f_of pointed.OfType[HKT_T_G_B, HKT_F_T_G_B],
	f_map functor.MapType[HKT_T_G_B, func(HKT_G_B) HKT_T_G_B, HKT_F_T_G_B, HKT_F_T_A_B],
	f_ap apply.ApType[HKT_F_G_B, HKT_F_T_G_B, HKT_F_T_A_B],

	g_of pointed.OfType[HKT_G_B, HKT_F_G_B],
	g_map functor.MapType[HKT_G_B, func(B) HKT_G_B, HKT_F_G_B, HKT_F_T_A_B],
	g_ap apply.ApType[HKT_F_B, HKT_F_G_B, HKT_F_T_A_B],
) func(func(A) HKT_F_B) func(HKT_T_G_A) HKT_F_T_G_B

Types

type Applicative

type Applicative[A, B, HKT_A, HKT_B, HKT_AB any] = applicative.Applicative[A, B, HKT_A, HKT_B, HKT_AB]

type Functor

type Functor[A, B, HKT_A, HKT_B any] = functor.Functor[A, B, HKT_A, HKT_B]

type Pointed

type Pointed[A, HKT_A any] = pointed.Pointed[A, HKT_A]

type SequenceType

type SequenceType[
	HKT_T_F_A,
	HKT_F_T_A any] = func(

	f_of pointed.OfType[HKT_T_F_A, HKT_F_T_A],
	f_map functor.MapType[HKT_T_F_A, func(HKT_T_F_A) HKT_T_F_A, HKT_F_T_A, HKT_T_F_A],
	f_ap apply.ApType[HKT_T_F_A, HKT_F_T_A, HKT_T_F_A],
) func(HKT_T_F_A) HKT_F_T_A

func SequenceFromTraverse

func SequenceFromTraverse[
	A, HKT_T_A, HKT_F_B, HKT_F_T_B any](
	t TraverseType[HKT_T_A, HKT_T_A, HKT_T_A, HKT_T_A, HKT_T_A, HKT_F_T_B, HKT_T_A],
) SequenceType[HKT_T_A, HKT_F_T_B]

type Traversable added in v2.3.9

type Traversable[A, HKT_F_B, HKT_T_A, HKT_F_T_B any] = func(func(A) HKT_F_B) func(HKT_T_A) HKT_F_T_B

Traversable is a type class that represents data structures that can be traversed from left to right, Example: A - item type HKT_F_B = F[B] HKT_T_A = []A HKT_F_T_B = F[[]B]

func ComposeTraversables added in v2.3.15

func ComposeTraversables[A, HKT_F_B, HKT_T_A, HKT_F_T_B, HKT_T_G_A, HKT_F_T_G_B any](
	outer Traversable[HKT_T_A, HKT_F_T_B, HKT_T_G_A, HKT_F_T_G_B],
	inner Traversable[A, HKT_F_B, HKT_T_A, HKT_F_T_B],
) Traversable[A, HKT_F_B, HKT_T_G_A, HKT_F_T_G_B]

ComposeTraversables combines two Traversable instances into a single Traversable for their composition T[G[_]], where T is the outer traversable and G is the inner traversable.

This implements the standard result that the composition of two traversable functors is itself traversable: given a way to traverse T and a way to traverse G, we can traverse T[G[_]] by first using G's traverse to lift the mapping function inside the inner container, then using T's traverse to sequence those effects across the outer container.

Type parameters (using Array as T and Option as G for concreteness):

  • A — the item type inside the inner container, e.g. string
  • HKT_F_B — the applicative effect applied to B, e.g. IO[int]
  • HKT_T_A — the inner container G applied to A, e.g. Option[string]
  • HKT_F_T_B — the applicative effect applied to G[B], e.g. IO[Option[int]]
  • HKT_T_G_A — the outer container T applied to G[A], e.g. []Option[string]
  • HKT_F_T_G_B — the applicative effect applied to T[G[B]], e.g. IO[[]Option[int]]

Parameters:

  • outer — traverse for T with G[A] as element type: (Option[A] → IO[Option[B]]) → []Option[A] → IO[[]Option[B]]
  • inner — traverse for G over items of type A: (A → IO[B]) → Option[A] → IO[Option[B]]

Returns a Traversable for the composed structure T[G[_]]:

(A → IO[B]) → []Option[A] → IO[[]Option[B]]

Example (Array outer, Option inner, IO effect):

traverse := ComposeTraversables(
    array.MakeTraversable[Option[string], Option[int], IO[Option[int]], IO[[]Option[int]]](),
    option.MakeTraversable[string, int, IO[int], IO[Option[int]]](),
)
// traverse : func(func(string) IO[int]) func([]Option[string]) IO[[]Option[int]]

type TraverseType

type TraverseType[A, B, HKT_T_A, HKT_T_B, HKT_F_B, HKT_F_T_B, HKT_F_T_A_B any] = func(

	f_of pointed.OfType[HKT_T_B, HKT_F_T_B],
	f_map functor.MapType[HKT_T_B, func(B) HKT_T_B, HKT_F_T_B, HKT_F_T_A_B],
	f_ap apply.ApType[HKT_F_B, HKT_F_T_B, HKT_F_T_A_B],

) func(func(A) HKT_F_B) func(HKT_T_A) HKT_F_T_B

Jump to

Keyboard shortcuts

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