purescript-quickcheck icon indicating copy to clipboard operation
purescript-quickcheck copied to clipboard

Add a Testable instance for Either

Open Rembane opened this issue 6 years ago • 2 comments

Result is not a very composable data type, which makes it clunky to work with. If we add a Testable instance for Either String Unit we can use the whole machinery around the Either type and make testing a much more pleasant experience.

Contrived example of pleasant experience:

p :: Array String -> Either String Unit
p  a = do
  i <- note "Couldn't find hello." (elemIndex "hello" a)
  if mod i 2 > 0 
    then Left "hello isn't on an index divisible by two."
    else Right unit

In my opinion this experience becomes pleasant because I can use do-notation, note and a load of other niceties.

If you think this is a good idea I can implement the instance(s) needed and make a PR.

Rembane avatar May 16 '18 17:05 Rembane

Seems reasonable to me!

garyb avatar Jun 05 '18 10:06 garyb

Then I'll start hacking and get back with a PR in a few weeks.

Rembane avatar Jun 05 '18 14:06 Rembane