I would add that a non-semantic signature is a lie. If we have `foo :: Int -> [Bar]` and it always produces 0 or 1 `Bar` the list is a lie. `foo :: Int -> Maybe Bar` is the honest signature.https://twitter.com/jdegoes/status/1069624608083464192 …
Not necessarily. Sometimes, the next thing you want to do is pass the result to a generic function that expects a list of Bar, and it's appropriate to return a list instead of an option. What next, you'll want a special type for prime numbers? Use dependent types!
-
-
I think that is a concern of the call site, and so should be handled at the call site. I said the codomain should be as close to the image as possible. If we are in a language without dependant types, we are limited in what is possible. A prime number type would be lovely.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
Read my blog!