Legitimate use of Boolean vs newtype (evidence)

I was reading this blog article about boolean blindness and was left thinking about situations where I’ve written functions like isX :: a -> Bool.

One case where it’s useful is for filtering which easily takes functions such as these. However, according to the evidence pattern, would it then be preferable to catMaybes . map prime?

Yes, or mapMaybe prime.

4 Likes

One case where it’s useful is for filtering which easily takes functions such as these. However, according to the evidence pattern, would it then be preferable to catMaybes . map prime ?

That is actually mentioned in the “learning by testing” episode of The Haskell Unfolder.

1 Like