DEV Community

Discussion on: Functional design: Algebraic Data Types

Collapse
christiantakle profile image
Christian Takle

There is a small typo and don't know if one can submit a change to a post.

const fold = <A, R>(fa: Option<A>, onNone: () => R, onSome: (a: A) => R): R =>
  fa.type === 'None' ? onNone() : onSome(fa.value)
onNone: () => R

The following code block declare:

const s = fold(head([]), 'Empty array', a => String(a))

Its should have been:

const s = fold(head([]), () => 'Empty array', a => String(a))