2
2
3
3
- statically type checked by [ Flow] ( https://flowtype.org/ )
4
4
- PureScript-like standard library
5
- - static land compatible ( [ Specification ] ( https://github.com/rpominov/static-land ) )
5
+ - [ static land] ( https://github.com/rpominov/static-land ) compatible
6
6
7
7
The idea (faking higher kinded types in Flow) is based on the paper [ Lightweight higher-kinded polymorphism] ( https://www.cl.cam.ac.uk/~jdy22/papers/lightweight-higher-kinded-polymorphism.pdf ) and [ elm-brands] ( https://github.com/joneshf/elm-brands ) .
8
8
9
- # Try it out
10
-
11
- ```
12
- git clone https://github.com/gcanti/flow-static-land.git
13
- cd flow-static-land
14
- npm install
15
- npm start
16
-
17
- # execute ./node_modules/.bin/babel-node playground/index.js
18
- # or open the page playground/index.html in a browser
19
- # then edit playground/index.js
20
- ```
21
-
22
- # Examples
23
-
24
- Real world examples
25
-
26
- - a Signal library ([ purescript-signal] ( https://github.com/bodil/purescript-signal ) porting)
27
- - a QuickCheck library ([ purescript-quickcheck] ( https://github.com/purescript/purescript-quickcheck ) partial porting)
28
-
29
- ## ` Maybe ` and ` Arr `
9
+ # Example
30
10
31
11
``` js
32
- import * as maybe from ' flow-static-land/Maybe'
33
- import * as arr from ' flow-static-land/Arr'
12
+ import * as maybe from ' flow-static-land/lib/ Maybe'
13
+ import * as arr from ' flow-static-land/lib/ Arr'
34
14
35
15
const f = (n ) => n * 2
36
16
const g = (n ) => n + 1
@@ -63,47 +43,28 @@ const f = (n) => n * 2
63
43
^^^^^ number
64
44
```
65
45
66
- ## Expressing side effects with the ` Eff ` monad
46
+ # Related blog posts
67
47
68
- See this [ blog post] ( https://medium.com/@gcanti/the-eff-monad-implemented-in-flow-40803670c3eb#.sj4m00hpe ) for context
69
-
70
- ``` js
71
- import type { Eff } from ' flow-static-land/Eff'
72
- import { inj } from ' flow-static-land/Eff'
48
+ - [ Higher kinded types with Flow] ( https://medium.com/@gcanti/higher-kinded-types-in-flow-275b657992b7 )
49
+ - [ Expressing side effects with the ` Eff ` monad] ( https://medium.com/@gcanti/the-eff-monad-implemented-in-flow-40803670c3eb )
50
+ - [ Phantom types with Flow] ( https://medium.com/@gcanti/phantom-types-with-flow-828aff73232b )
51
+ - [ Refinements with Flow] ( https://medium.com/@gcanti/refinements-with-flow-9c7eeae8478b )
73
52
74
- class DB {}
53
+ # More examples
75
54
76
- type User = {
77
- username: string,
78
- uid: number
79
- };
80
-
81
- const users = {}
82
- let uid = 0
83
-
84
- function createUser (username : string ): Eff<{ write: DB }, User> {
85
- return inj (() => {
86
- users[username] = { username, uid: ++ uid }
87
- return users[username]
88
- })
89
- }
55
+ ` examples ` directory:
90
56
91
- function lookupUser (username : string ): Eff<{ read: DB }, ? User> {
92
- return inj (() => users[username])
93
- }
94
-
95
- // the signature shows that createThenLookupUser will read and write to the db
96
- const createThenLookupUser: (username: string ) = > Eff< { read: DB , write: DB }, ? User> =
97
- username => chain (user => lookupUser (user .username ), createUser (username))
98
- ` ` `
57
+ - a Signal library ([ purescript-signal] ( https://github.com/bodil/purescript-signal ) porting)
58
+ - a QuickCheck library ([ purescript-quickcheck] ( https://github.com/purescript/purescript-quickcheck ) partial porting)
59
+ - a React library (experimental)
99
60
100
61
# Setup
101
62
102
- Download the source code with the command ` npm i gcanti / flow - static - land#master `
103
-
104
- **Bundles**
63
+ ``` sh
64
+ npm install flow-static-land --save
65
+ ```
105
66
106
- In order to build a bundle, add the following plugins to your ` . babelrc ` file
67
+ Babel config
107
68
108
69
```
109
70
{
@@ -116,15 +77,6 @@ In order to build a bundle, add the following plugins to your `.babelrc` file
116
77
}
117
78
```
118
79
119
- For webpack, add the following include to your babel loader
120
-
121
- ` ` ` js
122
- {
123
- loader: ' babel' ,
124
- include: [
125
- path .resolve (__dirname , " node_modules/flow-static-land" ),
126
- path .resolve (__dirname , " path/to/your/code" )
127
- ]
128
- }
129
- ` ` `
80
+ # License
130
81
82
+ The MIT License (MIT)
0 commit comments