read is defined in the Prelude as
read :: (Read a) => String -> a
and can be used as e.g. read "1" :: Int.
Now a function
readOne :: (Read a) => [String] -> (a, [String])
readOne (x:xs) = (read x,xs)
used with readOne ["1","foo"] results (as expected) in the error
Ambiguous type variable 'a' in the constraint:
'Read a' arising from a use of 'readOne' at :1:0-18
Probable fix: add a type signature that fixes these type variable(s)
But readOne ["1","foo"] :: Int doesn't work, while
readOneInt :: [String] -> (Int, [String])
readOneInt = readOne
works just fine:
> readOneInt ["1", "foo"]
(1,["foo"])
So: how can I add a type signature to readOne without defining a new function like readOneInt?