concept seq in category haskell

appears as: seq
Haskell in Depth MEAP V12

This is an excerpt from Manning's book Haskell in Depth MEAP V12.

The seq function

Haskell provides somewhat magic seq function, which is defined in terms of strictness. Its type is a → b → b so it looks like it ignores the first argument. In fact, it’s not, because its implementation is guaranteed to adhere to the following two rules:

ghci> let _ = undefined in "OK"
"OK"
ghci> :set -XBangPatterns
ghci> let !_ = "BAD" in "OK"
"OK"
ghci> let !_ = undefined in "OK"
"*** Exception: Prelude.undefined
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest