Do we have any built-in typeclasses or functions for calculating hashes from within Daml?
Something analogous to the built-in hash function every java object has?
(don’t ask why )
Do we have any built-in typeclasses or functions for calculating hashes from within Daml?
Something analogous to the built-in hash function every java object has?
(don’t ask why )
We don’t provide something generic for hashing values. What we do provide is DA.Text.sha256
which hashes a Text
value. If you combine that with show
, you can hash other values but of course you are relying on the Show
instance doing something sensible. If it just omits certain parts of your values (e.g., because you have a function in your record), the hash will be garbage. It probably will also be fairly slow.
In general, I would be very cautious with doing this type of stuff in DAML itself and try to push it to the client-side instead.
why??
I think we’re witnessing the creation of a very elusive bug some time in the future