Closed samhh closed 1 year ago
Rather than define this, lift the monoid and reuse memptyWhen
/memptyUnless
e.g.:
import * as E from "fp-ts/Either"
import * as Str from "fp-ts/string"
import { memptyUnless } from "fp-ts-std/Monoid"
import { getApplicativeMonoid } from "fp-ts/Applicative"
declare const cond: boolean
const M = getApplicativeMonoid(E.Applicative)(Str.Monoid)
memptyUnless(M)(cond)(() => etc)
Web use case: https://github.com/unsplash/unsplash-web/pull/10127#discussion_r1219062840