p.s: I wasn't sure how to name my question, fell free to let me know how I should have named it.
If not specifying the concrete type, I get this error, which is very clear and easy to solve:
Ambiguous type variable
a0arising from a use offctprevents the constraint(Read a0)from being solved. Probable fix: use a type annotation to specify whata0should be.
I just need more explanation on why it worked? How Read will know what is the type to return:
fct :: (Show a, Read b) => a -> b
fct = read . show
main = do
-- DOES NOT WORK: -- print (fct 4)
-- WORKS: -- print (fct 4 :: Int)
fctdoing here? - Willem Van OnsemInt, so that means thatreadmust return anInt. - Carcigenicate