optics

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package optics is an internal, see golem.optics for public api

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Morph

func Morph[S any](m Morphisms, s *S) error

func NewLens

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

NewLens creates lense instance

Types

type Lens

type Lens interface {
	FromString(string) (Value, error)
	Put(reflect.Value, Value) error
}

Lens is composable setter of Value to "some" struct

type Morphism

type Morphism struct {
	Lens
	Value
}

Morphism is product of Lens and Value

type Morphisms

type Morphisms []Morphism

Morphisms is collection of lenses and values to be applied for object

type Value

type Value struct {
	String string
	Number int
	Double float64
}

Value is co-product types matchable by patterns Note: do not extend the structure, optimal size for performance See https://goinbigdata.com/golang-pass-by-pointer-vs-pass-by-value/

Jump to

Keyboard shortcuts

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