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 * as React from 'react' | |
import { compose } from 'redux' | |
import { reader } from 'fp-ts/lib/Reader' | |
type StateContext<A> = [A, (a: A) => void] | |
const keepMax: (input: StateContext<number>) => StateContext<number> = | |
([state, setState]) => { | |
const keepMaxSetState = React.useCallback((n: number) => { |
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 scalaz.Monad | |
import scalaz._, Scalaz._ | |
object OptionTest { | |
case class User(name: String, image: String) | |
// Gets a user, optionally |
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 scalaz.Monad | |
import scalaz._, Scalaz._ | |
object OptionTest { | |
case class User(name: String, image: String) | |
// Gets a user, optionally |
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 { Monad2 } from "fp-ts/lib/Monad"; | |
import { HKT } from "fp-ts/lib/HKT"; | |
import { createSelector, Selector } from "reselect"; | |
import { sequenceT } from "fp-ts/lib/Apply"; | |
import { Do } from "fp-ts-contrib/lib/Do"; | |
declare module "fp-ts/lib/HKT" { | |
interface URI2HKT2<L, A> { | |
Selector: Selector<L, 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 * as React from "react"; | |
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; | |
type Func = (...args: any) => any; | |
export type Lit = string | number | boolean | undefined | null | void | {}; | |
export const tuple = <T extends Lit[]>(...args: T) => args; | |
type RenderProp<Props, SuppliedValue> = React.FC< | |
Props & { children: (s: SuppliedValue) => React.ReactNode } | |
>; | |
interface InferableHOC<ProvidedProps> { |
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 { array } from 'fp-ts/lib/Array' | |
import { io, IO } from 'fp-ts/lib/IO' | |
import { none, option, some, Option } from 'fp-ts/lib/Option' | |
import { getTraversableComposition } from 'fp-ts/lib/Traversable2v' | |
const T = getTraversableComposition(array, option) | |
T.traverse(???) |
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
/** | |
* This method sequences an array of Monads, chaining each one into the next. | |
* The result will be one Monad of a list of each unwrapped value. | |
*/ | |
function sequenceM(Type) { | |
return ms => { | |
function doIt(mArr, restMs) { | |
if(restMs.length === 0) { | |
return mArr; | |
} else { |
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
// All works with all fantasy-land applicatives: https://github.com/fantasyland/fantasy-land#applicative | |
// It turns an array of applicatives into an applicative of array | |
function All(Type) { | |
return values => | |
values.reduce((aggOp, aOp) => { | |
// crocks doesn't support ['fantasy-land/ap'] | |
return aggOp['fantasy-land/ap'](aOp['fantasy-land/map'](a => { | |
return agg => agg.concat([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
// Do works with any Monad that implements the fantasy-land spec | |
// https://github.com/fantasyland/fantasy-land#monad | |
function Do(Type) { return (a, ...fns) => { | |
function doIt(as, fns) { | |
const [fn, ...rest] = fns; | |
if(rest.length === 0) { | |
return as['fantasy-land/chain'](a2s => { | |
return Type['fantasy-land/of'](fn.apply(null, a2s)); | |
}); | |
} else { |
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
// Do works with any Monad that implements the fantasy-land spec | |
// https://github.com/fantasyland/fantasy-land#monad | |
function Do(Type) { return (a, ...fns) => { | |
function doIt(as, fns) { | |
const [fn, ...rest] = fns; | |
if(rest.length === 0) { | |
return as['fantasy-land/chain'](a2s => { | |
return Type['fantasy-land/of'](fn.apply(null, a2s)); | |
}); | |
} else { |