codesnippets:fnowarnorphans
This is an old revision of the document!
{-# OPTIONS_GHC -fno-warn-orphans #-}
- prevents warnings of orphan instance, meaning:
- instance declaration of a type is not declared in the module of the class
- example:
- code of module Lib:
module Lib ( MyClass(..) ) where class Num x => MyClass x where fMy :: x -> x
- compiler warning, when using -Wall:
app\Main.hs:6:1: warning: [-Worphans] Orphan instance: instance MyClass Double 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. | 6 | instance MyClass Double where | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
You could leave a comment if you were logged in.
codesnippets/fnowarnorphans.1618080312.txt.gz · Last modified: (external edit)
