[Haskell-cafe] Re: Laws and partial values
Jake McArthur
jake at pikewerks.com
Sat Jan 24 14:28:28 EST 2009
Thomas Davie wrote:
> But, as there is only one value in the Unit type, all values we have no information about must surely be that value
The flaw in your logic is your assumption that the Unit type has only
one value. Consider
bottom :: ()
bottom = undefined
Oviously, bottom is not (), but its type, nonetheless, is Unit. Unit
actually has both () and _|_. More generally, _|_ inhabits every Haskell
type, even types with no constructors (which itself requires a GHC
extension, of course):
data Empty
bottom' :: Empty
bottom' = undefined
If you only ever use total functions then you can get away with not
accounting for _|_. Perhaps ironically a function that doesn't account
for _|_ may be viewed philosophically as a partial function since its
contract doesn't accommodate all possible values.
- Jake
More information about the Haskell-Cafe
mailing list