[Haskell-cafe] Pointwise Monoid with DerivingVia on n-tuples
Joachim Breitner
mail at joachim-breitner.de
Wed Feb 6 14:25:56 UTC 2019
Hi,
Am Mittwoch, den 06.02.2019, 15:39 +0200 schrieb Georgi Lyubenov:
> Hi!
>
> I would like to use `DerivingVia` to do something like this:
> ```
> import Data.Semigroup
>
> data Four = Four Bool (Maybe Int) Bool Bool
> deriving (Semigroup, Monoid) via (Any, Option (First Int), Any, Any)
> ```
you probably know that, but this works:
newtype Four = Four (Bool, Maybe Int, Bool, Bool)
deriving (Semigroup, Monoid) via (Any, Option (First Int), Any, Any)
and is operationally equivalent to your data type. You can define a
pattern synonym to even the the other syntax.
Cheers,
Joachim
--
Joachim Breitner
mail at joachim-breitner.de
http://www.joachim-breitner.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20190206/22f30c89/attachment.sig>
More information about the Haskell-Cafe
mailing list