[Haskell-cafe] Float instance of 'read'

Twan van Laarhoven twanvl at gmail.com
Tue Sep 16 16:28:30 EDT 2008


Mauricio wrote:
> Do you think 'read' (actually,
> 'readsPrec'?) could be made to also
> read the international convention
> (ie., read "1,5" would also work
> besides read "1.5")? I'm happy to
> finaly use a language where I can
> use words of my language to name
> variables, so I wonder if we could
> also make that step.

That would be quite problematic in combination with lists, is

   read "[1,2,3,4]" == [1,2,3,4]

or

   read "[1,2,3,4]" == [1.2, 3.4]

Or something else?


Localized reading should be somewhere else, perhaps related to Locales.

As an aside, this is one of the (many) places where Haskell has made the right 
choice. In other languages such as Java input functions suddenly break when the 
user has a different locale setting. While for user input this might be desired, 
in my experience much of the i/o a program does is with well defined file 
formats where changing '.' to ',' just shouldn't happen.


Twan


More information about the Haskell-Cafe mailing list