Skip to main content
Deno 2 is finally here 🎉️
Learn more

hkts

Higher kinded types for Deno. As an avid user of fp-ts I wanted to have a similarly full featured envvironment in Deno. Unfortunately, the fp-ts port to Deno is clunky to use with other functional libraries like @nll/datum, io-ts, and monocle-ts. While I could have ported fp-ts directly, I’ve come to like the exploratory work done by pelotom in the original hkts. Thus, I’ve decided to port the functionality of fp-ts, io-ts, and monocle-ts to Deno using the HKT substitution developed by pelotom.

Installation

This library is meant to be used with Deno, thus it follows the Deno imports syntax.

import * as O from "https://deno.land/x/hkts/option.ts";
import { pipe } from "https://deno.land/x/hkts/pipe.ts";

const result = pipe(
    O.some(1),
    O.map(n => n + 1),
    O.chain(n => n % 2 === 0 ? O.none, O.some(n))
);
// result = O.none.