Skip to content

Latest commit

 

History

History
18 lines (14 loc) · 308 Bytes

README.md

File metadata and controls

18 lines (14 loc) · 308 Bytes

Usage

import * as E from './either';


const log = (x: number): E.Either<string, number> => {
  if (x < 0) return E.left('X cannot be negative');
  return E.right(Math.log(x));
};

console.log(
  E.match(
    (err) => `Error is ${err}`,
    (value) => `Result is ${value}`
  )(log(12))
);