[GHC] #13772: Cannot put HasCallStack on instances

GHC ghc-devs at haskell.org
Mon Jun 12 23:45:44 UTC 2017


#13772: Cannot put HasCallStack on instances
-------------------------------------+-------------------------------------
        Reporter:  augustss          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 {{{
 foo :: Monoid a => (a,a)
 foo = (mempty, mempty)

 bar :: Tree a
 bar = fst foo
 }}}
 You say you want a `HasCallStack` constraint just on the `Tree` instance
 of `mempty`.  But I don't think you can do that.  The call site of
 `mempty` is in `foo`, which is polymorhpic, works for any instance.  Only
 in `bar` do we beome specific to the `Tree` instance.

 It'd be fine if you wanted to say
 {{{
 class Monoid a where
   mempty :: HasCallStack => a
   ...
 }}}
 but I doubt you do.

 I don't see how to achieve what you want.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13772#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list