hs-cryptohash icon indicating copy to clipboard operation
hs-cryptohash copied to clipboard

Is cryptohash as high-level as it could be?

Open nh2 opened this issue 9 years ago • 2 comments

We were just looking at toHex and wondering whether it's necessary to write such a low-level concatMap.

Couldn't bytestring provide an inlinable combinator with which this could be expressed in a completely memory-safe fashion?

@vincenthz Have you had tries in the past to do this?

nh2 avatar Nov 05 '14 20:11 nh2

a concatMap approach will have quite a different profile, in term of memory usage and cpu usage. Also note that this is the same approach taken in base16-bytestring for performance reasons.

vincenthz avatar Nov 07 '14 09:11 vincenthz

@vincenthz I'm not suggesting to literally use concatMap, I'm rather asking whether you think that bytestring could provide a concatMap-like function which allows you to write toHex in a safe way (i.e. only providing a Char -> ByteString or Char -> Storable something function) with the same performance characteristics.

nh2 avatar Nov 07 '14 18:11 nh2