Hacker News new | ask | show | jobs
by edef 414 days ago
> I get to take for granted that a boolean is true or false (and not some brilliant third value!)

  [True, False, undefined] :: [Bool]
3 comments

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.

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
    | ^^^^^^^^^^^^^^^^^^^^^^^
See, you can even do quantum computing very naturally in Haskell.