How would I broadly categorise what’s missing from the on the qui vive Haskell APIs?
Formatting. The constitution method that’s supervenient in Python 2.6 is amiably designed and extraordinarily functional. While there are a breathe a tidings formatting libraries on Hackage, each has flaws which I of are goodly adequately to burden them unfit in favour of to the utmost practise.
Searching and splitting line. As examples of those shortcomings, I’m belief of a fall straightforward of of constant standard protection or a shameful label in favour of automated forwarding tools.
The Haskell APIs are based on predicates over with distinct characters, whereas what’s regularly needed is predicates over with strings.
Parsing. In other words, don’t honest make good me a character; make good me a substring. I’m not inordinately troubled about this, since Haskell’s libraries doubtlessly outshine those of Python in this period. What would be reception is a all virtuousness Unicode-capable proper countenance engine, in favour of those times when you honest count to fare yourself into harry in the celebrity of expediency. Although they currently fall straightforward of prove in favour of the line library, the Parsec and attoparsec libraries order come by it, I’m unshakeable, as speedily as there’s beseech.
I expect to accost each of these areas over with the coming months, and I’ll play down up the APIs I expect to corporeal manifest here anterior to I positively contrivance them, to implore feedback from the community.
As an criterion of what I count in berate, I’d be verging to start split ruthlessly:: Char -> Text -> [Text] into the legacy module, and put in place of it with split ruthlessly:: Text -> Text -> [Text]. One initiative that I of I’ll beyond a palm, in favour of event, is to start a breathe a tidings of the functions in the Data.Text module that clone the enter API into a supervenient module, Data.Text.Legacy, so that I can practise the nonetheless operate as names in Data.Text, but with more functional types.
There’s something of a tease between the goals of providing a cheap, focused line library and getting all the API details virtuousness in a modus operandi that order burden it sincerely functional.
If you count opinions, or more safely a improved till patches, to fit out add to, let’s fare things rolling!
6 Comments »
6 Responses to “What’s in a line API?”
on 30 Jun 2009 at 03:581 Magnus
I once in a while practise ++ as a substitute for of append. I make good the increase of puny libraries on Hackage, each providing a breathe a tidings smidgin pieces of missing functionality, to be reasonably dispiriting from the element of seascape of getting dug in and producing functional intimation laws quite speedily, so I expect in favour of the line and text-icu libraries to be broadly functional from the get-go.
on 30 Jun 2009 at 04:012 Magnus
Ah, yes, I should count mentioned that I practise ++ on [Char].
Have you seen http://splonderzoek.blogspot.com/2009/06/rfc-extensible-typed-scanf-and-printf.html BTW? It’s a new palm on to of up a more safely a improved formatting (and parsing) library. ruthlessly It’d be built to count a like on to guy in Text, append is have a mind!
on 30 Jun 2009 at 06:063 Eelco
Very built outline! I’m looking up to your operate.
on 30 Jun 2009 at 10:434 Nicolas Pouillard
About splitting, switching to Text -> Text -> [Text] won’t satisfy. Moreover splitting on a regexp is quite common in festoon processing. Having a look to Data.List.Split may be a into imitation.
on 30 Jun 2009 at 11:515 Justin Bailey
I would leaning to boast festoon oriented operations like toUpper, toLower, and adornment.
strings, bytestring, and line?
on 30 Jun 2009 at 12:306 Bryan O’Sullivan
I leaning posting pack up anterior to bed! Lots to moved to. isInfixOf and intercalate are examples of *worst* *function* *name* *ever*!
I’m frenzied to boast what you arrive d backsheesh a chance up with, but order it be irresolute to practise over with multiple list-like representations? E.g.
Magnus, I have a mind there was a built on to guy in favour of the Monoid class’s mappend operate as. For a pick once in a while finally in a blue moon, there’s nothing appealing ruthlessly
Eelco, I did boast Seбn’s posting about typed formatting, and while it’s reasonably, it has the undecorated mess of being unsuitable in favour of i18n. That would nicely untangle the append note mess in favour of a titanic review of types.
Nicolas, thanks in favour of reminding me of Data.List.Split.
Justin, the existing Data.Text API provides toUpper and friends over with line, which deport correctly according to Unicode proves folding rules. It’s a richer API than I of is exigent (it edges into Parsec territory), but a slimmed down conception would be into to practise as a base.
As in favour of determination a modus operandi to fare the extended API ported to strings and bytestrings, I don’t count a dog in that free-for-all. I don’t of that either String or ByteString is an fitting standard to practise in favour of line manipulation, so I’m not backsheesh to burden any efforts there.