Hyperlinkv0.8.0-beta.28

HKT

HKT.URIconsteffect/HKT.ts:54
typeof URI

Defines the unique symbol used to associate TypeClass implementations with their TypeLambda.

When to use

Use when you need to define a custom type class that exposes the TypeLambda it operates on.

Details

This symbol links a type class shape with its compile-time type lambda. It is intended for type-class definitions and has no runtime behavior.

Example (Linking a type class to a type lambda)

import type { HKT } from "effect"

interface IdentityTypeLambda extends HKT.TypeLambda {
  readonly type: this["Target"]
}

interface IdentityTypeClass extends HKT.TypeClass<IdentityTypeLambda> {
  readonly [HKT.URI]?: IdentityTypeLambda
  readonly of: <A>(value: A) => HKT.Kind<IdentityTypeLambda, never, never, never, A>
}

const identity: IdentityTypeClass = {
  of: (value) => value
}

type LinkedTypeLambda = typeof identity[typeof HKT.URI]

const value: HKT.Kind<NonNullable<LinkedTypeLambda>, never, never, never, string> = identity.of("ok")
console.log(value) // "ok"
symbols
Source effect/HKT.ts:541 lines
export declare const URI: unique symbol
Referenced by 1 symbols