[Haskell-cafe] List as input

Dougal Stanton dougal at dougalstanton.net
Fri Oct 17 09:31:57 EDT 2008


On Fri, Oct 17, 2008 at 2:21 PM, leledumbo <leledumbo_cool at yahoo.co.id> wrote:
>
> So, what's the solution? This one:
>
> (l::[Ord]) <- readLn
>
> doesn't work (because Ord isn't a type constructor). It doesn't even comply
> to Haskell 98 standard. I want to be able to read any list of ordered
> elements.

I hope to be enlightened, but I'm pretty sure this is not possible.
Your readLn has to present a list of some specific type which can be
inferred at compile time. Which type is it? String? Int? Something
else?

Also, neither Show nor Read relate to Ord, so you cannot ever be sure
that all Readable/Showable types are Ordered, or that all Ordered
types can be Read/Shown.


D


More information about the Haskell-Cafe mailing list