Skip to content

Implicit call stack empty in instance declarations

Given the following code:

{-# LANGUAGE ImplicitParams #-}

import GHC.Stack

class Foo a where
    foo :: a -> String

main = putStrLn $ foo ()

In GHC 7.11.20151216, the following instances result in no output:

instance Foo () where
    foo () = prettyCallStack ?loc
fooHelper = prettyCallStack ?loc

instance Foo () where
    foo () = fooHelper

Though this one does:

fooHelper () = prettyCallStack ?loc

instance Foo () where
    foo = fooHelper

{-
CallStack (from ImplicitParams):
  fooHelper, called at implicit.hs:11:11 in main:Main
-}

Including explicit signatures with -XInstanceSigs has no effect.

The aforementioned instances all yield output with GHC 7.10.3 (after replacing prettyCallStack with showCallStack):

?loc, called at implicit.hs:9:28 in main:Main
Edited by pikajude
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information