optics

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2023 License: MIT Imports: 3 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForProduct2

func ForProduct2[T, A, B any](attr ...string) (
	Lens[T, A],
	Lens[T, B],
)

ForProduct2 unfold 2 attribute of type

func ForProduct3

func ForProduct3[T, A, B, C any](attr ...string) (
	Lens[T, A],
	Lens[T, B],
	Lens[T, C],
)

func ForProduct4

func ForProduct4[T, A, B, C, D any](attr ...string) (
	Lens[T, A],
	Lens[T, B],
	Lens[T, C],
	Lens[T, D],
)

func ForProduct5

func ForProduct5[T, A, B, C, D, E any](attr ...string) (
	Lens[T, A],
	Lens[T, B],
	Lens[T, C],
	Lens[T, D],
	Lens[T, E],
)

func ForProduct6

func ForProduct6[T, A, B, C, D, E, F any](attr ...string) (
	Lens[T, A],
	Lens[T, B],
	Lens[T, C],
	Lens[T, D],
	Lens[T, E],
	Lens[T, F],
)

func ForProduct7

func ForProduct7[T, A, B, C, D, E, F, G any](attr ...string) (
	Lens[T, A],
	Lens[T, B],
	Lens[T, C],
	Lens[T, D],
	Lens[T, E],
	Lens[T, F],
	Lens[T, G],
)

func ForProduct8

func ForProduct8[T, A, B, C, D, E, F, G, H any](attr ...string) (
	Lens[T, A],
	Lens[T, B],
	Lens[T, C],
	Lens[T, D],
	Lens[T, E],
	Lens[T, F],
	Lens[T, G],
	Lens[T, H],
)

func ForProduct9

func ForProduct9[T, A, B, C, D, E, F, G, H, I any](attr ...string) (
	Lens[T, A],
	Lens[T, B],
	Lens[T, C],
	Lens[T, D],
	Lens[T, E],
	Lens[T, F],
	Lens[T, G],
	Lens[T, H],
	Lens[T, I],
)

Types

type Lens

type Lens[S, A any] interface {
	Get(*S) A
	Put(*S, A) error
}

Lens resembles concept of getters and setters, which you can compose using functional concepts. In other words, this is combinator data transformation for pure functional data structure.

func ForProduct1

func ForProduct1[T, A any](attr ...string) Lens[T, A]

ForProduct1 unfold 1 attribute of type

func NewLens added in v0.9.1

func NewLens[S, A any](t hseq.Type[S]) Lens[S, A]

NewLens instantiates a typed Lens[S, A] for hseq.Type[S]

func NewLensStruct added in v0.9.1

func NewLensStruct[S, A any](t hseq.Type[S]) Lens[S, A]

func NewLensStructFloat64 added in v0.9.1

func NewLensStructFloat64[S any](t hseq.Type[S]) Lens[S, float64]

func NewLensStructInt added in v0.9.1

func NewLensStructInt[S any](t hseq.Type[S]) Lens[S, int]

func NewLensStructString added in v0.9.1

func NewLensStructString[S any](t hseq.Type[S]) Lens[S, string]

type Morphism

type Morphism[S any] interface {
	Put(*S) error
	PutValue(reflect.Value) error
}

Morphism[S] is Len[S, A] composed with the value A

func Morph

func Morph[S, A any](lens Lens[S, A], a A) Morphism[S]

Morph composes Lens[S, A] with the value A

type Morphisms

type Morphisms[S any] []Morphism[S]

Morphisms[S] is an ordered set of morphisms applied to S

func (Morphisms[S]) Put

func (m Morphisms[S]) Put(s *S) error

type Reflector added in v0.8.4

type Reflector[A any] interface {
	GetValue(reflect.Value) A
	PutValue(reflect.Value, A) error
}

Reflector is a Lens over reflect.Value

Directories

Path Synopsis
examples module

Jump to

Keyboard shortcuts

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