suppress warning "Defined but not used: type variable ‘x’" in GHC-8.0

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

suppress warning "Defined but not used: type variable ‘x’" in GHC-8.0

Henning Thielemann

GHC-8.0 emits several new warnings of this kind:

    Defined but not used: type variable ‘x’

for declarations like

    type instance Snd x y = y

Enthusiastically, I started to replace unused type function arguments by
underscores, only to find out that older GHC versions do not accept that.
With what option can I disable this warning? Or can it be removed from
-Wall for now?
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: suppress warning "Defined but not used: type variable ‘x’" in GHC-8.0

Carter Schonwald
Have you tried _x instead?

On Saturday, January 9, 2016, Henning Thielemann <[hidden email]> wrote:

GHC-8.0 emits several new warnings of this kind:

   Defined but not used: type variable ‘x’

for declarations like

   type instance Snd x y = y

Enthusiastically, I started to replace unused type function arguments by underscores, only to find out that older GHC versions do not accept that. With what option can I disable this warning? Or can it be removed from -Wall for now?

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: suppress warning "Defined but not used: type variable ‘x’" in GHC-8.0

Henning Thielemann

On Sat, 9 Jan 2016, Carter Schonwald wrote:

> Have you tried _x instead?

Ah, this solves the problem! Almost.

I have an instance like this one:

instance (Natural n) => Num.Integer (Un n) where
     type Repr (Un _n) = Unary


GHC-7.6.3 and GHC-7.4.2 complain:
     Type indexes must match class instance head
     Found `Un _n' but expected `Un n'
     In the type synonym instance declaration for `Num.Repr'
     In the instance declaration for `Num.Integer (Un n)'


GHC-7.8.4, GHC-7.10.3 and GHC-8.0 are happy with the difference.
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: suppress warning "Defined but not used: type variable ‘x’" in GHC-8.0

Richard Eisenberg-2

On Jan 9, 2016, at 6:44 PM, Henning Thielemann <[hidden email]> wrote:

>
> instance (Natural n) => Num.Integer (Un n) where
>    type Repr (Un _n) = Unary
>
>
> GHC-7.6.3 and GHC-7.4.2 complain:
>    Type indexes must match class instance head
>    Found `Un _n' but expected `Un n'
>    In the type synonym instance declaration for `Num.Repr'
>    In the instance declaration for `Num.Integer (Un n)'
>
>
> GHC-7.8.4, GHC-7.10.3 and GHC-8.0 are happy with the difference.

I'm surprised this is accepted at all. Looks like hogwash to me. I think you should post a bug report.

Richard
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: suppress warning "Defined but not used: type variable ‘x’" in GHC-8.0

Henning Thielemann

On Mon, 11 Jan 2016, Richard Eisenberg wrote:

> On Jan 9, 2016, at 6:44 PM, Henning Thielemann <[hidden email]> wrote:
>>
>> instance (Natural n) => Num.Integer (Un n) where
>>    type Repr (Un _n) = Unary
>>
>>
>> GHC-7.6.3 and GHC-7.4.2 complain:
>>    Type indexes must match class instance head
>>    Found `Un _n' but expected `Un n'
>>    In the type synonym instance declaration for `Num.Repr'
>>    In the instance declaration for `Num.Integer (Un n)'
>>
>>
>> GHC-7.8.4, GHC-7.10.3 and GHC-8.0 are happy with the difference.
>
> I'm surprised this is accepted at all. Looks like hogwash to me. I think you should post a bug report.

Ok, but then GHC must not warn about the unused argument of Repr.
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: suppress warning "Defined but not used: type variable ‘x’" in GHC-8.0

Edward Kmett-2
As a data point I now get thousands of occurrences of this warning across my packages.

It is quite annoying.

class Foo a where
  type Bar a

instance Foo [a] where
  type Bar [a] = Int

is enough to trigger it.

And you can't turn it off by using _ as

instance Foo [_] where
  type Bar [_] = Int

isn't legal.

I've been avoiding it for now by using

  if impl(ghc >= 8)

    ghc-options: -fno-warn-unused-matches

but this is a pretty awful addition to this warning as it stands.

-Edward

On Mon, Jan 11, 2016 at 2:12 PM, Henning Thielemann <[hidden email]> wrote:

On Mon, 11 Jan 2016, Richard Eisenberg wrote:

On Jan 9, 2016, at 6:44 PM, Henning Thielemann <[hidden email]> wrote:

