Zulip Chat Archive

Stream: new members

Topic: Workaround for deriving Repr in types with non Repr fields


Luis Enrique Muñoz Martín (Jul 22 2024 at 11:19):

Hi, I have a structure that contains a HashMap field, which does not implement Repr. What's the common workaround to have my struct with Repr:

structure MyType where
  nonRepr : HashMap Nat Int  -- This does not implement Repr
deriving Repr -- <- I want to do this

Henrik Böving (Jul 22 2024 at 12:53):

You can have a custom instance : Repr MyType if you want.

Kyle Miller (Jul 22 2024 at 15:27):

Or define instance [Repr X] [Repr Y] : Repr (HashMap X Y) first


Last updated: May 02 2025 at 03:31 UTC