endo

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endo

type Endo[A any] func(A) A

type Type

type Type[
	A any,
	F Endo[A],
] struct {
	monoid.Type[F]
}

func NewType

func NewType[
	A any,
	F Endo[A],
]() Type[A, F]
Example
package main

import (
	"fmt"

	"github.com/calebcase/base/data/monoid/endo"
)

func main() {
	t := endo.NewType[string]()

	prefix := func(x string) string {
		return "Hello, " + x
	}

	postfix := func(x string) string {
		return x + "!"
	}

	computation := t.MAppend(prefix, postfix)

	fmt.Println(t.Apply(computation, "Haskell"))

}
Output:
Hello, Haskell!

func (Type[A, F]) Apply

func (t Type[A, F]) Apply(f F, x A) A

Jump to

Keyboard shortcuts

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