Here is the piece of code:
import System.Environment
myReverse :: [a] -> [a]
myReverse [] = []
main = print (myReverse [])
When I compile that with GHC I get the following error:
[1 of 1] Compiling Main ( problem5_myReverse.hs, problem5_myReverse.o ) problem5_myReverse.hs:6:8: No instance for (Show a0) arising from a use of
print' 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 Show Double -- Defined inGHC.Float' instance Show Float -- Defined in
GHC.Float' instance (Integral a, Show a) => Show (GHC.Real.Ratio a) -- Defined inGHC.Real' ...plus 23 others In the expression: print (myReverse []) In an equation for
main': main = print (myReverse [ ])
But when I change the signature from myReverse::[a]->[a]
to myReverse::[Int]->[Int]
the source code is compiled without any problems
Can somebody tell how can I keep the general signature [a] -> [a]
but make it work for empty Integer lists?