number formatting with locale

Hi all haskell lovers I'm trying to print out Double in russian locale (we use "," as decimal separator insetad of "."). I'm trying to set locale with System.Locale.SetLocale like setLocale LC_ALL $ Just "ru_RU.UTF-8" this returns Just "ru_RU.UTF-8", so it seems that function call succeeded, but when I call show 20.2 it just prints 20.2 and not desired 20,2 Can anyone please help?

Dmitry Simonchik wrote:
I'm trying to print out Double in russian locale (we use "," as decimal separator insetad of "."). I'm trying to set locale with System.Locale.SetLocale like
setLocale LC_ALL $ Just "ru_RU.UTF-8"
this returns Just "ru_RU.UTF-8", so it seems that function call succeeded, but when I call
show 20.2
it just prints 20.2 and not desired 20,2
Can anyone please help?
By design, show and read don't use the locale. Not to mention that since Haskell is pure, it is *impossible* for the expression show 20.2 :: String to depend on the current locale. I have never tried to use locales in Haskell, maybe someone else can help. Most likely, you'll need to do foreign imports of C functions. Regards, apfelmus -- http://apfelmus.nfshost.com

Excerpts from Dmitry Simonchik's message of Tue Sep 08 02:47:43 -0600 2009:
Not to mention that
since Haskell is pure, it is *impossible* for the expression show 20.2 :: String to depend on the current locale.
This is a very valuable remark. Thanks! I will think about using some special functions to read and write numbers depending on current locale.
The i18n module from hackage is worth a look for this: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/i18n -- wmw
participants (3)
-
Dmitry Simonchik
-
Heinrich Apfelmus
-
Wirt Wolff