<div dir="ltr"><div><div>Hi devs,<br><br></div>in the followin snippet:<br><br>{-# LANGUAGE OverloadedStrings #-}<br>import  Data.Char (isAlphaNum)<br>import  Data.ByteString.Char8 as BS (all)<br>main = <br>    print $ check str<br>  where<br>    check = BS.all (\x -> x `elem` valid || isAlphaNum x)  -- Line 7<br>    valid   = "$_-"                     -- :: String                      -- Line 8<br>    str      = "foo_bar123"<br><br></div>GHC 7.10 fails with the following errors (whereas 7.8 compiles without complaining):<br><div><br>ghc --make "Testcase.hs"<br>[1 of 1] Compiling Main             ( Testcase.hs, Testcase.o )<br>Testcase.hs:7:31:<br>    No instance for (Foldable t0) arising from a use of ‘elem’<br>    The type variable ‘t0’ is ambiguous<br>   (...)<br><br>Testcase.hs:8:15:<br>    No instance for (Data.String.IsString (t0 Char))<br>      arising from the literal ‘"$_-"’<br>    The type variable ‘t0’ is ambiguous<br>    (...)<br><br></div><div>Uncommenting the -- :: String type annotation (line 8) makes the snippet acceptable to the typechecker however.<br></div><div><br></div><div>So Foldable [] and  [Char] should be possible to infer, given the evidence of 'isAlphaNum x', as obviously happens with GHC 7.8. My question is, how or why does the 7.10 typechecker behave differently? Is this intentional, or does this qualify for a trac ticket?<br><br></div><div>Thanks for looking into this,<br></div><div>Michael<br><br></div><div><br><br></div><div>PS: The ByteString part is just there since the snippet is taken out of one of my projects. The following (modified) code only typechecks on 7.10 with both type annotations uncommented:<br><br>{-# LANGUAGE OverloadedStrings #-}<br>import  Data.Char (isAlphaNum)<br>main = <br>    print $ check str<br>  where<br>    check   = all (\x -> x `elem` valid || isAlphaNum x)<br>    valid     = "$_-"               -- :: String<br>    str        = "foo_bar123"    -- :: String<br></div><div><br></div><div>The errors here are (1) no instances for Foldable and (2) no instances for IsString.<br></div><div><br></div></div>