This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { some, Option, none, getSetoid, option } from 'fp-ts/lib/Option'; | |
import { setoidNumber } from 'fp-ts/lib/Setoid'; | |
import { liftA2 } from 'fp-ts/lib/Apply'; | |
const isEquals = (x: Option<number>, y: Option<number>) => getSetoid(setoidNumber).equals(x, y); | |
// Monad = Applicative & Chain + Laws | |
// Laws: | |
// 1. Left identity: M.chain(M.of(a), f) = f(a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Option, some, none, fromNullable, getSetoid as getSetoidOpt } from 'fp-ts/lib/Option'; | |
import { success, getSetoid as getSetoidRD } from '@devexperts/remote-data-ts'; | |
import { of, Observable, combineLatest } from 'rxjs'; | |
import { setoidNumber, setoidString, getRecordSetoid } from 'fp-ts/lib/Setoid'; | |
import { Function1 } from 'fp-ts/lib/function'; | |
type TUser = { | |
name: string; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Function1 } from 'fp-ts/lib/function'; | |
import { Option, none, some } from 'fp-ts/lib/Option'; | |
// T -> T | |
const identity = <T>(v: T): T => v; | |
// (B -> C, A -> B) -> A -> C | |
const compose = <A, B, C>(f: (Function1<B, C>), g: Function1<A, B>) => (x: A): C => f(g(x)); | |
const plusFive = (n: number): number => n + 5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Option, some, none, option } from "fp-ts/lib/Option"; | |
import { liftA4 } from 'fp-ts/lib/Apply'; | |
import { Function1 } from 'fp-ts/lib/function'; | |
// Task: find the total age of two users | |
type TPerson = { | |
name: string; | |
// age: number; | |
age: Option<number>; |