How about a "deriving defaulted" deriving strategy

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

How about a "deriving defaulted" deriving strategy

Andrew Martin
I was just doing the usual incantation for an exception type:

    data DatagramException = ...
      deriving stock (Eq,Show)
    instance Exception Datagram

And it suddenly hit me what a shame it was that I cannot put the Exception instance in a deriving clause like the others. It would be more visually pleasing to write:

    data DatagramException = ...
      deriving stock (Eq,Show)
      deriving defaulted (Exception)

--
-Andrew Thaddeus Martin

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

Re: How about a "deriving defaulted" deriving strategy

Matthew Pickering
Is that not what DeriveAnyClass does?

On Mon, Jan 14, 2019 at 4:13 PM Andrew Martin <[hidden email]> wrote:

>
> I was just doing the usual incantation for an exception type:
>
>     data DatagramException = ...
>       deriving stock (Eq,Show)
>     instance Exception Datagram
>
> And it suddenly hit me what a shame it was that I cannot put the Exception instance in a deriving clause like the others. It would be more visually pleasing to write:
>
>     data DatagramException = ...
>       deriving stock (Eq,Show)
>       deriving defaulted (Exception)
>
> --
> -Andrew Thaddeus Martin
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: How about a "deriving defaulted" deriving strategy

Andrew Martin
Dang it. That's exactly what does. I had somehow convinced myself that it only worked with instances that used GHC.Generics.

On Mon, Jan 14, 2019 at 11:14 AM Matthew Pickering <[hidden email]> wrote:
Is that not what DeriveAnyClass does?

On Mon, Jan 14, 2019 at 4:13 PM Andrew Martin <[hidden email]> wrote:
>
> I was just doing the usual incantation for an exception type:
>
>     data DatagramException = ...
>       deriving stock (Eq,Show)
>     instance Exception Datagram
>
> And it suddenly hit me what a shame it was that I cannot put the Exception instance in a deriving clause like the others. It would be more visually pleasing to write:
>
>     data DatagramException = ...
>       deriving stock (Eq,Show)
>       deriving defaulted (Exception)
>
> --
> -Andrew Thaddeus Martin
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


--
-Andrew Thaddeus Martin

_______________________________________________
Libraries mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries