Created
April 5, 2017 19:13
-
-
Save mietek/f64692d3714e7b99f6571c5c6821933a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
main :: IO () | |
main = do | |
str <- getLine | |
let x = show (read str) | |
putStrLn x | |
{- | |
$ ghc -Wall -o foo Main.hs | |
[1 of 1] Compiling Main ( Main.hs, Main.o ) | |
Main.hs:6:11: error: | |
• Ambiguous type variable ‘a0’ arising from a use of ‘show’ | |
prevents the constraint ‘(Show a0)’ from being solved. | |
Probable fix: use a type annotation to specify what ‘a0’ should be. | |
These potential instances exist: | |
instance Show Ordering -- Defined in ‘GHC.Show’ | |
instance Show Integer -- Defined in ‘GHC.Show’ | |
instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’ | |
...plus 22 others | |
...plus 10 instances involving out-of-scope types | |
(use -fprint-potential-instances to see them all) | |
• In the expression: show (read str) | |
In an equation for ‘x’: x = show (read str) | |
In the expression: | |
do { str <- getLine; | |
let x = show (read str); | |
putStrLn x } | |
Main.hs:6:17: error: | |
• Ambiguous type variable ‘a0’ arising from a use of ‘read’ | |
prevents the constraint ‘(Read a0)’ from being solved. | |
Probable fix: use a type annotation to specify what ‘a0’ should be. | |
These potential instances exist: | |
instance Read Ordering -- Defined in ‘GHC.Read’ | |
instance Read Integer -- Defined in ‘GHC.Read’ | |
instance Read a => Read (Maybe a) -- Defined in ‘GHC.Read’ | |
...plus 22 others | |
...plus four instances involving out-of-scope types | |
(use -fprint-potential-instances to see them all) | |
• In the first argument of ‘show’, namely ‘(read str)’ | |
In the expression: show (read str) | |
In an equation for ‘x’: x = show (read str) | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment