fork(8) download
  1. {-# LANGUAGE KindSignatures,TypeFamilies,FlexibleInstances #-}
  2. {-# LANGUAGE CPP #-}
  3.  
  4. import Prelude
  5.  
  6. data Poo
  7. data HooBar
  8. data Bar
  9. type family Hoo b :: *
  10. type instance Hoo Bar = HooBar
  11.  
  12. class Pooable a where
  13. poo :: a -> Poo
  14.  
  15. f :: (Hoo b ~ HooBar) => b
  16.  
  17. instance {-# OVERLAPPABLE #-} (b ~ Bar) => Pooable b where
  18. poo = undefined
  19.  
  20. #if 1
  21. -- 0 にすると問題なく通る.
  22. instance {-# OVERLAPPING #-} Pooable () where
  23. poo = undefined
  24. #endif
  25.  
  26. x = poo f -- (f :: Bar) -- 型注釈入れると勿論通る.
  27. main = print "ok"
Compilation error #stdin compilation error #stdout 0s 4284KB
stdin
Standard input is empty
compilation info
[1 of 1] Compiling Main             ( prog.hs, prog.o )

prog.hs:27:9: error:
    • Couldn't match type ‘Hoo a0’ with ‘HooBar’
        arising from a use of ‘f’
      The type variable ‘a0’ is ambiguous
    • In the first argument of ‘poo’, namely ‘f’
      In the expression: poo f
      In an equation for ‘x’: x = poo f
stdout
Standard output is empty