instance (Natural n) => Num.Integer (Un n) where
   type Repr (Un _n) = Unary


GHC-7.6.3 and GHC-7.4.2 complain:
   Type indexes must match class instance head
   Found `Un _n' but expected `Un n'
   In the type synonym instance declaration for `Num.Repr'
   In the instance declaration for `Num.Integer (Un n)'


GHC-7.8.4, GHC-7.10.3 and GHC-8.0 are happy with the difference.

I'm surprised this is accepted at all. Looks like hogwash to me. I think you should post a bug report.

Ok, but then GHC must not warn about the unused argument of Repr.

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: suppress warning "Defined but not used: type variable ‘x’" in GHC-8.0

Andrew Farmer-3

Can't you just:

instance Foo [a] where
  type Bar [_a] = Int

(At least I think I did that somewhere...)

On Jan 16, 2016 9:24 PM, "Edward Kmett" <[hidden email]> wrote:
As a data point I now get thousands of occurrences of this warning across my packages.

It is quite annoying.

class Foo a where
  type Bar a

instance Foo [a] where
  type Bar [a] = Int

is enough to trigger it.

And you can't turn it off by using _ as

instance Foo [_] where
  type Bar [_] = Int

isn't legal.

I've been avoiding it for now by using

  if impl(ghc >= 8)

    ghc-options: -fno-warn-unused-matches

but this is a pretty awful addition to this warning as it stands.

-Edward

On Mon, Jan 11, 2016 at 2:12 PM, Henning Thielemann <[hidden email]> wrote:

On Mon, 11 Jan 2016, Richard Eisenberg wrote:

On Jan 9, 2016, at 6:44 PM, Henning Thielemann <[hidden email]> wrote:

instance (Natural n) => Num.Integer (Un n) where
   type Repr (Un _n) = Unary


GHC-7.6.3 and GHC-7.4.2 complain:
   Type indexes must match class instance head
   Found `Un _n' but expected `Un n'
   In the type synonym instance declaration for `Num.Repr'
   In the instance declaration for `Num.Integer (Un n)'


GHC-7.8.4, GHC-7.10.3 and GHC-8.0 are happy with the difference.

I'm surprised this is accepted at all. Looks like hogwash to me. I think you should post a bug report.

Ok, but then GHC must not warn about the unused argument of Repr.

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: suppress warning "Defined but not used: type variable ‘x’" in GHC-8.0

Edward Kmett-2
No, the type instance must match the class heading.

I can use

instance Foo [_a] where
  type Bar [_a] = Int
  whatever = ... where
    bar :: _a -> Int
    bar = ...

but that is a needlessly messy thing to request of every package everywhere.

The arguments being pattern matched in a class associated type aren't really just bindings, they reference the surrounding context and so shouldn't be treated the same as the basic type family case.

It isn't just the class associated type being mangled, it is every type variable that comes from the instance head in the entire body of every instance that happens to have a class associated type in it.

Note that in the example above I added another ScopedTypeVariables reference to the same parameter, but it _also_ must be mangled despite having absolutely nothing to do with the class associated type.

The existing convention has worked since 6.10 or so, when all of this stuff was invented in the first place, and the new state of affairs is clearly worse.

-Edward

On Sun, Jan 17, 2016 at 3:16 AM, Andrew Farmer <[hidden email]> wrote:

Can't you just:

instance Foo [a] where
  type Bar [_a] = Int

(At least I think I did that somewhere...)

On Jan 16, 2016 9:24 PM, "Edward Kmett" <[hidden email]> wrote:
As a data point I now get thousands of occurrences of this warning across my packages.

It is quite annoying.

class Foo a where
  type Bar a

instance Foo [a] where
  type Bar [a] = Int

is enough to trigger it.

And you can't turn it off by using _ as

instance Foo [_] where
  type Bar [_] = Int

isn't legal.

I've been avoiding it for now by using

  if impl(ghc >= 8)

    ghc-options: -fno-warn-unused-matches

but this is a pretty awful addition to this warning as it stands.

-Edward

On Mon, Jan 11, 2016 at 2:12 PM, Henning Thielemann <[hidden email]> wrote:

On Mon, 11 Jan 2016, Richard Eisenberg wrote:

On Jan 9, 2016, at 6:44 PM, Henning Thielemann <[hidden email]> wrote:

instance (Natural n) => Num.Integer (Un n) where
   type Repr (Un _n) = Unary


