Re:Propositions as Types [pdf]
by edef on Tuesday May 06, 2025 @12:03PM
(#43906667)
> I get to take for granted that a boolean is true or false (and not some brilliant third value!)
[ Parent
| on HN ]
The traditional third value is actually FileNotFound: https://thedailywtf.com/articles/what_is_truth_0x3f_
but in Haskell, yes, it's undefined. Which isn't a real value! For example, infinite loops are undefined. Theorists like to call it a value of every type, but in practical terms, it's more like a computation that never produces a value. The builtin "undefined" can be written as an infinite loop ("undefined = undefined") and many other pure infinite loops can also act as undefined values. The runtime is able to catch some and crash instead of hanging, but not others.
Re:Propositions as Types [pdf]
by ddellacosta on Tuesday May 06, 2025 @05:33PM
(#43909877)
See, you can even do quantum computing very naturally in Haskell.
Nah.
check :: Bool -> a
check True = undefined
check False = undefined
check _ = undefined
7:1: warning: [GHC-53633] [-Woverlapping-patterns]
Pattern match is redundant
In an equation for ‘check’: check _ = ...
|
7 | check _ = undefined
| ^^^^^^^^^^^^^^^^^^^^^^^