prism

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Prism is an optic used to select part of a sum type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsTraversal

func AsTraversal[R ~func(func(A) HKTA) func(S) HKTS, S, A, HKTS, HKTA any](
	fof func(S) HKTS,
	fmap func(HKTA, func(A) S) HKTS,
) func(Prism[S, A]) R

AsTraversal converts a prism to a traversal

func Compose

func Compose[S, A, B any](ab Prism[A, B]) func(Prism[S, A]) Prism[S, B]

Compose composes a `Prism` with a `Prism`.

func IMap

func IMap[S, A, B any](ab func(A) B, ba func(B) A) func(Prism[S, A]) Prism[S, B]

func Set

func Set[S, A any](a A) func(Prism[S, A]) func(S) S

Types

type Prism

type Prism[S, A any] interface {
	GetOption(s S) O.Option[A]
	ReverseGet(a A) S
}

Prism is an optic used to select part of a sum type.

func FromPredicate

func FromPredicate[S any](pred func(S) bool) Prism[S, S]

func Id

func Id[S any]() Prism[S, S]

Id returns a prism implementing the identity operation

func MakePrism

func MakePrism[S, A any](get func(S) O.Option[A], rev func(A) S) Prism[S, A]

func Some

func Some[S, A any](soa Prism[S, O.Option[A]]) Prism[S, A]

Some returns a `Prism` from a `Prism` focused on the `Some` of a `Option` type.

Jump to

Keyboard shortcuts

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