[Haskell-cafe] Porting setlocale to Windows

Alexey Shmalko rasen.dubi at gmail.com
Fri Jan 2 11:17:34 UTC 2015


Okay. categoryToCInt returns you -1, which you pass to setlocale and
get NULL back, then convert it to Nothing and return to Haskell space.

I'm just wondering, why categoryToCInt is exported at all?

2015-01-02 11:46 GMT+02:00 Sven Bartscher <sven.bartscher at weltraumschlangen.de>:
> But the result of categoryToCInt is, normally guaranteed to return a
> result that you can pass to setlocale, which isn't satisfied in this
> case.
>
> Regards
> Sven
>
> On Fri, 2 Jan 2015 10:32:01 +0200
> Alexey Shmalko <rasen.dubi at gmail.com> wrote:
>
>> According to man 3 setlocale:
>> > The setlocale() function returns NULL and
>> > fails to change the locale if the given combi-
>> > nation of category and locale makes no sense.
>>
>> So, returning Nothing seems just fine for me.
>>
>> I believe categoryToCInt can return any CInt, because it's result is
>> implementation detail. I mean, applications can't make any assumption
>> based on result of categoryToCInt. That's why changing it (while
>> keeping its type) shouldn't break anything.
>>
>> Regards,
>> Alexey
>>
>> 2015-01-02 0:57 GMT+02:00 Sven Bartscher <sven.bartscher at weltraumschlangen.de>:
>> > I assume that "do nothing", means that a call to
>> > `setLocale LC_MESSAGES x` always returns Nothing (which may confuse
>> > some applications, but maybe it does in the right way).
>> >
>> > Then there's the question left, what categoryToCInt does. I could
>> > change it's signature to `Category -> Maybe CInt`, but that would mean
>> > breaking the API. Instead I could make say
>> > `categoryToCInt LC_MESSAGES = -1`, which may confuse some applications
>> > which assume that categoryToCInt returns valid integers. But I guess,
>> > that's not that much of a problem, since categoryToCInt is not really
>> > often used in packages other than setlocale itself.
>> >
>> > Regards
>> > Sven
>> >
>> > On Fri, 2 Jan 2015 00:13:58 +0200
>> > Alexey Shmalko <rasen.dubi at gmail.com> wrote:
>> >
>> >> Hi,
>> >>
>> >> The third option is to make `setLocale LC_MESSAGES` do nothing. I believe,
>> >> it's perfectly acceptable in this case and is much better than making it an
>> >> error.
>> >>
>> >> Regards,
>> >> Alexey
>> >>
>> >> 2015-01-01 21:45 GMT+02:00 Sven Bartscher <
>> >> sven.bartscher at weltraumschlangen.de>:
>> >>
>> >> > Greetings,
>> >> >
>> >> > A while ago I took over the packages setlocale.
>> >> > I now would like to make it portable to windows, but came across the
>> >> > problem that LC_MESSAGES isn't defined on mingw.
>> >> > I thought about these options, for solving this:
>> >> >  - Not defining LC_MESSAGES, which would mean, every package using
>> >> >    LC_MESSAGES wouldn't be portable to windows.
>> >> >  - Defining LC_MESSAGES as some an error, which would basically have
>> >> >    the same problem as above.
>> >> >
>> >> > I don't like either of these solutions, but don't know any better.
>> >> > I would be happy about suggestions.
>> >> >
>> >> > Regards
>> >> > Sven
>> >> >
>> >> > _______________________________________________
>> >> > Haskell-Cafe mailing list
>> >> > Haskell-Cafe at haskell.org
>> >> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>> >> >
>> >> >
>> >
>> > _______________________________________________
>> > Haskell-Cafe mailing list
>> > Haskell-Cafe at haskell.org
>> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>> >
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list