[Haskell-cafe] Ambiguous types
ietf-dane at dukhovni.org
Wed Aug 7 22:49:54 UTC 2019
> On Aug 7, 2019, at 5:52 AM, Dušan Kolář <kolar at fit.vut.cz> wrote:
> So is there a nicer and working way, how to change my simple example? Is there a way, how to make it compile? Or is it useless to do that, original function is just fine...
The closest working version is:
checkDup ns = fst $ foldr f (False, ) ns
f _ res@(True, _) = res
f 0 res@(_, vs) = (False, vs)
f v res@(_, vs) = (elem v vs, v : vs)
replacing "mempty" with "" removes the ambiguity, which
is was a logical inevitability, and not some limitation of
GHC's type inference...
More information about the Haskell-Cafe