flow-static-land

[DEPRECATED, please check out fp-ts] Implementation of common algebraic types in JavaScript + Flow

  • Owner: gcanti/flow-static-land
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

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.

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

Related libraries

Related blog posts

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)

Main metrics

Overview
Name With Ownergcanti/flow-static-land
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2016-08-14 12:42:44
Pushed At2017-11-02 20:48:40
Last Commit At2017-11-02 21:46:02
Release Count10
Last Release Name0.2.8 (Posted on )
First Release Name0.1.0 (Posted on )
用户参与
Stargazers Count410
Watchers Count14
Fork Count22
Commits Count124
Has Issues Enabled
Issues Count27
Issue Open Count10
Pull Requests Count32
Pull Requests Open Count0
Pull Requests Close Count5
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private