UNPKG

effect-ts-laws

Version:
38 lines 1.22 kB
import { HKT } from 'effect'; /** * A typeclass for lossless bidirectional conversion between two encodings. * @category typeclass */ export interface Isomorphism<A, B> { readonly to: (from: A) => B; readonly from: (to: B) => A; } /** * Type lambda for the `Isomorphism` typeclass. * @category type lambda */ export interface IsomorphismTypeLambda extends HKT.TypeLambda { readonly type: Isomorphism<this['Target'], this['Out1']>; } /** * Flip the encode/decode direction: encode becomes decode and decode becomes * encode. * @category typeclass */ export declare const reverse: <A, B>({ to, from, }: Isomorphism<A, B>) => Isomorphism<B, A>; /** * Compose two isomorphisms of `A⇒B` and `B⇒C` into an isomorphism of `a⇒C`. * @category typeclass */ export declare const compose: <A, B>(F: Isomorphism<A, B>) => <C>(G: Isomorphism<B, C>) => Isomorphism<A, C>; /** * Run the `to` transform of the isomorphism. * @category typeclass */ export declare const encode: <A, B>(iso: Isomorphism<A, B>) => ((a: A) => B), /** * Run the `from` transform of the isomorphism. * @category type lambda */ decode: <A, B>(iso: Isomorphism<A, B>) => ((a: B) => A); //# sourceMappingURL=Isomorphism.d.ts.map