On Fri, Oct 17, 2008 at 6:21 AM, leledumbo <leledumbo_cool@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.

The problem is one of decoding data from a data source.  This is usually handled with parsers.  Neither static nor dynamic typing could really save you here, unless the file is written out in a format that could be automatically parsed by the input.  (like S-expressions perhaps for a lisp read call...)

If it was as easy as your code would like it to be, people wouldn't have bothered with things like XDR, XML, ASN.1 (BER) etc.  They'd just send binary data everywhere.  How can you tell a 32bit value from four 8 bit bytes for instance? 

You must parse I think.
 

--
View this message in context: http://www.nabble.com/List-as-input-tp19987726p20033244.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

_______________________________________________