iso

package
v1.0.58 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: Apache-2.0 Imports: 1 Imported by: 1

Documentation

Overview

Iso is an optic which converts elements of type `S` into elements of type `A` without loss.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compose

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

Compose combines an ISO with another ISO

func From

func From[S, A any](a A) func(Iso[S, A]) S

To unwraps the value

func IMap

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

IMap implements a bidirectional mapping of the transform

func Modify

func Modify[S, A any](f func(A) A) func(Iso[S, A]) func(S) S

Modify applies a transformation

func To

func To[A, S any](s S) func(Iso[S, A]) A

From wraps the value

func Unwrap

func Unwrap[A, S any](s S) func(Iso[S, A]) A

Wrap wraps the value

func Wrap

func Wrap[S, A any](a A) func(Iso[S, A]) S

Unwrap unwraps the value

Types

type Iso

type Iso[S, A any] struct {
	Get        func(s S) A
	ReverseGet func(a A) S
}

func Id

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

Id returns an iso implementing the identity operation

func MakeIso

func MakeIso[S, A any](get func(S) A, reverse func(A) S) Iso[S, A]

func Reverse

func Reverse[S, A any](sa Iso[S, A]) Iso[A, S]

Reverse changes the order of parameters for an iso

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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