3 ms·
So it should have been: Double -> Maybe Double That would be the "right way" to fix this. (or create a type NotNilDouble, lol)
by cies 6y ago
So it should have been: Double -> Maybe Double
That would be the "right way" to fix this.
(or create a type NotNilDouble, lol)
- bidirectional 6y agoOr, controversially, define 1/0 = 0.[1] [1]: https://www.hillelwayne.com/post/divide-by-zero/ https://www.hillelwayne.com/post/divide-by-zero/
- cies 6y agoEnough controversy in defining std libs as it is :)
- the_af 6y agoThe "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.
- cies 6y agoIdris does well here: https://www.idris-lang.org/docs/current/prelude_doc/docs/Prelude.List.html#Prelude.List.head https://www.idris-lang.org/docs/current/prelude_doc/docs/Pre...'
- cies 6y agoIdris does well here: https://www.idris-lang.org/docs/current/contrib_doc/docs/Data.Nat.html#Data.Nat.divMod https://www.idris-lang.org/docs/current/contrib_doc/docs/Dat...