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

Boris boris at d12frosted.io
Thu Jun 13 10:59:13 UTC 2019


Tom,

Haha, nice. Now we have someCheck defined for so many scenarios. I like it.

Didn't expect to get so many answers ;) Thanks everyone!


Cheers,
boris at d12frosted.io

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Thursday, June 13, 2019 12:53 PM, Tom Ellis <tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk> wrote:

> On Thu, Jun 13, 2019 at 04:46:25AM -0400, Viktor Dukhovni wrote:
>
> > > On Jun 13, 2019, at 4:25 AM, Boris boris at d12frosted.io wrote:
> > > Agree, a good point. And actually, your variant works without any extensions.
> >
> > Well, in a sense it is working with an "extension", just one that
> > happens to be on by default and is required in Haskell 98. Namely,
> > what makes it work is the "MonomorphismRestriction". If you specify:
> > {-# LANGUAGE NoMonomorphismRestriction #-}
> > then the example stops working. I like the posted example as an
> > exceptionally clear illustration of the MonomorphismRestriction.
>
> And for the record, this version requires no extension nor unextension:
>
> {-# LANGUAGE NoMonomorphismRestriction #-}
>
> module Check where
>
> someCheck :: (Show a, Read a, Eq a) => String -> a -> Bool
>
>     someCheck = someCheck' read
>       where someCheck' r s v = (r . show . r $ 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.




More information about the Haskell-Cafe mailing list