# Deriving Eq and Show for tuples having more than 5 elements

**URL:** <https://forum.canton.network/t/deriving-eq-and-show-for-tuples-having-more-than-5-elements/4271>\
**Category:** App Development\
**Tags:** features and bugs\
**Created:** [April 7, 2022, 2:22pm UTC](https://forum.canton.network/t/deriving-eq-and-show-for-tuples-having-more-than-5-elements/4271 "2022-04-07T14:22:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gyorgybalazsi](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gyorgybalazsi/32/684_2.png) [@gyorgybalazsi](https://forum.canton.network/u/gyorgybalazsi)\
**Post date:** [April 7, 2022, 2:22pm UTC](https://forum.canton.network/t/deriving-eq-and-show-for-tuples-having-more-than-5-elements/4271/1 "2022-04-07T14:22:29Z")

</div>

Tuples bigger than 5 elements are not instances of the Show typeclass:

> **instance** [Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) ()
> 
> **instance** ([Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) a, [Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) b) =\> [Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) (a, b)
> 
> **instance** ([Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) a, [Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) b, [Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) c) =\> [Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) (a, b, c)
> 
> **instance** ([Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) a, [Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) b, [Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) c, [Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) d) =\> [Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) (a, b, c, d)
> 
> **instance** ([Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) a, [Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) b, [Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) c, [Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) d, [Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) e) =\> [Show](https://docs.daml.com/daml/stdlib/Prelude.html#class-ghc-show-show-65360) (a, b, c, d, e)

Can I somehow circumvent this limitation?

---

<div class="post-metadata">

**Author:** ![stefanobaghino-da](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stefanobaghino-da/32/7057_2.png) [@stefanobaghino-da](https://forum.canton.network/u/stefanobaghino-da)\
**Post date:** [April 7, 2022, 2:54pm UTC](https://forum.canton.network/t/deriving-eq-and-show-for-tuples-having-more-than-5-elements/4271/2 "2022-04-07T14:54:25Z")

</div>

If you have such a big tuple, in terms of readability you may probably want to think about turning your tuple in a record with explicit names, which are likely to make your code more readable.

In terms of circumventing the limitation, can you write your own instance where you need it, like so?

```haskell
instance (Show a, Show b, Show c, Show d, Show e, Show f) => Show (a, b, c, d, e, f)

```

---

<div class="post-metadata">

**Author:** ![gyorgybalazsi](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gyorgybalazsi/32/684_2.png) [@gyorgybalazsi](https://forum.canton.network/u/gyorgybalazsi)\
**Post date:** [April 7, 2022, 3:27pm UTC](https://forum.canton.network/t/deriving-eq-and-show-for-tuples-having-more-than-5-elements/4271/3 "2022-04-07T15:27:19Z")

</div>

> [@stefanobaghino-da](#):
>
> `instance (Show a, Show b, Show c, Show d, Show e, Show f) => Show (a, b, c, d, e, f)`

Yeah, thank you, actually it’s easy;

```haskell
instance (Show a, Show b, Show c, Show d, Show e, Show f) => Show (a, b, c, d, e, f) where 
  show (a,b,c,d,e,f) = "("<> show a <> "," <> show b <> "," <> show c <> "," <> show d <> "," <> show e <> "," <> show f <> ")"

```

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [April 8, 2022, 7:31am UTC](https://forum.canton.network/t/deriving-eq-and-show-for-tuples-having-more-than-5-elements/4271/4 "2022-04-08T07:31:59Z")

</div>

> [@gyorgybalazsi](#):
>
> Yeah, thank you, actually it’s easy;

I’d still encourage you to consider the record-with-named-fields approach. There’s a reason we chose not to include Show instances for larger tuples despite it being very easy to do.

---

<div class="post-metadata">

**Author:** ![gyorgybalazsi](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gyorgybalazsi/32/684_2.png) [@gyorgybalazsi](https://forum.canton.network/u/gyorgybalazsi)\
**Post date:** [April 8, 2022, 7:57am UTC](https://forum.canton.network/t/deriving-eq-and-show-for-tuples-having-more-than-5-elements/4271/5 "2022-04-08T07:57:26Z")

</div>

Yes, generally I don’t use large tuples, this is a special situation where I use a library which uses them and 5 elements are not enough.

---

<div class="post-metadata">

**Author:** ![stefanobaghino-da](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stefanobaghino-da/32/7057_2.png) [@stefanobaghino-da](https://forum.canton.network/u/stefanobaghino-da)\
**Post date:** [April 8, 2022, 8:03am UTC](https://forum.canton.network/t/deriving-eq-and-show-for-tuples-having-more-than-5-elements/4271/6 "2022-04-08T08:03:32Z")

</div>

Is there something in particular that’s preventing you from turning the tuple into a record with explicit names? I don’t want to judge, I’m mostly curious if there’s something we can do to promote what we perceive as good practices. If you have some code to share we’re very happy to have a look. 😃
