libsodium-bindings
libsodium-bindings copied to clipboard
Better UX for constant output function for Sel.Hashing
Sel.Hashing uses a Maybe HashKey parameter to hashByteString.
However this is not fantastic in terms of readability.
I'd like to avoid Maybe-blindness by having a sum type like data KeyParma = Key <hashkey> | NoKey (or Constant).
@divarvel @kozross @a-02 your input would be appreciated. :)
I'm OK either way: I don't really feel this is confusing or less readable.
Key / NoKey does not improve readability compared to Maybe Key imo.
Is there a canonical name for when the operation is ran without a key? (eg deterministic or something). Using this name in a sum type could make things clearer.
Also, if the presence/ absence of key changes semantics too much, then maybe two functions would work better by not conflating different operations.
That being said:
- I haven't use these operations so I might be off the mark
- I think Maybe is okay anyway, I understand it's a matter of making things better, but the existing state of things is not horrible either.
@divarvel Well, the change of semantics is "same input gives same output", which makes sense when one has been diving into this kind of API for a while. Not sure about outsiders though.
It appears that the Blake2 paper uses "Keyed"