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

data-ts

v1.1.0

Published

Common algebraic structures heavily inspired by Haskell type classes adapted for fluent pointfree interfaces in Typescript.

Downloads

3

Readme

data-ts

Common algebraic structures heavily inspired by Haskell type classes adapted for fluent pointfree interfaces in Typescript. Strictly typed.

Relationship among Haskell algebraic type classes Source: The Typeclassopedia by Brent Yorgey

Install

yarn add data-ts

Import

import { Maybe } from 'data-ts';
/* or */
import * as Maybe from 'data-ts/lib/Maybe';

Run Test

$ yarn jest
$ yarn jest --watch

Publish

$ yarn publish

Instances

  • [ ] Identity
  • [X] Maybe
  • [ ] Either
  • [ ] Task
  • [X] List
  • [ ] Map
  • [ ] Set
  • [ ] Trie

Work in progress

  • track 1:
    LazyMaybe
  • track 2:
    ✅List -- Tree -- (BinaryTree) -- (BST) -- (Red-Black Tree)
                   \_ (Stack)
                   \_ (Map)
  • track 3:
    Trie -- (RouteTrie)
  • track 4:
    Monad2 -- (Either)

TODO Ideas

  • create Functor2, Applicative2, Monad2 to support Either
  • implement Alternative (.alt), Semigroup, Monoid, Foldable, Traversable
  • implement the lazy version of Maybe, Either that apply multiple chains/maps per item
  • implement naive, non-persistent (but immutable) versions of: (Linked)List, Stack, Tree, Dictionary (still useful for small inputs)
  • implement persistent versions of: LinkedList, Stack, Tree, Dictionary
  • see if it's possible to implement type Maybe<T> = Nothing | Just<T>; rather than type Maybe<T> = Nothing<T> | Just<T>;

References & Inspirations

Note: this project does not implemented to be in compliant with Fantasyland but I draw a lot of inspiration from it. I however opt to be in consistent with Haskell interfaces but adapt it to be ergonomic in Typescript/Javascript.

Brain dump

  • semigroup/monoid is useful because it allows you to implement pairwise funtions/operators and they will just work on your monoid (e.g. list). With associativity and that allows divide & conquer algorithms, parallelization, and incremental accumulation.
  • function composition can be a monoid if the functions have the same type of input and output (endomorphism)
  • hence, a monad is just a monoid in the category of endofunctors

A functor is a structure-preserving transformation between categories. It's some way to map objects from one category to objects of another category while also preserving the arrows between objects—think of it as a category homomorphism. ... An endofunctor is a functor from one category back to the same category. https://www.quora.com/What-is-an-endofunctor

fmap (haskell) can be viewed as fmap :: Functor f => (a -> b) -> (f a -> f b) which shows the preserved structor that maps from (a -> b) into (f a -> f b)