Bodigrim / linear-builder

Strict Text and ByteString builder, which hides mutable buffer behind linear types and takes amortized linear time.
https://hackage.haskell.org/package/text-builder-linear
BSD 3-Clause "New" or "Revised" License
88 stars 4 forks source link

Another approach to support negative hexadecimals #15

Closed Bodigrim closed 1 year ago

Bodigrim commented 1 year ago

@wismill this is what I meant in https://github.com/Bodigrim/linear-builder/pull/11#pullrequestreview-1608329738. Is it sufficient?

wismill commented 1 year ago

Clever! There is something fishy though:

import Data.Int
runBuffer \b -> b |>& (-1 :: Int32)
-- "ffffffff"
runBuffer \b -> b |>. '?' |>& (-1 :: Int32)
-- "7ffffffff"

It helps to update the tests as in #11.

When fixed, we should benchmark to check for the relevance of rewrite rules.

Bodigrim commented 1 year ago

Good catch, should be better now. Could you possibly try rebasing your branch with tests atop of this?

I'd rather avoid rewrite rules, in the worst case scenario we can dispatch by types similarly to https://github.com/Bodigrim/linear-builder/blob/d8ae7d89c09b8c748bbb04cddf23e33fd5189b5c/src/Data/Text/Builder/Linear/Dec.hs#L130-L143

wismill commented 1 year ago

@Bodigrim Done, see #11.

Bodigrim commented 1 year ago

Superseded by #11.