News for hackers. Stuff that matters.
Re:Building a Better Custom Haskell Prelude by drostie on Friday April 08, 2016 @01:04PM (#11456154)
Partly. Tsuyoshi Ito's answer on that page is IMO better than the original: `head` mattered at a time when pattern matching didn't exist; but today the only reason to use `head` is to form some sort of pointfree expression operating on lists that you've already filtered to be not-null. That is, you're doing `map (transform . head) . takeWhile (not . null)` or something, or maybe `takeWhile` is replaced with `filter` or so. If you cannot assert that the list is non-null then you have to handle two branches, and this code will generally look clearer if you pull it into a `where` clause and write it with pattern matching rather than with an adjusted `head` followed immediately by an appropriate `maybe` function.
Re:Building a Better Custom Haskell Prelude by marchelzo on Friday April 08, 2016 @03:27PM (#11457206)
With `[a] -> Maybe a`, it's not so bad if you use `catMaybes` from Data.Maybe.

map transform . catMaybes . map safeHead

Re:Building a Better Custom Haskell Prelude by koloron on Friday April 08, 2016 @03:51PM (#11457389)
Even better with mapMaybe:

    map transform . mapMaybe safeHead