fork(7) download
  1. {-# LANGUAGE CPP,FlexibleInstances #-}
  2. class C a where
  3. f :: a -> String
  4. instance {-# OVERLAPPABLE #-} C a where
  5. f x = "a"
  6. -- #if 0 で通る
  7. #if 1
  8. instance {-# OVERLAPPABLE #-} C () where
  9. f x = "()"
  10. #endif
  11. main = print $ f undefined -- (undefined :: ()) で通る
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
[1 of 1] Compiling Main             ( prog.hs, prog.o )

prog.hs:11:16: error:
    • Overlapping instances for C a0 arising from a use of ‘f’
      Matching instances:
        instance [overlappable] C a -- Defined at prog.hs:4:31
        instance [overlappable] C () -- Defined at prog.hs:8:31
      (The choice depends on the instantiation of ‘a0’
       To pick the first instance above, use IncoherentInstances
       when compiling the other instance declarations)
    • In the second argument of ‘($)’, namely ‘f undefined’
      In the expression: print $ f undefined
      In an equation for ‘main’: main = print $ f undefined
stdout
Standard output is empty