hpack-dhall icon indicating copy to clipboard operation
hpack-dhall copied to clipboard

Convert `Map`s to JSON objects

Open sellout opened this issue 2 months ago • 1 comments

There’s no place in hpack where mapName or mapValue can be used as object keys inside a list, so it’s safe to convert those instances to JSON objects, rather than a literal translation to an array of objects.

This is especially helpful when trying to typecheck hpack-dhall values, because while writing tests.foo = {=} is perfectly fine, it has a different type than tests.bar = {=}. However, tests = toMap { foo = {=} } and tests = toMap { bar = {=} } have the same type.

After this change, the two variants above (tests.foo and tests = toMap { foo … }) convert to the same JSON.

Also after this, I’ve been able to write consistent types for all of hpack-dhall, which has allowed me to define Dhall schemas and abstract a few other things in my package.dhall files, like autogenerating the license-file list

sellout avatar Oct 21 '25 15:10 sellout

This should probably add a golden test or two.

sellout avatar Nov 06 '25 23:11 sellout