
On Tue, Jan 30, 2007 at 01:54:02PM +0000, Ian Lynagh wrote:
+-- | Class for string-like datastructures; used by the overloaded string +-- extension (-foverloaded-strings in GHC). +class IsString a where + fromString :: String -> a + +instance IsString [Char] where + fromString xs = xs
Wouldn't it make sense to have IsString require an Eq instance? class Eq a => IsString a where so that string literals could be used in pattern matching? The only reason I could see not to do this would be if you wanted to make something like (Ptr CChar) be an IsString, but that seems pretty crazy to me. I guess you could make (ForeignPtr CChar) be an IsString, and that wouldn't be particularly crazy, but it still seems ugly, and reasonably pointless. I'd rather have the inferred type of foo "bar" = True be foo :: IsString a => a -> Bool than foo :: (Eq a, IsString a) => a -> Bool or even worse, to have pattern matching not work as expected with -foverloaded-strings. -- David Roundy http://www.darcs.net