Socket
Socket
Sign inDemoInstall

flow-static-land

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    flow-static-land

Implementation of common algebraic types in JavaScript + Flow


Version published
Maintainers
1
Install size
261 kB
Created

Changelog

Source

0.2.6

  • Bug fix
    • fix ChainRec definition [@gcanti]
    • fix State definition [@gcanti]

Readme

Source

Features

  • statically type checked by Flow
  • PureScript-like standard library
  • static land compatible

The idea (faking higher kinded types in Flow) is based on the paper Lightweight higher-kinded polymorphism and elm-brands.

  • Semigroup
  • Monoid
  • Functor
  • Applicative
  • Monad
  • Foldable
  • Traversable
  • ChainRec
  • Alternative
  • Eff
  • Arr
  • Maybe
  • Either
  • Task
  • State
  • Writer
  • Reader

and many more...

Example

import * as maybe from 'flow-static-land/lib/Maybe'
import * as arr from 'flow-static-land/lib/Arr'

const f = (n) => n * 2
const g = (n) => n + 1

// functor
maybe.map(f, maybe.Nothing) // => null
maybe.map(f, maybe.of(3)) // => 6

const a1 = arr.inj([f, g])
const a2 = arr.inj([1, 2, 3])

// applicative
arr.ap(a1, a2) // => [2, 4, 6, 2, 3, 4]

Statically type checked

maybe.map(f, maybe.of('s'))

Error

maybe.map(f, maybe.of('s'))
                  ^^^^^^^^^^^^^ call of method `of`
const f = (n) => n * 2
                 ^ string. This type is incompatible with
const f = (n) => n * 2
                 ^^^^^ number

More examples

examples directory:

Setup

npm install flow-static-land --save

Babel config

{
  "presets": ["es2015"],
  "plugins" : [
    "syntax-flow",
    "transform-flow-strip-types",
    "transform-class-properties"
  ]
}

License

The MIT License (MIT)

Keywords

FAQs

Last updated on 25 Feb 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc