1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-11-23 22:14:53 +02:00
Files
fp-go/v2/samples/lens/gen_lens.go

461 lines
15 KiB
Go
Raw Normal View History

package lens
// Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at
// 2025-11-13 09:05:02.7405925 +0100 CET m=+0.003158301
import (
IO "github.com/IBM/fp-go/v2/optics/iso/option"
L "github.com/IBM/fp-go/v2/optics/lens"
LO "github.com/IBM/fp-go/v2/optics/lens/option"
option "github.com/IBM/fp-go/v2/optics/lens/option"
)
// PersonLenses provides lenses for accessing fields of Person
type PersonLenses struct {
// mandatory fields
Name L.Lens[Person, string]
Age L.Lens[Person, int]
Email L.Lens[Person, string]
Phone L.Lens[Person, *string]
// optional fields
NameO LO.LensO[Person, string]
AgeO LO.LensO[Person, int]
EmailO LO.LensO[Person, string]
PhoneO LO.LensO[Person, *string]
}
// PersonRefLenses provides lenses for accessing fields of Person via a reference to Person
type PersonRefLenses struct {
// mandatory fields
Name L.Lens[*Person, string]
Age L.Lens[*Person, int]
Email L.Lens[*Person, string]
Phone L.Lens[*Person, *string]
// optional fields
NameO LO.LensO[*Person, string]
AgeO LO.LensO[*Person, int]
EmailO LO.LensO[*Person, string]
PhoneO LO.LensO[*Person, *string]
}
// MakePersonLenses creates a new PersonLenses with lenses for all fields
func MakePersonLenses() PersonLenses {
// mandatory lenses
lensName := L.MakeLens(
func(s Person) string { return s.Name },
func(s Person, v string) Person { s.Name = v; return s },
)
lensAge := L.MakeLens(
func(s Person) int { return s.Age },
func(s Person, v int) Person { s.Age = v; return s },
)
lensEmail := L.MakeLens(
func(s Person) string { return s.Email },
func(s Person, v string) Person { s.Email = v; return s },
)
lensPhone := L.MakeLens(
func(s Person) *string { return s.Phone },
func(s Person, v *string) Person { s.Phone = v; return s },
)
// optional lenses
lensNameO := LO.FromIso[Person](IO.FromZero[string]())(lensName)
lensAgeO := LO.FromIso[Person](IO.FromZero[int]())(lensAge)
lensEmailO := LO.FromIso[Person](IO.FromZero[string]())(lensEmail)
lensPhoneO := LO.FromIso[Person](IO.FromZero[*string]())(lensPhone)
return PersonLenses{
// mandatory lenses
Name: lensName,
Age: lensAge,
Email: lensEmail,
Phone: lensPhone,
// optional lenses
NameO: lensNameO,
AgeO: lensAgeO,
EmailO: lensEmailO,
PhoneO: lensPhoneO,
}
}
// MakePersonRefLenses creates a new PersonRefLenses with lenses for all fields
func MakePersonRefLenses() PersonRefLenses {
// mandatory lenses
lensName := L.MakeLensStrict(
func(s *Person) string { return s.Name },
func(s *Person, v string) *Person { s.Name = v; return s },
)
lensAge := L.MakeLensStrict(
func(s *Person) int { return s.Age },
func(s *Person, v int) *Person { s.Age = v; return s },
)
lensEmail := L.MakeLensStrict(
func(s *Person) string { return s.Email },
func(s *Person, v string) *Person { s.Email = v; return s },
)
lensPhone := L.MakeLensStrict(
func(s *Person) *string { return s.Phone },
func(s *Person, v *string) *Person { s.Phone = v; return s },
)
// optional lenses
lensNameO := LO.FromIso[*Person](IO.FromZero[string]())(lensName)
lensAgeO := LO.FromIso[*Person](IO.FromZero[int]())(lensAge)
lensEmailO := LO.FromIso[*Person](IO.FromZero[string]())(lensEmail)
lensPhoneO := LO.FromIso[*Person](IO.FromZero[*string]())(lensPhone)
return PersonRefLenses{
// mandatory lenses
Name: lensName,
Age: lensAge,
Email: lensEmail,
Phone: lensPhone,
// optional lenses
NameO: lensNameO,
AgeO: lensAgeO,
EmailO: lensEmailO,
PhoneO: lensPhoneO,
}
}
// AddressLenses provides lenses for accessing fields of Address
type AddressLenses struct {
// mandatory fields
Street L.Lens[Address, string]
City L.Lens[Address, string]
ZipCode L.Lens[Address, string]
Country L.Lens[Address, string]
State L.Lens[Address, *string]
// optional fields
StreetO LO.LensO[Address, string]
CityO LO.LensO[Address, string]
ZipCodeO LO.LensO[Address, string]
CountryO LO.LensO[Address, string]
StateO LO.LensO[Address, *string]
}
// AddressRefLenses provides lenses for accessing fields of Address via a reference to Address
type AddressRefLenses struct {
// mandatory fields
Street L.Lens[*Address, string]
City L.Lens[*Address, string]
ZipCode L.Lens[*Address, string]
Country L.Lens[*Address, string]
State L.Lens[*Address, *string]
// optional fields
StreetO LO.LensO[*Address, string]
CityO LO.LensO[*Address, string]
ZipCodeO LO.LensO[*Address, string]
CountryO LO.LensO[*Address, string]
StateO LO.LensO[*Address, *string]
}
// MakeAddressLenses creates a new AddressLenses with lenses for all fields
func MakeAddressLenses() AddressLenses {
// mandatory lenses
lensStreet := L.MakeLens(
func(s Address) string { return s.Street },
func(s Address, v string) Address { s.Street = v; return s },
)
lensCity := L.MakeLens(
func(s Address) string { return s.City },
func(s Address, v string) Address { s.City = v; return s },
)
lensZipCode := L.MakeLens(
func(s Address) string { return s.ZipCode },
func(s Address, v string) Address { s.ZipCode = v; return s },
)
lensCountry := L.MakeLens(
func(s Address) string { return s.Country },
func(s Address, v string) Address { s.Country = v; return s },
)
lensState := L.MakeLens(
func(s Address) *string { return s.State },
func(s Address, v *string) Address { s.State = v; return s },
)
// optional lenses
lensStreetO := LO.FromIso[Address](IO.FromZero[string]())(lensStreet)
lensCityO := LO.FromIso[Address](IO.FromZero[string]())(lensCity)
lensZipCodeO := LO.FromIso[Address](IO.FromZero[string]())(lensZipCode)
lensCountryO := LO.FromIso[Address](IO.FromZero[string]())(lensCountry)
lensStateO := LO.FromIso[Address](IO.FromZero[*string]())(lensState)
return AddressLenses{
// mandatory lenses
Street: lensStreet,
City: lensCity,
ZipCode: lensZipCode,
Country: lensCountry,
State: lensState,
// optional lenses
StreetO: lensStreetO,
CityO: lensCityO,
ZipCodeO: lensZipCodeO,
CountryO: lensCountryO,
StateO: lensStateO,
}
}
// MakeAddressRefLenses creates a new AddressRefLenses with lenses for all fields
func MakeAddressRefLenses() AddressRefLenses {
// mandatory lenses
lensStreet := L.MakeLensStrict(
func(s *Address) string { return s.Street },
func(s *Address, v string) *Address { s.Street = v; return s },
)
lensCity := L.MakeLensStrict(
func(s *Address) string { return s.City },
func(s *Address, v string) *Address { s.City = v; return s },
)
lensZipCode := L.MakeLensStrict(
func(s *Address) string { return s.ZipCode },
func(s *Address, v string) *Address { s.ZipCode = v; return s },
)
lensCountry := L.MakeLensStrict(
func(s *Address) string { return s.Country },
func(s *Address, v string) *Address { s.Country = v; return s },
)
lensState := L.MakeLensStrict(
func(s *Address) *string { return s.State },
func(s *Address, v *string) *Address { s.State = v; return s },
)
// optional lenses
lensStreetO := LO.FromIso[*Address](IO.FromZero[string]())(lensStreet)
lensCityO := LO.FromIso[*Address](IO.FromZero[string]())(lensCity)
lensZipCodeO := LO.FromIso[*Address](IO.FromZero[string]())(lensZipCode)
lensCountryO := LO.FromIso[*Address](IO.FromZero[string]())(lensCountry)
lensStateO := LO.FromIso[*Address](IO.FromZero[*string]())(lensState)
return AddressRefLenses{
// mandatory lenses
Street: lensStreet,
City: lensCity,
ZipCode: lensZipCode,
Country: lensCountry,
State: lensState,
// optional lenses
StreetO: lensStreetO,
CityO: lensCityO,
ZipCodeO: lensZipCodeO,
CountryO: lensCountryO,
StateO: lensStateO,
}
}
// CompanyLenses provides lenses for accessing fields of Company
type CompanyLenses struct {
// mandatory fields
Name L.Lens[Company, string]
Address L.Lens[Company, Address]
CEO L.Lens[Company, Person]
Website L.Lens[Company, *string]
// optional fields
NameO LO.LensO[Company, string]
AddressO LO.LensO[Company, Address]
CEOO LO.LensO[Company, Person]
WebsiteO LO.LensO[Company, *string]
}
// CompanyRefLenses provides lenses for accessing fields of Company via a reference to Company
type CompanyRefLenses struct {
// mandatory fields
Name L.Lens[*Company, string]
Address L.Lens[*Company, Address]
CEO L.Lens[*Company, Person]
Website L.Lens[*Company, *string]
// optional fields
NameO LO.LensO[*Company, string]
AddressO LO.LensO[*Company, Address]
CEOO LO.LensO[*Company, Person]
WebsiteO LO.LensO[*Company, *string]
}
// MakeCompanyLenses creates a new CompanyLenses with lenses for all fields
func MakeCompanyLenses() CompanyLenses {
// mandatory lenses
lensName := L.MakeLens(
func(s Company) string { return s.Name },
func(s Company, v string) Company { s.Name = v; return s },
)
lensAddress := L.MakeLens(
func(s Company) Address { return s.Address },
func(s Company, v Address) Company { s.Address = v; return s },
)
lensCEO := L.MakeLens(
func(s Company) Person { return s.CEO },
func(s Company, v Person) Company { s.CEO = v; return s },
)
lensWebsite := L.MakeLens(
func(s Company) *string { return s.Website },
func(s Company, v *string) Company { s.Website = v; return s },
)
// optional lenses
lensNameO := LO.FromIso[Company](IO.FromZero[string]())(lensName)
lensAddressO := LO.FromIso[Company](IO.FromZero[Address]())(lensAddress)
lensCEOO := LO.FromIso[Company](IO.FromZero[Person]())(lensCEO)
lensWebsiteO := LO.FromIso[Company](IO.FromZero[*string]())(lensWebsite)
return CompanyLenses{
// mandatory lenses
Name: lensName,
Address: lensAddress,
CEO: lensCEO,
Website: lensWebsite,
// optional lenses
NameO: lensNameO,
AddressO: lensAddressO,
CEOO: lensCEOO,
WebsiteO: lensWebsiteO,
}
}
// MakeCompanyRefLenses creates a new CompanyRefLenses with lenses for all fields
func MakeCompanyRefLenses() CompanyRefLenses {
// mandatory lenses
lensName := L.MakeLensStrict(
func(s *Company) string { return s.Name },
func(s *Company, v string) *Company { s.Name = v; return s },
)
lensAddress := L.MakeLensStrict(
func(s *Company) Address { return s.Address },
func(s *Company, v Address) *Company { s.Address = v; return s },
)
lensCEO := L.MakeLensStrict(
func(s *Company) Person { return s.CEO },
func(s *Company, v Person) *Company { s.CEO = v; return s },
)
lensWebsite := L.MakeLensStrict(
func(s *Company) *string { return s.Website },
func(s *Company, v *string) *Company { s.Website = v; return s },
)
// optional lenses
lensNameO := LO.FromIso[*Company](IO.FromZero[string]())(lensName)
lensAddressO := LO.FromIso[*Company](IO.FromZero[Address]())(lensAddress)
lensCEOO := LO.FromIso[*Company](IO.FromZero[Person]())(lensCEO)
lensWebsiteO := LO.FromIso[*Company](IO.FromZero[*string]())(lensWebsite)
return CompanyRefLenses{
// mandatory lenses
Name: lensName,
Address: lensAddress,
CEO: lensCEO,
Website: lensWebsite,
// optional lenses
NameO: lensNameO,
AddressO: lensAddressO,
CEOO: lensCEOO,
WebsiteO: lensWebsiteO,
}
}
// CompanyExtendedLenses provides lenses for accessing fields of CompanyExtended
type CompanyExtendedLenses struct {
// mandatory fields
Extended L.Lens[CompanyExtended, string]
// optional fields
ExtendedO LO.LensO[CompanyExtended, string]
}
// CompanyExtendedRefLenses provides lenses for accessing fields of CompanyExtended via a reference to CompanyExtended
type CompanyExtendedRefLenses struct {
// mandatory fields
Extended L.Lens[*CompanyExtended, string]
// optional fields
ExtendedO LO.LensO[*CompanyExtended, string]
}
// MakeCompanyExtendedLenses creates a new CompanyExtendedLenses with lenses for all fields
func MakeCompanyExtendedLenses() CompanyExtendedLenses {
// mandatory lenses
lensExtended := L.MakeLens(
func(s CompanyExtended) string { return s.Extended },
func(s CompanyExtended, v string) CompanyExtended { s.Extended = v; return s },
)
// optional lenses
lensExtendedO := LO.FromIso[CompanyExtended](IO.FromZero[string]())(lensExtended)
return CompanyExtendedLenses{
// mandatory lenses
Extended: lensExtended,
// optional lenses
ExtendedO: lensExtendedO,
}
}
// MakeCompanyExtendedRefLenses creates a new CompanyExtendedRefLenses with lenses for all fields
func MakeCompanyExtendedRefLenses() CompanyExtendedRefLenses {
// mandatory lenses
lensExtended := L.MakeLensStrict(
func(s *CompanyExtended) string { return s.Extended },
func(s *CompanyExtended, v string) *CompanyExtended { s.Extended = v; return s },
)
// optional lenses
lensExtendedO := LO.FromIso[*CompanyExtended](IO.FromZero[string]())(lensExtended)
return CompanyExtendedRefLenses{
// mandatory lenses
Extended: lensExtended,
// optional lenses
ExtendedO: lensExtendedO,
}
}
// CheckOptionLenses provides lenses for accessing fields of CheckOption
type CheckOptionLenses struct {
// mandatory fields
Name L.Lens[CheckOption, option.Option[string]]
Value L.Lens[CheckOption, string]
// optional fields
NameO LO.LensO[CheckOption, option.Option[string]]
ValueO LO.LensO[CheckOption, string]
}
// CheckOptionRefLenses provides lenses for accessing fields of CheckOption via a reference to CheckOption
type CheckOptionRefLenses struct {
// mandatory fields
Name L.Lens[*CheckOption, option.Option[string]]
Value L.Lens[*CheckOption, string]
// optional fields
NameO LO.LensO[*CheckOption, option.Option[string]]
ValueO LO.LensO[*CheckOption, string]
}
// MakeCheckOptionLenses creates a new CheckOptionLenses with lenses for all fields
func MakeCheckOptionLenses() CheckOptionLenses {
// mandatory lenses
lensName := L.MakeLens(
func(s CheckOption) option.Option[string] { return s.Name },
func(s CheckOption, v option.Option[string]) CheckOption { s.Name = v; return s },
)
lensValue := L.MakeLens(
func(s CheckOption) string { return s.Value },
func(s CheckOption, v string) CheckOption { s.Value = v; return s },
)
// optional lenses
lensNameO := LO.FromIso[CheckOption](IO.FromZero[option.Option[string]]())(lensName)
lensValueO := LO.FromIso[CheckOption](IO.FromZero[string]())(lensValue)
return CheckOptionLenses{
// mandatory lenses
Name: lensName,
Value: lensValue,
// optional lenses
NameO: lensNameO,
ValueO: lensValueO,
}
}
// MakeCheckOptionRefLenses creates a new CheckOptionRefLenses with lenses for all fields
func MakeCheckOptionRefLenses() CheckOptionRefLenses {
// mandatory lenses
lensName := L.MakeLensRef(
func(s *CheckOption) option.Option[string] { return s.Name },
func(s *CheckOption, v option.Option[string]) *CheckOption { s.Name = v; return s },
)
lensValue := L.MakeLensStrict(
func(s *CheckOption) string { return s.Value },
func(s *CheckOption, v string) *CheckOption { s.Value = v; return s },
)
// optional lenses
lensNameO := LO.FromIso[*CheckOption](IO.FromZero[option.Option[string]]())(lensName)
lensValueO := LO.FromIso[*CheckOption](IO.FromZero[string]())(lensValue)
return CheckOptionRefLenses{
// mandatory lenses
Name: lensName,
Value: lensValue,
// optional lenses
NameO: lensNameO,
ValueO: lensValueO,
}
}