I hereby claim:
- I am vincentcordobes on github.
- I am vincentcordobes (https://keybase.io/vincentcordobes) on keybase.
- I have a public key ASBpuGtIzpS2pRXqqeIrUFmWz7-GEk9McG_c05yuWn_BzAo
To claim this, I am signing this object:
watson log | awk '/test/ {print $1}' | xargs -I{} watson remove -f {} |
module Reader = struct | |
type ('e, 'a) t = Reader of ('e -> 'a) | |
let run = function | |
| Reader r -> r | |
let map f m = Reader (fun env -> f (run m env)) | |
let bind f m = Reader (fun env -> run (f (run m env)) env) |
module Result = struct | |
type ('a, 'b) t = Ok of 'a | Error of 'b | |
let return a = Ok a | |
let map f m = | |
match m with | |
| Ok a -> Ok (f a) | |
| Error b -> Error b |
type List<T> = | |
| { type: "Empty" } | |
| { | |
type: "List"; | |
head: T; | |
list: List<T>; | |
}; | |
// use it like so | |
function empty<T>(): List<T> { |
import { Result, Ok, isOk, succeed, fail, Err } from "./Result"; | |
// Experimenting some stuff in there | |
type GeneratorResult<T, E> = IterableIterator<Result<T, E>>; | |
function addOne(a: number): number { | |
return a + 1; | |
} |
type Add = (a: number) => (b: number) => (c: number) => number; | |
const add: Add = a => b => c => a + b + c; | |
const r = succeed(4).map(add).ap(fail(['err1'])).ap(fail(['err2'])); | |
// const r = succeed(add).ap(succeed(4)).ap(succeed(1)).ap(succeed(2)); | |
// console.log(r); | |
type Person = { |
export type Result<T, E> = Ok<T, E> | Err<T, E> | |
class Ok<T, E> { | |
value: T; | |
constructor(v: T) { | |
this.value = v | |
} | |
bind<U>(f: (v: T) => Result<U, E>): Result<U, E> { | |
return f(this.value); |
I hereby claim:
To claim this, I am signing this object: