[Haskell-cafe] How to fix ambiguous type variable?

Boris boris at d12frosted.io
Thu Jun 13 05:36:33 UTC 2019


Hi everyone,

I was playing around with some tests and run into code that looks really similar to the following function

someCheck :: (Show a, Read a, Eq a) => String -> a -> Bool
someCheck s v = (read . show . read $ s) == v

But obviously, it's not clear what instance to use in the right-most read and the show functions. So it doesn't compile.

Out of curiosity, is it possible to make this function compile? I've struggled some time and could not find an answer by myself, so here I am.

Thanks in advance!

Cheers,
boris at d12frosted.io




More information about the Haskell-Cafe mailing list