talira

text-short

Memory-efficient ShortText type for many short Unicode strings in Haskell

open sourceBSD-3-Clausefree

text-short is a Haskell package that provides the ShortText type, for keeping many short Unicode strings in memory, as ShortByteString does for ByteString. Unlike Text, ShortText gives up zero-copy slicing to save two words per value and stores UTF-8 rather than text-1's UTF-16, so a boxed value takes four words (two unboxed) plus its UTF-8 bytes. It has Data, Typeable and Template Haskell Lift instances.

Problems it solves

  • my Haskell program holds millions of short Text values and uses too much memory
  • store short Unicode keys compactly in a Haskell map
  • a UTF-8 string type for Haskell that's smaller than Text

Features

  • ShortText: UTF-8 strings without slicing overhead
  • four words per boxed value plus the UTF-8 payload
  • Data, Typeable and Template Haskell Lift instances

Alternatives

The same job

These do what text-short does.

  1. text Efficient packed Unicode text for Haskell
  2. bytestring Fast, compact strict and lazy byte strings for Haskell
  3. case-insensitive Haskell type for case-insensitive comparison of String, Text or ByteString
  4. string-interpolate Unicode-aware string interpolation for Haskell that handles all textual types

Compare text-short with the top 3