Skip to content

Instantly share code, notes, and snippets.

@cblp
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save cblp/0d81dbb9d5071370a32c to your computer and use it in GitHub Desktop.

Select an option

Save cblp/0d81dbb9d5071370a32c to your computer and use it in GitHub Desktop.
Why?
class Show' a where show' :: a -> String
instance Show' Integer where show' = show
main = do
putStrLn $ show 42 -- OK
putStrLn $ show' 42 -- Error! Why?
[1 of 1] Compiling Main ( printTest.hs, printTest.o )
printTest.hs:6:16:
No instance for (Show' a0) arising from a use of show'
The type variable `a0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Note: there is a potential instance available:
instance Show' Integer -- Defined at printTest.hs:2:11
In the second argument of `($)', namely `show' 42'
In a stmt of a 'do' block: putStrLn $ show' 42
In the expression:
do { putStrLn $ show 42;
putStrLn $ show' 42 }
printTest.hs:6:22:
No instance for (Num a0) arising from the literal `42'
The type variable `a0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
Note: there are several potential instances:
instance Num Double -- Defined in `GHC.Float'
instance Num Float -- Defined in `GHC.Float'
instance Integral a => Num (GHC.Real.Ratio a)
-- Defined in `GHC.Real'
...plus three others
In the first argument of show', namely `42'
In the second argument of `($)', namely `show' 42'
In a stmt of a 'do' block: putStrLn $ show' 42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment