Niklas Hambüchen | 20 Dec 09:47 2012

GHC shows wrong line number in error?

Hello,

I have some code like this (the contents don't really matter):

42  data TestChain next = ChainEntry (forall b . TestG b) next
43                      | ChainDescribe String (Free TestChain...
44                      deriving (Functor)
45
46  -- deriving instance Show a => Show (TestChain a)
47
48  it :: (SomeT typ, Partition t typ) => String -> t -> ...
49  it desc test = liftF (ChainEntry (mkTestG test) ())

And get the error:

Clean.hs:49:43:
    Could not deduce (t ~ b)
    from the context (SomeT typ, Partition t typ)
      bound by the type signature for
                 it :: (SomeT typ, Partition t typ) =>
                       String -> t -> Free TestChain ()
      at Clean.hs:49:1-51
      `t' is a rigid type variable bound by
          the type signature for
            it :: (SomeT typ, Partition t typ) =>
                  String -> t -> Free TestChain ()
          at Clean.hs:49:1
      `b' is a rigid type variable bound by
          a type expected by the context: TestG b at Clean.hs:49:23
[...]
(Continue reading)

Roman Cheplyaka | 20 Dec 10:20 2012

Re: GHC shows wrong line number in error?

* Niklas Hambüchen <mail <at> nh2.me> [2012-12-20 08:47:17+0000]
> Hello,
> 
> I have some code like this (the contents don't really matter):
> 
> 42  data TestChain next = ChainEntry (forall b . TestG b) next
> 43                      | ChainDescribe String (Free TestChain...
> 44                      deriving (Functor)
> 45
> 46  -- deriving instance Show a => Show (TestChain a)
> 47
> 48  it :: (SomeT typ, Partition t typ) => String -> t -> ...
> 49  it desc test = liftF (ChainEntry (mkTestG test) ())
> 
> And get the error:
> 
> Clean.hs:49:43:
>     Could not deduce (t ~ b)
>     from the context (SomeT typ, Partition t typ)
>       bound by the type signature for
>                  it :: (SomeT typ, Partition t typ) =>
>                        String -> t -> Free TestChain ()
>       at Clean.hs:49:1-51
>       `t' is a rigid type variable bound by
>           the type signature for
>             it :: (SomeT typ, Partition t typ) =>
>                   String -> t -> Free TestChain ()
>           at Clean.hs:49:1
>       `b' is a rigid type variable bound by
>           a type expected by the context: TestG b at Clean.hs:49:23
(Continue reading)

Brandon Allbery | 20 Dec 19:27 2012
Picon

Re: GHC shows wrong line number in error?

On Thu, Dec 20, 2012 at 3:47 AM, Niklas Hambüchen <mail <at> nh2.me> wrote:
      `b' is a rigid type variable bound by
          a type expected by the context: TestG b at Clean.hs:49:23

It might be worth rephrasing this error message somehow, although I suspect it's written to fit into existing error reporting machinery that's not easy to adapt to fit the situation:  the location is not referring to "TestG b", but to "a type" on line 49, which is expected/"generated" by the context TestG b established previously.  You have to read pretty closely to figure that out, though.

--
brandon s allbery kf8nh                               sine nomine associates
allbery.b <at> gmail.com                                  ballbery <at> sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Gmane