News for hackers. Stuff that matters.
Re:Haskell: The Bad Parts, part 2 (2020) by cies on Tuesday February 09, 2021 @12:43PM (#26080376)
So it should have been: Double -> Maybe Double

That would be the "right way" to fix this.

(or create a type NotNilDouble, lol)

Re:Haskell: The Bad Parts, part 2 (2020) by bidirectional on Tuesday February 09, 2021 @02:00PM (#26081258)
Or, controversially, define 1/0 = 0.[1]

[1]: https://www.hillelwayne.com/post/divide-by-zero/

Re:Haskell: The Bad Parts, part 2 (2020) by cies on Tuesday February 09, 2021 @02:01PM (#26081267)
Enough controversy in defining std libs as it is :)
Re:Haskell: The Bad Parts, part 2 (2020) by the_af on Tuesday February 09, 2021 @03:11PM (#26081897)
The "right" way for division by zero is controversial, though maybe that would be a solution.

It's clearer for partial function "head :: [a] -> a", which takes the first of a list if it exists, and explodes without dignity if the list is empty (this is what makes head partial).

A proposal is "head :: [a] -> Maybe a", so head returns Nothing when the list is empty.

Re:Haskell: The Bad Parts, part 2 (2020) by cies on Wednesday February 10, 2021 @06:04AM (#26087721)
Re:Haskell: The Bad Parts, part 2 (2020) by cies on Wednesday February 10, 2021 @06:06AM (#26087733)