A really bad way to say "all isSpace"

Hi, Reading through the code to read: read s = case [x | (x,t) <- reads s, ("","") <- lex t] of [x] -> x [] -> error "Prelude.read: no parse" _ -> error "Prelude.read: ambiguous parse" Reading through the code to lex, it appear that it will return [("","")] if and only if all isSpace t. If this is really the case, does it make sense to state all isSpace t? It has a much clearer meaning to me. Thanks Neil

Neil Mitchell wrote:
Hi,
Reading through the code to read:
read s = case [x | (x,t) <- reads s, ("","") <- lex t] of [x] -> x [] -> error "Prelude.read: no parse" _ -> error "Prelude.read: ambiguous parse"
Reading through the code to lex, it appear that it will return [("","")] if and only if all isSpace t.
If this is really the case, does it make sense to state all isSpace t? It has a much clearer meaning to me.
I think 'lex' is supposed to not understand (haskell-style) comments - which I agree with - so I agree that it would be "better" to say (all isSpace t). I might even have thought that in passing when reading that code, I don't remember.... Isaac

Hi
Reading through the code to lex, it appear that it will return [("","")] if and only if all isSpace t.
If this is really the case, does it make sense to state all isSpace t? It has a much clearer meaning to me.
I think 'lex' is supposed to not understand (haskell-style) comments - which I agree with - so I agree that it would be "better" to say (all isSpace t). I might even have thought that in passing when reading that code, I don't remember....
My particular reason for wanting this is that read :: Int -> String depends on lex, when logically reading an Int doesn't appear to warrant lexing Haskell! Thanks Neil
participants (2)
-
Isaac Dupree
-
Neil Mitchell