[Haskell-cafe] Re: The instability of Haskell libraries

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Sat Apr 24 04:39:43 EDT 2010


John Goerzen <jgoerzen at complete.org> writes:

> It is somewhat of a surprise to me that I'm making this
> post, given that there was a day when I thought Haskell was
> moving too slow ;-)
>
> My problem here is that it has become rather difficult to
> write software in Haskell that will still work with newer
> compiler and library versions in future years.

I have the same problem, except that I work so slowly that
things have changed before I finish anything!

> Here is a prime example.  (Name hidden because my point here
> isn't to single out one person.)  This is a patch to
> old-locale:
>
> Wed Sep 24 14:37:55 CDT 2008  xxxxx at xxxxx.xxxx
>   * Adding 'T' to conform better to standard
>   This is based on information found at
>
> http://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations
> diff -rN -u old-old-locale/System/Locale.hs new-old-locale/System/Locale.hs
> --- old-old-locale/System/Locale.hs	2010-04-23 13:21:31.381619614 -0500
> +++ new-old-locale/System/Locale.hs	2010-04-23 13:21:31.381619614 -0500
> @@ -79,7 +79,7 @@
>  iso8601DateFormat mTimeFmt =
>      "%Y-%m-%d" ++ case mTimeFmt of
>               Nothing  -> ""
> -             Just fmt -> ' ' : fmt
> +             Just fmt -> 'T' : fmt
>
> A one-character change.  Harmless?  No.  It entirely changes
> what the function does.  Virtually any existing user of that
> function will be entirely broken.  Of particular note, it
> caused significant breakage in the date/time handling
> functions in HDBC.
>
> Now, one might argue that the function was incorrectly
> specified to begin with.

It certainly was, and I said so in
<wfmytn48x5.fsf at calligramme.charmers> posted to the Libraries
list back in 2007:

>> According to <http://www.w3.org/TR/NOTE-datetime> (and other
>> random sources), the iso format for date+time in one field
>> is YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00), ie
>> no spaces around the "T" but iso8601DateFormat outputs a
>> space after the day if the timeFmt is not Nothing, so
>> 
>> formatTime System.Locale.defaultTimeLocale
>>            (System.Locale.iso8601DateFormat (Just "T%H:%M:%SZ")) 
>>            (UTCTime (fromGregorian 2007 10 20) 26540)
>> 
>> yeilds "2007-10-20 T07:22:20Z".  I reckon this is a bug,
>> but at the very least it's not a good design.  Please can we
>> change
>> 
>> 
>>              Just fmt -> ' ' : fmt
>> 
>> to 
>> 
>>              Just fmt -> fmt
>> 
>> ?  if someone wants a space, they can put it in the string,
>> but it's a pain to take it out when you want the one field
>> format with a T there.

Now, while that change would still have been incompatible, I
think it would have hurt less. But the problem here is that no
one noticed my message, and then someone else must have seen the
problem and made the different change without checking through
old messages. If I remember correctly, I didn't report it as a
bug because (a) I had some problem accessing trac at the time
and anyway "2007-10-20 07:22:20Z" is acceptable as a two field
format, so it was a feature request (make it possible to output
the correct single field format).  But no discussion ensued.

My own, related, gripe about Haskell libraries is that they seem
very patchy; not adhering very well to relevant standards and
not using Haskell's types enough. For your cited example, there
is an applicable standard, so it should have been written to
adhere to it and properly typed formats are rather awkward to
do, so that can be forgiven.  But in many other places Strings
are used, with the effect that there's no typechecking at all.

An example I came across yesterday: I wanted to read a file
modification time and use that as the If-Modified-Since header
in an HTTP request. System.getModificationTime returns one type
of date, and I couldn't find how to format that correctly
(There's old-time and new time -- which one do I choose for
future compatibility? And how /do/ I convert that date to
something I can format for http?), but more to the point, I
shouldn't have to care: the IF-Modified-Since header in HTTP
expects a date, and I got a date from the system, so it should
be typed that way; converting it to the right format for HTTP is
simple-HTTP's job.

-- 
Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk
http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html  (updated 2009-01-31)



More information about the Haskell-Cafe mailing list