Skip to Content
Effective Haskell
book

Effective Haskell

by Rebecca Skinner
July 2023
Intermediate to advanced
670 pages
17h 13m
English
Pragmatic Bookshelf
Content preview from Effective Haskell

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Grokking Functional Programming

Grokking Functional Programming

Michal Plachta
Grokking Algorithms

Grokking Algorithms

Aditya Bhargava
The Rust Programming Language, 2nd Edition

The Rust Programming Language, 2nd Edition

Steve Klabnik, Carol Nichols

Publisher Resources

ISBN: 9798888650400Errata Page