fork download
  1. {-# LANGUAGE GADTs #-}
  2.  
  3. class Show a => Num' a where fromInteger' :: Integer -> a
  4.  
  5. data X a where
  6. X :: (Show a, Num' a) => a -> X a
  7.  
  8. instance Show (X a) where
  9. show (X x) = "X " ++ show x
  10.  
  11. instance Num' (X a) where
  12. fromInteger' x = X $ fromInteger' x
  13.  
  14. main = return ()
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:12:27:
    Could not deduce (Num' a) arising from a use of `X'
    from the context (Show (X a))
      bound by the instance declaration at prog.hs:11:10-19
    Possible fix:
      add (Num' a) to the context of the instance declaration
    In the expression: X
    In the expression: X $ fromInteger' x
    In an equation for fromInteger':
        fromInteger' x = X $ fromInteger' x
stdout
Standard output is empty