Protocol Primitive | Client-side | Server-side |
---|---|---|
request | writer morphism | reader morphism |
HTTP Method | ø.GET declares the verb of HTTP request |
ƒ.GET matches the verb of HTTP request and fails with error if the verb does not match the expected one. |
URI | ø.URI(string) specifies target URI for HTTP request. The combinator uses absolute URI to specify target host and endpoint. |
ƒ.URI(string) matches URL path from HTTP request. The combinator considers the URI path as an ordered sequence of segments, which are matched against a given pattern or uses a lens to extract value into the context. It fails if the path does not match the expected one. |
URI Query | ø.Params(any) ø.Param[T Literals](string, T) lifts the flat structure or individual values into query parameters of specified URI. |
`ƒ.Params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "textflag.h" | |
// func EuclideanF32(a, b, c []float32) float32 | |
TEXT ·EuclideanF32(SB), NOSPLIT, $0 | |
MOVD a_base + 0(FP), R0 | |
MOVD b_base + 24(FP), R1 | |
MOVD c_base + 48(FP), R2 | |
MOVD a_size + (8)(FP), R20 | |
MOVD $4, R8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// See the post: https://tech.fog.fish/2022/07/05/assert-golang-errors-for-behavior.html | |
// | |
// ErrorCodes provides a raw code originared by the failed package | |
type ErrorCode interface{ ErrorCode() string } | |
// ErrorType is the primary identifier (IRI) for the problem type, defined by the ontology | |
type ErrorType interface{ ErrorType() string } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strings" | |
) | |
// | |
// | |
type HKT[F, A any] interface { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HKT<F, A> {} | |
interface Functor<F> { | |
map<A, B>(f: (a: A) => B, fa: HKT<F, A>): HKT<F, B> | |
} | |
type Seq<A> = HKT<'Seq', A> | |
type Abc<A> = HKT<'Abc', A> | |
type seq<A> = Array<A> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strconv" | |
) | |
// | |
// | |
func filter[A any](f func(A) bool, a A) A { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
SeqEq is a heterogeneous product of Seq and Eq laws. | |
It composes two types together that "knows" how to compare sequences. | |
*/ | |
type SeqEq[S, T any] struct { | |
Seq[S, T] | |
Eq[T] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Seq defines fundamental general purpose sequence | |
*/ | |
type Seq[S any, T any] interface { | |
Head(S) *T | |
Tail(S) S | |
IsVoid(S) bool | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Foldable[T any] interface { | |
Fold(T, []T) T | |
} | |
type Semigroup[T any] interface { | |
Combine(T, T) T | |
} | |
type Folder[T any] struct{ Semigroup[T] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
ContraMapEq is a combinator that build a new instance of type trait Eq[B] using | |
existing instance of Eq[A] and f: b ⟼ a | |
*/ | |
type ContraMapEq[A, B any] struct{ Eq[A] } | |
// implementation of contra variant functor | |
func (c ContraMapEq[A, B]) FMap(f func(B) A) Eq[B] { | |
return FromEq[B](func(a, b B) bool { |
NewerOlder