As things are, it seems much slower for simple operations. I added to some things to the benchmarks map
and drop
and map pred . map succ
and map succ . drop 30
and got results like these
benchmarking map/map/foundation 49.63 μs
benchmarking map/map/text 5.990 μs
benchmarking map/map.map/foundation 98.84 μs
benchmarking map/map.map/text 5.270 μs
benchmarking drop/drop/foundation 258.4 ns
benchmarking drop/drop/text 41.91 ns
benchmarking drop/map.drop/foundation 46.39 μs
benchmarking drop/map.drop/text 3.106 μs
I'm not sure why the simple uncomposed map
and drop
work better. See https://gist.github.com/michaelt/b7e74602a52c0b36eb244c221e6177a8
It should be possible to write a Data.Text.Foundation
that just uses the existing Stream operations for the cases where that makes most sense. It is just a question of writing stream
and unstream
functions. stream
would look like https://hackage.haskell.org/package/text-1.2.2.1/docs/src/Data-Text-Internal-Encoding-Fusion.html#streamUtf8