title | date |
---|---|
Move orphan instances to a separate module |
2020-05-19 |
Often we find ourselves deriving instances for a library type, but GHC will produce this warning:
Orphan instance: instance Monad m => PandocRaw (RoutedT t r m)
To avoid this
move the instance declaration to the module of the class or of the type, or
wrap the type with a newtype and declare the instance on the new type.
A solution is to move orphan instances like this to a separate module; one named Internal.hs
or Orphans.hs
, and then tack on this module-level flag at the top1:
{-# OPTIONS_GHC -fno-warn-orphans #-}