Open vincenthz opened 7 years ago
I'm interested in implementing this Builder.
But at first let me check if I am getting the issue right. I will need to rewrite Foundation.String.Builder
module for generalized builder which will work for UArray
and String
both? So builder type will look like this
data Builder a = E a | T [Builder a]
and having the following type family
type family Element t
type instance Element (UArray ty) = ty
type instance Element String = Char
Function
emitChar :: Char -> Builder
will now become
emitElement :: Element a -> Builder a
?
yes, that's correct @vrom911. one thing that is orthogonal but thought I would mention is that the approach used in this builder is not very efficient and if you want inspiration for more efficient builder implementations there's http://hackage.haskell.org/package/bytestring-0.10.2.0/docs/Data-ByteString-Builder.html or http://hackage.haskell.org/package/blaze-builder-0.4.0.2/docs/Blaze-ByteString-Builder.html that comes to mind.
related to #324