[Haskell-cafe] List as input

David Leimbach leimy2k at gmail.com
Fri Oct 17 09:42:48 EDT 2008


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


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.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081017/1d37c944/attachment.htm


More information about the Haskell-Cafe mailing list