talira

Haskell's either-or-both data type, with Align for zipping with padding

open sourceBSD-3-Clausefree

these is a Haskell library for the These a b type, which holds a value of type a, a value of type b, or both, with functions in Data.These like those in Data.Either. Its repository also publishes semialign, whose Align class zips two structures with padding (a structural union, so the result is as long as the longer input) and Unalign undoes it; monad-chronicle, a ChronicleT monad transformer that is a hybrid of error and writer; and these-lens and these-optics with lens and optics combinators for These.

Problems it solves

  • zip two lists of different lengths in Haskell without dropping the extra elements
  • a Haskell result type that can carry warnings and a value at the same time
  • represent a value that may be on the left, the right or both sides in Haskell

Features

  • These a b: either a, b, or both
  • Align and Unalign for zipping with padding
  • ChronicleT, an error/writer hybrid monad transformer
  • lens and optics combinators