Avoiding Enum generic-deriving boilerplate


#1

In Haskell, I would do the following:

data SomethingA = Foo | Bar         deriving (Eq, Ord, Show, Bounded, Enum)
data SomethingB = Baz | Bop | Bloop deriving (Eq, Ord, Show, Bounded, Enum)

To accomplish the same thing in PureScript, I do all of this:

data SomethingA = Foo | Bar
data SomethingB = Baz | Bop | Bloop
derive instance _0_ ∷ Generic SomethingA _
derive instance _1_ ∷ Eq SomethingA
derive instance _2_ ∷ Ord SomethingA
instance _3_ ∷ Show SomethingA where
  show = genericShow
instance _4_ ∷ Enum SomethingA where
  succ = genericSucc
  pred = genericPred
instance _5_ ∷ Bounded SomethingA where
  top = genericTop
  bottom = genericBottom
instance _6_ ∷ BoundedEnum SomethingA where
  cardinality = genericCardinality
  toEnum = genericToEnum
  fromEnum = genericFromEnum
derive instance _7_ ∷ Generic SomethingB _
derive instance _8_ ∷ Eq SomethingB
derive instance _9_ ∷ Ord SomethingB
instance _10_ ∷ Show SomethingB where
  show = genericShow
instance _11_ ∷ Enum SomethingB where
  succ = genericSucc
  pred = genericPred
instance _12_ ∷ Bounded SomethingB where
  top = genericTop
  bottom = genericBottom
instance _13_ ∷ BoundedEnum SomethingB where
  cardinality = genericCardinality
  toEnum = genericToEnum
  fromEnum = genericFromEnum

Two simple, readable statements become thirty-two lines of mush with fourteen useless function names. I find myself using this pattern all the time in order to collect everything with enumFromTo bottom top. Is there a better way?