hash package:dhall

Hash a fully resolved expression
Convenience utility to hash a fully resolved expression and return the base-16 encoded hash with the sha256: prefix In other words, the output of this function can be pasted into Dhall source code to add an integrity check to an import
Decode a HashMap from a toMap expression or generally a Prelude.Map.Type.
>>> fmap (List.sort . HashMap.toList) (input (Dhall.hashMap strictText bool) "toMap { a = True, b = False }")
[("a",True),("b",False)]

>>> fmap (List.sort . HashMap.toList) (input (Dhall.hashMap strictText bool) "[ { mapKey = \"foo\", mapValue = True } ]")
[("foo",True)]
If there are duplicate mapKeys, later mapValues take precedence:
>>> let expr = "[ { mapKey = 1, mapValue = True }, { mapKey = 1, mapValue = False } ]"

>>> input (Dhall.hashMap natural bool) expr
fromList [(1,False)]
Decode a HashSet from a List with distinct elements.
>>> input (hashSetFromDistinctList natural) "[1, 2, 3]"
fromList [1,2,3]
An error is thrown if the list contains duplicates.
>>> input (hashSetFromDistinctList natural) "[1, 1, 3]"
*** Exception: Error: Failed extraction

The expression type-checked successfully but the transformation to the target
type failed with the following error:

One duplicate element in the list: 1
>>> input (hashSetFromDistinctList natural) "[1, 1, 3, 3]"
*** Exception: Error: Failed extraction

The expression type-checked successfully but the transformation to the target
type failed with the following error:

2 duplicates were found in the list, including 1
Decode a HashSet from a List.
>>> input (hashSetIgnoringDuplicates natural) "[1, 2, 3]"
fromList [1,2,3]
Duplicate elements are ignored.
>>> input (hashSetIgnoringDuplicates natural) "[1, 1, 3]"
fromList [1,3]
Exception thrown when an integrity check fails
A ImportType extended with an optional hash for semantic integrity checks
Hash a ByteString and return the hash as a SHA256Digest
Parse a SHA256Digest This corresponds to the hash rule from the official grammar
Parse an ImportHashed This corresponds to the import-hashed rule from the official grammar