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

Boris boris at d12frosted.io
Thu Jun 13 08:25:40 UTC 2019


Hi everyone!

Thank you for your quick and (as always) helpful responses!

--------------------------------------------------------------------------------

Sandeep,

> This seems to work for me...
>
> someCheck :: forall a . (Show a, Read a, Eq a) => String -> a -> Bool
>
> someCheck s v = (read . show . (read :: String -> a) $ s) == v
>
> Probably requires 'ScopedTypeVariables'...

I clearly tried using `forall a`, but without `ScopedTypeVariables`. That's the missing thing. Thank you very much!

--------------------------------------------------------------------------------

Viktor, thank you for providing even more options!

I was looking for something like `TypeApplications`!

--------------------------------------------------------------------------------

Marian,

Agree, a good point. And actually, your variant works without any extensions.

Cheers,
boris at d12frosted.io

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Thursday, June 13, 2019 8:45 AM, Sandeep.C.R via Haskell-Cafe <haskell-cafe at haskell.org> wrote:

> This seems to work for me...
>
> someCheck :: forall a . (Show a, Read a, Eq a) => String -> a -> Bool
>
> someCheck s v = (read . show . (read :: String -> a) $ s) == v
>
> Probably requires 'ScopedTypeVariables'...
>
> On 13/06/19 11:06 AM, Boris wrote:
>
> > someCheck :: (Show a, Read a, Eq a) => String -> a -> Bool
> > someCheck s v = (read . show . read $ s) == v
>
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.

</haskell-cafe at haskell.org>


More information about the Haskell-Cafe mailing list