Menu

Christian Stryczynski

Freelance software developer. Haskelling at night. Hopefully unconventional. Fan of Dvorak

Haskell String vs Text Overview

So essentially Haskell has two main "Letter related" types -  String, and Text - and they have performance differences. 

It also has a language extension called OverloadedStrings to automatically 'convert' "Example" into String or Text

It is such an annoying issue, from my vague small understanding - Text would be much better to be a default type inferred on "Example"

Here is an possible work around to have Text as the default:
https://stackoverflow.com/questions/11552764/restricting-string-literals-to-text-only

There is also TWO (WTF WHY!?!?) libraries that help converting to String / Text:
https://hackage.haskell.org/package/string-conversions

https://hackage.haskell.org/package/string-conv

My opinion is just go with string-conversions (it has more downloads)

It has been discussed numerous times on reddit: 
https://www.reddit.com/r/haskell/comments/3rrlih/text_or_string/
https://www.reddit.com/r/haskell/comments/4p2vx7/what_can_i_do_to_help_the_stringbytestringtext/
https://www.reddit.com/r/haskell/comments/3jtoon/haskell_string_types/

Written by Christian Stryczynski on Monday December 18, 2017

Permalink -

« Cheapest 4K compatible graphics card - My Projects »