[Haskell-cafe] Library support for sorting with Text.Data.ICU.Collate.MCollator?

Michael Snoyman michael at snoyman.com
Mon Sep 19 15:29:03 CEST 2011

On Mon, Sep 19, 2011 at 4:26 PM, Richard Cobbe <cobbe at ccs.neu.edu> wrote:
> I'm trying to sort a list of Text values using a collator obtained from the
> Text.Data.ICU.Collate module in the text-icu package on Hackage.
> Unfortunately, I can't use the normal Data.List.sortBy function with one of
> these collators, because the collators return (IO Ordering), not Ordering.
> It's easy to write sortWithCollator :: [Text] -> IO [Text], but I'd rather
> not have to.  I haven't been able to find library support for this anywhere
> -- am I overlooking it, or do I need to write the sort function myself?

Hi Richard,

You want to use freeze[1] to get an immutable collator, and then use
the pure collate[2] function.


[1] http://hackage.haskell.org/packages/archive/text-icu/
[2] http://hackage.haskell.org/packages/archive/text-icu/

More information about the Haskell-Cafe mailing list