npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hkt-ts

v2.1.5

Published

A Generic HKT encoding for TypeScript

Downloads

654

Readme

HKT-TS

HKT-TS is an encoding for Higher-Kinded Types (HKT) for TypeScript, with composable Typclasses to describe the majority of functionality you'll be using to write your programs.

It is principled, based primarily in Type Theory and Alegbra, but also with roots in Category Theory.

If you've ever used a compiler for a strictly-typed language like TypeScript before, the annotations you're writing already follow all of these rules, and you likely know more about it already than you may realize. If something is an Algebra, it can be solved, like how your type-checker solves for the correctness of your program.

The laws required to build something like a type-checker are generally applicable to all programming -- this is where HKT-TS comes in. HKT-TS provides the highest level of abstractions possible within TypeScript and will allow you to place composition at the forefront of programs. It will allow you to rapidly compose small solutions into larger solutions with an emphasis on type safety.

Right now there's not a lot to see besides the code itself, but it is my goal to make learning materials accessible on all of the topics above as well as the contents of this library -- check back soon for more.

Acknowledgments

HKT-TS has been greatly influenced by numerous other open-source projects, the biggest being the Scala library ZIO-Prelude which is the pioneer of a brand new way to blend Category Theory with programming languages that aren't Haskell.

Within the TypeScript space, I've been inspired and taken influence from Effect-TS which offers a port of a larger portion of ZIO including ZIO-Prelude. If you're interested in powerful effects that are built upon abstractions like these, with a strong standard library, check them out. Also if you love FP, then check out the amazing things they're doing with TS+ for functional programmers. I look forward to seeing it continue to mature!

Last but certainly not least, I have to give a huge shoutout to fp-ts, another HKT encoding for TypeScript that provides a Haskell-like expression of Category Theory with a rich standard library and ecosystem, which I've been using for a few years now. It's helped me greatly to dive into the world of Category Theory as it is applied to programming, but after seeing this talk during the beginning months of COVID, I've constantly been questioning if it's the easiest approach to learn and teach.

HKT-TS is the culmination of my attempts to learn this new set of TypeClasses and what they're capable of.

Installation

NOTE: For the best experience you'll want to use typescript >= 4.7 to be able to use the NodeNext moduleResolution mode to support the package exports defined for this project. All examples are written in this format. Otherwise hkt-ts/cjs or hkt-ts/esm will be needed to have type-safe imports with TypeScript.

# NPM
npm i --save hkt-ts

# Yarn
yarn add hkt-ts

# PNPM
pnpm add hkt-ts

Related Links