Comment

Comment by Someone

They need to tighten that a bit, though. “Lexicographic” isn’t clear enough even ignoring locale dependencies.

Looking at the reference implementation, it contains

  encode = encodeUtf8 . generate
So, the sorting is done before conversion to UTF-8.

Relevant line, I think is

  genObject hm = "{" <> foldl' go mempty (sortOn fst (HM.toList hm)) <> "}"
So, it uses Data.String’s sort order, which seems to be to lexicographic by Unicode code point (https://stackoverflow.com/a/3126287)

⇒ implementations cannot sort the UTF-8 byte st sequences lexicographically. I think that’s a bad choice (if it was a choice and not an oversight)

I’ve never written a single line of Haskell, so corrections welcome.

parent Someone 9 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton