[Haskell-cafe] New type of expressions containing (error ...) includes noisy implicit parameter

Eric Seidel eric at seidel.io
Sun Feb 14 00:02:40 UTC 2016


On Sat, Feb 13, 2016, at 15:32, Christopher Allen wrote:
> There's another problem I discovered with HasCallStack. The implicit
> parameter constraint breaks sharing behavior for examples that use
> bottom.
 
This is a necessary consequence of the implementation of callstack-aware
functions as overloaded functions. It's really no different from using a
type-class, and is in my opinion the correct behavior. 

It seems what you really want is a way to prevent GHC from inferring the
HasCallStack constraint in the first place. That's doable with an
explicit type signature (or even a combinator to wrap the expression),
but this isn't a great solution for your book. 

What I'd suggest instead is to define your own undefined in a
Prelude-replacement (or simplification if you will). Something like

undefined :: a
undefined = withFrozenCallStack emptyCallStack Prelude.undefined

should work to remove all traces of CallStacks (including when it blows
up). error can be similarly wrapped to avoid having to deal with
CallStacks, and $ and the FTP-related functions can be specialized to
less-polymorphic versions that are easier to explain to beginners (at
least until they're ready to be exposed to the real versions).

I'm sorry that this change has caused you trouble. 


More information about the Haskell-Cafe mailing list