Exploring the Type Space of an Application with Undefined
As you get more accustomed to using types to help you write correct programs, you’ll start to find that sometimes you want to test if the types for your functions are right before you spend the time implementing them. To help with that, Prelude includes the undefined function, which has the type undefined :: a. In other words, undefined is a value that inhabits all types. Of course it’s impossible to actually write a pure function that can have any value of any type, given no inputs, and indeed, if you try to use an undefined value you’ll get a runtime error:
| λ undefined |
| *** Exception: Prelude.undefined |
| CallStack (from HasCallStack): |
| error, called at libraries/base/GHC/Err.hs:80:14 ... |
Get Effective Haskell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.