[Haskell-cafe] read with pattern
cgibbard at gmail.com
Thu Apr 21 20:09:23 EDT 2005
It's not really clear to me what you're asking. The function read is a
method of the typeclass Read, and it has type Read a => String -> a.
There are a number of instances of the typeclass Read in the standard
instance Read Int where ...
instance (Read a, Read b) => Read (a,b) where ...
instance (Read a) => Read [a] where ...
which, taken together, imply that the type [(Int,Int)] is in the
typeclass Read, and so there is a suitable implementation of read ::
String -> [(Int,Int)] If you want to see how that might be
implemented (though haskell implementations are allowed to do the same
thing in a different way), see the link to the prelude there.
hope this helps,
On 4/21/05, Walt Potter <potter at southwestern.edu> wrote:
> I'd like to find a reference to reading with patterns such as
> Thanks, Walt
More information about the Haskell-Cafe