Skip to content
This repository was archived by the owner on Jun 13, 2020. It is now read-only.

Latest commit

 

History

History
21 lines (16 loc) · 733 Bytes

3ef946dc.md

File metadata and controls

21 lines (16 loc) · 733 Bytes
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 #-}

Footnotes

  1. https://gitlab.haskell.org/ghc/ghc/issues/2515