typescript-flow-haskell-types-comparison
May 12, 2017 ยท View on GitHub
| Type | Haskell | TypeScript | Flow | JsDoc | JSON Schema |
|---|---|---|---|---|---|
| Union | data Shape = Circle | Triangle | type Shape = CircleInterface | TriangleInterface | var Shape: CircleVar | TriangleVar | `({x: number, y: number, r: number} | {{x: number, y: number, a: number, b: number, c: number}})` |
| Product | Data Circle = Int Int Int | interface Circle {x: number; y: number; radius: number } | var Circle = {x: number, y: number, radius: number} | {{x: number; y: number; radius: number}} | type: "object", properties: {x: "number", y: "number", radius: "number"} |
| Nullable | Maybe type | type T1 = (x?: number) | var Salary = ?number | {?number} | Depends on parser, either type: null if it supports undefined as well or using required |
| Non-nulalble | - | let s = e!.name | ? | {!{number}} | - |
| Discriminated union | Pattern matching in type constructor | Understanding context | Understanding context | - | - |
| Generics | data Maybe a = Nothing | Just a | interface GenericObject<T> {foo: T;} | type GenericObject<T> = { foo: T }; | - | - |