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

Richard Cobbe cobbe at ccs.neu.edu
Mon Sep 19 17:51:19 CEST 2011

On Mon, Sep 19, 2011 at 04:29:03PM +0300, Michael Snoyman wrote:
> 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.

Ah -- perfect.  Can't think how I missed freeze.  Thanks!


More information about the Haskell-Cafe mailing list