1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-08-10 22:31:32 +02:00

fix: rename FormEndomorphism and FormBuilder

Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
Dr. Carsten Leue
2023-12-17 22:38:55 +01:00
parent e82575fe08
commit 1d02f21ff5
2 changed files with 14 additions and 14 deletions

View File

@@ -28,8 +28,8 @@ import (
)
type (
// FormEndomorphism returns an [ENDO.Endomorphism] that transforms a form
FormEndomorphism = ENDO.Endomorphism[url.Values]
// Endomorphism returns an [ENDO.Endomorphism] that transforms a form
Endomorphism = ENDO.Endomorphism[url.Values]
)
var (
@@ -38,8 +38,8 @@ var (
noField = O.None[string]()
// FormMonoid is the [M.Monoid] for the [FormEndomorphism]
FormMonoid = ENDO.Monoid[url.Values]()
// FormMonoid is the [M.Monoid] for the [Endomorphism]
Monoid = ENDO.Monoid[url.Values]()
// AtValues is a [L.Lens] that focusses on the values of a form field
AtValues = LRG.AtRecord[url.Values, []string]
@@ -57,7 +57,7 @@ var (
)
// WithValue creates a [FormBuilder] for a certain field
func WithValue(name string) func(value string) FormEndomorphism {
func WithValue(name string) func(value string) Endomorphism {
return F.Flow3(
O.Of[string],
AtValue(name).Set,
@@ -66,6 +66,6 @@ func WithValue(name string) func(value string) FormEndomorphism {
}
// WithoutValue creates a [FormBuilder] that removes a field
func WithoutValue(name string) FormEndomorphism {
func WithoutValue(name string) Endomorphism {
return AtValue(name).Set(noField)
}

View File

@@ -40,8 +40,8 @@ type (
body O.Option[IOE.IOEither[error, []byte]]
}
// BuilderEndomorphism returns an [ENDO.Endomorphism] that transforms a builder
BuilderEndomorphism = ENDO.Endomorphism[*Builder]
// Endomorphism returns an [ENDO.Endomorphism] that transforms a builder
Endomorphism = ENDO.Endomorphism[*Builder]
)
var (
@@ -50,8 +50,8 @@ var (
defaultMethod = F.Constant(http.MethodGet)
// BuilderMonoid is the [M.Monoid] for the [BuilderEndomorphism]
BuilderMonoid = ENDO.Monoid[*Builder]()
// Monoid is the [M.Monoid] for the [Endomorphism]
Monoid = ENDO.Monoid[*Builder]()
// Url is a [L.Lens] for the URL
Url = L.MakeLensRef((*Builder).GetUrl, (*Builder).SetUrl)
@@ -226,7 +226,7 @@ func Header(name string) L.Lens[*Builder, O.Option[string]] {
}
// WithHeader creates a [BuilderBuilder] for a certain header
func WithHeader(name string) func(value string) BuilderEndomorphism {
func WithHeader(name string) func(value string) Endomorphism {
return F.Flow3(
O.Of[string],
Header(name).Set,
@@ -235,12 +235,12 @@ func WithHeader(name string) func(value string) BuilderEndomorphism {
}
// WithoutHeader creates a [BuilderBuilder] to remove a certain header
func WithoutHeader(name string) BuilderEndomorphism {
func WithoutHeader(name string) Endomorphism {
return Header(name).Set(noHeader)
}
// WithFormData creates a [BuilderBuilder] to send form data payload
func WithFormData(value url.Values) BuilderEndomorphism {
func WithFormData(value url.Values) Endomorphism {
return F.Flow2(
F.Pipe4(
value,
@@ -254,7 +254,7 @@ func WithFormData(value url.Values) BuilderEndomorphism {
}
// WithJson creates a [BuilderBuilder] to send JSON payload
func WithJson[T any](data T) BuilderEndomorphism {
func WithJson[T any](data T) Endomorphism {
return F.Flow2(
F.Pipe3(
data,