[Haskell-cafe] ReadS with Maybe
robdockins at fastmail.fm
Mon Jan 3 14:58:39 EST 2005
From the GHC docs:
type ReadS a = String -> [(a, String)]
A parser for a type a, represented as a function that takes a String and
returns a list of possible parses (a,String) pairs.
So it returns all possible parses, hence the list. This is useful if
the encoding is ambiguous.
Henning Thielemann wrote:
> What is the reason for the definition
> ReadS a = [(a, String)]
> not being
> ReadS a = Maybe (a, String)
> ? The latter one reflects that either one or no value is read, whereas the
> first definition allows an arbitrary number of read values which is
> confusing and unsafe in my opinion.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe