re: Brag Post VIEW POST


In the last year I've learned a lot about functional programming -- enough to write my own abstract data type that fits nicely over fetchable and refreshable data that can have an error state (it also works for stuff like auth state, application loading state, and pretty much anything that has a concept of pending). I know that not everyone is into TypeScript and that even fewer people have delved into fp-ts, but for those that have, I'd be pretty excited if you took a look at Datum.

GitHub logo nullpub / datum

A monad that represents a refreshable option type and its transformation with an Either monad.

An fp-ts style ADT to capture the concept of an Option in progress.

build status Coverage Status npm downloads

dependency status dev dependency status peer dependency status


ADT for asynchronous data updated to work with fp-ts@2+.


Full Documentation

npm i @nll/datum fp-ts
import { datumEither, map } from '@nll/datum/lib/DatumEither';

import { sequenceT } from 'fp-ts/lib/Apply';
import { pipe } from 'fp-ts/lib/pipeable';

const myData = datumEither.of(1);
const myOtherData = datumEither.of(2);

const dataSequence = sequenceT(datumEither)(myData, myOtherData);

const result = pipe(
  map(([a, b]) => a + b)

// result.value.right === 3;
code of conduct - report abuse