Hacker News new | ask | show | jobs
by harpocrates 3043 days ago
> People underestimate the compiler cost of deriving instances. It adds up very fast if you derive lots of functors and foldables in your quest for unique names everywhere.

Do you pay this price when you derive via a `newtype`? Or does GHC figure out that the instance it would write out would be identical (modulo coercions)?

1 comments

It can generate the instance for you for particular typeclasses with an extension. See DeriveGeneric and DeriveAnyClass. The penalty applies when you're unwilling to use these extensions or when you create a type with the `data` keyword.