flow-static-land

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

  • 所有者: gcanti/flow-static-land
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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)

主要指标

概览
名称与所有者gcanti/flow-static-land
主编程语言JavaScript
编程语言JavaScript (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2016-08-14 12:42:44
推送于2017-11-02 20:48:40
最后一次提交2017-11-02 21:46:02
发布数10
最新版本名称0.2.8 (发布于 )
第一版名称0.1.0 (发布于 )
用户参与
星数410
关注者数14
派生数22
提交数124
已启用问题?
问题数27
打开的问题数10
拉请求数32
打开的拉请求数0
关闭的拉请求数5
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?