Documentation
¶
Overview ¶
Package string provides functional programming utilities for working with strings. It includes functions for string manipulation, comparison, conversion, and formatting, following functional programming principles with curried functions and composable operations.
Index ¶
- Variables
- func Append(suffix string) func(string) string
- func Eq(left, right string) bool
- func Format[T any](format string) func(T) string
- func Intersperse(middle string) func(string, string) string
- func IntersperseMonoid(middle string) M.Monoid[string]
- func IntersperseSemigroup(middle string) S.Semigroup[string]
- func IsEmpty(s string) bool
- func IsNonEmpty(s string) bool
- func Prepend(prefix string) func(string) string
- func Size(s string) int
- func ToBytes(s string) []byte
- func ToRunes(s string) []rune
Constants ¶
This section is empty.
Variables ¶
var ( // ToUpperCase converts the string to uppercase ToUpperCase = strings.ToUpper // ToLowerCase converts the string to lowercase ToLowerCase = strings.ToLower // Ord implements the default ordering for strings Ord = ord.FromStrictCompare[string]() // Join joins strings Join = F.Curry2(F.Bind2nd[[]string, string, string])(strings.Join) // Equals returns a predicate that tests if a string is equal Equals = F.Curry2(Eq) // Includes returns a predicate that tests for the existence of the search string Includes = F.Bind2of2(strings.Contains) // HasPrefix returns a predicate that checks if the prefix is included in the string HasPrefix = F.Bind2of2(strings.HasPrefix) )
var Monoid = M.MakeMonoid(concat, "")
Monoid is the monoid implementing string concatenation with empty string as identity
var Semigroup = S.MakeSemigroup(concat)
Semigroup is the semigroup implementing string concatenation
Functions ¶
func Append ¶ added in v2.1.6
Append returns a function that appends a suffix to a string. This is a curried function that takes a suffix and returns a function that appends that suffix to any string passed to it.
Example:
addExclamation := Append("!")
result := addExclamation("Hello") // "Hello!"
func Format ¶
Format applies a format string to an arbitrary value and returns a function that formats values of type T using the provided format string
func Intersperse ¶
Intersperse returns a function that concatenates two strings with a middle string in between. If either string is empty, the middle string is not added (to satisfy monoid identity laws).
func IntersperseMonoid ¶
IntersperseMonoid creates a monoid that concatenates strings with a middle string in between, with empty string as identity
func IntersperseSemigroup ¶
IntersperseSemigroup creates a semigroup that concatenates strings with a middle string in between
func Prepend ¶ added in v2.1.6
Prepend returns a function that prepends a prefix to a string. This is a curried function that takes a prefix and returns a function that prepends that prefix to any string passed to it.
Example:
addHello := Prepend("Hello, ")
result := addHello("World") // "Hello, World"
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package generic provides generic string utility functions that work with any type that has string as its underlying type (using the ~string constraint).
|
Package generic provides generic string utility functions that work with any type that has string as its underlying type (using the ~string constraint). |