dual

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: 1 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dual

type Dual[A any] struct {
	Value A
}

type Type

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

func NewType

func NewType[
	A any,
](m monoid.Class[A]) Type[A]
Example
package main

import (
	"fmt"

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

func main() {
	t := dual.NewType[string](monoid.NewType(
		func(x string, y string) string {
			return x + y
		},
		func() string {
			return ""
		},
	))

	d := t.MAppend(
		dual.Dual[string]{Value: "Hello"},
		dual.Dual[string]{Value: "World"},
	)

	fmt.Println(d.Value)

}
Output:
WorldHello

Jump to

Keyboard shortcuts

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