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

akh.list

v0.0.1

Published

Akh list monad and monad transformer

Downloads

3,279

Readme

List Monad and Monad Transformer for Akh Javascript Monad Library

The list transformer ListT and the base list type, List. This uses Javascript arrays which are both finite and not lazy. For working with lazy, potentially infinite lists of values see Stream-m.

# To use as standalone package
$ npm install --save akh.either

# To use as part of akh library
$ npm install --save akh

Usage

ListT and List implement the Fantasy Land a monad, monoid, functor, and applicative functor interfaces.

// List monad
require('akh.list').List
require('akh').List

// List monad tranformer
require('akh.list').ListT
require('akh').ListT

List.of(x)

Create a list consisting of a single element x.

const List = require('akh.list').List

List.run(List.of(1)) === [1]

List.run(List.of([1,2,3])) === [[1, 2, 3]]

List.zero

Empty list.

List.run(List.zero) === []
List.zero.run() === []

a.concat(b)

Concatenate list b onto list a.

List.run(
    List.zero
        .concat(List.of(1))
        .concat(List.of([2, 3]))
        .concat(List.of(4))) === [1, [2, 3], 4]

a.chain(f)

Flatmap list a with function f. f is mapped over a, returning a new List for each element of a. The resulting list is then flattened.

List.run(
    List.of(1)
        .chain(x => List.of([x, x + 1]))
        .chain(x => List.of([x, x * 2]))) === [1, 2, 2, 4]

a.map(f)

Regular mapping of list a with function f. f is maps current values to new values.

List.run(
    List.zero
        .concat(List.of(1))
        .concat(List.of(2))
        .concat(List.of(3))
        .map(x -> x * x)) === [1, 4, 9]

f.ap(m)

Map the functors in list f over list m.

List.run(
    List.of(x => x * x)
        .ap(List.zero
            .concat(List.of(1))
            .concat(List.of(2))
            .concat(List.of(3)))) === [1, 4, 9]
List.run(List
    .of(x => x * x)
    .concat(List.of(x => x + 10))
    .concat(List.of(x => x * x))
        .ap(List.zero
            .concat(List.of(1))
            .concat(List.of(2))
            .concat(List.of(3)))) === [2, 4, 6, 11, 12, 13, 1, 4, 9]

Running

List.run(m), m.run()

Run list computation m, getting the resulting list.

ListT.run(t), t.run()

Same as List.run but for transformed types.

Contributing

Contributions are welcome.

To get started:

$ cd akh-list
$ npm install # install dev packages
$ npm test # run tests