text
text copied to clipboard
headMaybe
head is partial, so it would be great to have a safe alternative.
https://hackage.haskell.org/package/text-1.2.4.1/docs/Data-Text.html#v:uncons ?
I'd be in favor of adding the headMaybe function to have API-parity with other collections (though, tbh, I'd much prefer for head to return a Maybe Char).
I'm also for making head return Maybe Char, although that will probably breaks lots of packages.
I was searching for Text -> Maybe Char so I didn't find it and used a workaround. I'm probably not the first nor the last.
uncons is a natural way to eliminate strings, blessed by base. I'm not sure that an additional entity for a combination of uncons and fst is justified.
I'd be in favor of adding the
headMaybefunction to have API-parity with other collections
It will actually introduce API disparity with other collections. The only other package, which has such function, is rio.
though, tbh, I'd much prefer for
headto return aMaybe Char
This is also not quite attested in other packages, and is a huge breaking change.