newlandsvalley / purescript-midi

MIDI and Web MIDI support
MIT License
10 stars 1 forks source link

Generated code for Midi.Instruments is grossly inflated #9

Closed newlandsvalley closed 5 years ago

newlandsvalley commented 5 years ago

This is because we have a very large enumerated type for the (128) MIDI instrument names. The problem comes if we want to automatically generate an Ord instance - the code bloat goes through the roof.

The answer seems to be to write an Ord instance by hand by just comparing the stringified version of the names.

newlandsvalley commented 5 years ago

In fixing things I've learnt some frightening things about how bloated the generated code can get when dealing with ADTs which have a large number of simple constructors.

The generic instances also caused long compile times that seemed to grow exponentially with the number of entries.