haskell / haskell/binary

Calculate the length of a Builder without executing it

Aperta
#12 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Haskell
Stelle
120
Fork
70
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

In the ELF format, there are absolute offsets pointing to positions after the offset.
Thus, calculating this offset requires knowing the length of several Builders, including the length of the Builder that will contain the offset itself.

With the current API and a naive approach that would force the Builders into lazy ByteStrings, you'd end up with <>.

One simple solution, suggested by Joe Hendrix, is to wrap the Builder in a type that contains the Builder and it's length.

data SizedBuilder = SB Int64 Builder

length (SB l _) = l
… + additional methods exported by Data.Binary.Builder

This API could be exposed from Data.Binary.Builder.Sized.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.