fp-ts
TypeScriptlibrary
Giulio Canti

Effect-TSmerge
>Announcement: following the official decision to merge the fp-ts project with the Effect-TS ecosystem, active development has been transferred to the repository https://github.com/Effect-TS/data. ref

>@EffectTS_: The news is out! 📢
>We have made the decision to unite and collaborate on *Effect* as a generational project that aims to create a more cohesive and powerful ecosystem of libraries that are accessible and useful to developers of all levels.






etc.





import
2
import { Option } from 'fp-ts/lib/Option'; // CommonJS
import { Option } from 'fp-ts/es6/Option'; // ESModule
ESModuleTreeShaking
Node.jsCommonJS使

pipe
import * as O from 'fp-ts/lib/Option'
import { identity } from 'fp-ts/lib/function'
import { pipeable } from 'fp-ts'
pipeable.pipe(
O.some(42), // O.Option<number>
O.chain(n => n === 42 ? O.some('Answer to Everything') : O.none), // (ma: O.Option<number>) => O.Option<string>
O.fold(() => 'No Answer', identity) // (ma: O.Option<string>) => string
) // string



18~100


io-tsfp-ts使Twitter APISample

fp-ts
使使
parserREST
IOResult使
Monad使
TSmrsekut
fp-ts便TSfp-ts


fp-ts


pursfp-ts




instances



Eithererror
import * as E from 'fp-ts/lib/Either';
import { sequenceT } from 'fp-ts/lib/Apply';
import * as A from 'fp-ts/lib/Array';
const hoge = E.getApplicativeValidation(A.getMonoid<string>());
console.log(sequenceT(hoge)(E.left(['a']), E.left(['b'])));
// { _tag: 'Left', left: [ 'a', 'b' ] }