GHC-7.6.3 and GHC-7.4.2 complain:
   Type indexes must match class instance head
   Found `Un _n' but expected `Un n'
   In the type synonym instance declaration for `Num.Repr'
   In the instance declaration for `Num.Integer (Un n)'


GHC-7.8.4, GHC-7.10.3 and GHC-8.0 are happy with the difference.

I'm surprised this is accepted at all. Looks like hogwash to me. I think you should post a bug report.

Ok, but then GHC must not warn about the unused argument of Repr.

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users



_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: suppress warning "Defined but not used: type variable ‘x’" in GHC-8.0

Edward Kmett-2
Moreover those _'d type variables would infect all of our haddocks.

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: suppress warning "Defined but not used: type variable ‘x’" in GHC-8.0

Oliver Charles-3
Inferred types and errors too, I would imagine.

On Sun, 17 Jan 2016 2:45 pm Edward Kmett <[hidden email]> wrote:
Moreover those _'d type variables would infect all of our haddocks.
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

RE: suppress warning "Defined but not used: type variable ‘x’" in GHC-8.0

Simon Peyton Jones
In reply to this post by Edward Kmett-2

I have created not one but three tickets arising from this thread:

 

·         https://ghc.haskell.org/trac/ghc/ticket/11449

·         https://ghc.haskell.org/trac/ghc/ticket/11450

·         https://ghc.haskell.org/trac/ghc/ticket/11451

 

I’d love comments on them: which of the three matter most to you folk?  The first also involves a flag-naming question.

 

Simon

 

From: Glasgow-haskell-users [mailto:[hidden email]] On Behalf Of Edward Kmett
Sent: 17 January 2016 14:44
To: Andrew Farmer <[hidden email]>
Cc: Henning Thielemann <[hidden email]>; [hidden email]
Subject: Re: suppress warning "Defined but not used: type variable ‘x’" in GHC-8.0

 

No, the type instance must match the class heading.

 

I can use

 

instance Foo [_a] where

  type Bar [_a] = Int

  whatever = ... where

    bar :: _a -> Int

    bar = ...

 

but that is a needlessly messy thing to request of every package everywhere.

 

The arguments being pattern matched in a class associated type aren't really just bindings, they reference the surrounding context and so shouldn't be treated the same as the basic type family case.

 

It isn't just the class associated type being mangled, it is every type variable that comes from the instance head in the entire body of every instance that happens to have a class associated type in it.

 

Note that in the example above I added another ScopedTypeVariables reference to the same parameter, but it _also_ must be mangled despite having absolutely nothing to do with the class associated type.

 

The existing convention has worked since 6.10 or so, when all of this stuff was invented in the first place, and the new state of affairs is clearly worse.

 

-Edward

 

On Sun, Jan 17, 2016 at 3:16 AM, Andrew Farmer <[hidden email]> wrote:

Can't you just:

instance Foo [a] where
  type Bar [_a] = Int

(At least I think I did that somewhere...)

On Jan 16, 2016 9:24 PM, "Edward Kmett" <[hidden email]> wrote:

As a data point I now get thousands of occurrences of this warning across my packages.

 

It is quite annoying.

 

class Foo a where

  type Bar a

 

instance Foo [a] where

  type Bar [a] = Int

 

is enough to trigger it.

 

And you can't turn it off by using _ as

instance Foo [_] where
  type Bar [_] = Int

isn't legal.

I've been avoiding it for now by using

  if impl(ghc >= 8)

    ghc-options: -fno-warn-unused-matches

but this is a pretty awful addition to this warning as it stands.

-Edward

 

On Mon, Jan 11, 2016 at 2:12 PM, Henning Thielemann <[hidden email]> wrote:


On Mon, 11 Jan 2016, Richard Eisenberg wrote:

On Jan 9, 2016, at 6:44 PM, Henning Thielemann <[hidden email]> wrote:


instance (Natural n) => Num.Integer (Un n) where
   type Repr (Un _n) = Unary


GHC-7.6.3 and GHC-7.4.2 complain:
   Type indexes must match class instance head
   Found `Un _n' but expected `Un n'
   In the type synonym instance declaration for `Num.Repr'
   In the instance declaration for `Num.Integer (Un n)'


GHC-7.8.4, GHC-7.10.3 and GHC-8.0 are happy with the difference.


I'm surprised this is accepted at all. Looks like hogwash to me. I think you should post a bug report.


Ok, but then GHC must not warn about the unused argument of Repr.


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users

 


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users

 


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users