I have just confirmed that we can specify HasCallStack separately for different instance of same typeclass, and here is the test code.


Oliver Charles <ollie@ocharles.org.uk> 于2019年6月17日周一 上午3:02写道:
Surely then the call stack is only foldr1, and not foldr1's callsite?

On Sun, 16 Jun 2019, 8:27 pm Henning Thielemann, <lemming@henning-thielemann.de> wrote:

On Sun, 16 Jun 2019, Simon Jakobi wrote:

> >  I think only the partial implementations should get that constraint.

> Oops, I had the misconception that one couldn't add a HasCallStack
> constraint to method implementations.

I think you have to declare:

instance Foldable [] where
    foldl1 = foldl1List

foldl1List :: HasCallStack => (a->a->a) -> [a] -> a
foldl1List = ...

Would this work?_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries