Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reason to use String instead of Text in Haskell

Tags:

haskell

yesod

I hear that good practice in Haskell to use Text instead of String.

I am trying to follow this rule, and coming up with the following question:

Why parseRoute of Network-HTTP-Client is designed to work with String and not Text?

What is the general recommendation to use String instead of Text?

https://www.stackage.org/haddock/lts-14.2/http-client-0.6.4/Network-HTTP-Client.html#v:parseRequest

like image 437
mkUltra Avatar asked Aug 22 '19 21:08

mkUltra


1 Answers

I suspect the most likely answer is, sadly, that String is still the path of least resistance: the ability to reuse all the familiar list functions (and the very good support for lists in parsing libraries) is so convenient that a largish collection of libraries continue to use String despite possible technical advantages of choosing a different type.

Until the cost of the "worse" (but more convenient) choice is carefully quantified and a fix written by somebody who cares, you can expect that to pretty much stay unchanged in any given library.

like image 88
Daniel Wagner Avatar answered Sep 27 '22 22:09

Daniel Wagner