expressing injectivity on functional dependencies gives orphan instances warnings
Class.hs
{-# LANGUAGE DataKinds, FlexibleInstances, FunctionalDependencies, KindSignatures, MultiParamTypeClasses, TypeFamilies #-}
module Class where
class C a b | a -> b, b -> a
Lib.hs
{-# LANGUAGE DataKinds, FlexibleInstances, MultiParamTypeClasses, TypeFamilies #-}
module Lib where
import Class
newtype Local = Local ()
instance C Local ()
gives
/Users/dr/workspace/broken-ophans-ghc/src/Lib.hs:10:1: warning: [-Worphans]
Orphan instance: instance C Local ()
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.
It seems weird to me and it is either a bug in the orphan instances checker or there is some fundamental aspect which i don't undestand. I've been able to reproduce this with 7.10.3 and 8-rc4. I've compiled a git repo with minimalistic example of this: https://github.com/dredozubov/broken-instances-minimal
Trac metadata
Trac field | Value |
---|---|
Version | 7.10.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |