sshine/hs-jq

Write Hedgehog generator for homogenic lists

Closed this issue · 0 comments

An interesting exercise in itself is to make a Hedgehog Gen Expr that produces lists where all elements are arbitrary and have the same shape. This represents the kind of lists that one would often like to transform using jq.

For example,

[]
[null,null]
[true,false,true]
[[],[1],[2,3],[4,5,6]]
[{},{},{}]
[{"a":5},{"a":6},{"a":7}]
[{"a":true,"b":5},{"a":false,"b":6}]
[{"$":{"\u0020":[null,null]}},{"$":{"\u0020":[]}}]

(As a possible extension, parameterise the generator with whether objects can be null or have missing keys, since some jq filters exist to handle these cases. The idea of this extension is mostly kept as a note here, since it deserves its own issue when a basic generator exists.)