<p dir="ltr">Is predicate a function specific to each product, used to compose product? </p>
<p dir="ltr">Or is it used when querying products to filter them?</p>
<p dir="ltr">I'd define data structures as records, sometimes with a couple variable types. Then if variable types are used, define classes to query, modify data.</p>
<p dir="ltr">Why not define product as <br>
data Prod a c = Prod a [c]</p>
<p dir="ltr">where a is product info and c is child item data.</p>
<p dir="ltr">Then define predicate class.</p>
<p dir="ltr">Then define a's and c's separately for each use case. Maybe add types for each specific product.</p>
<p dir="ltr">Then add instances.</p>
<p dir="ltr">This way future changes will be easy. It is easier to work on specifics when generics are simple. Specific products may be as complex as necessary. </p>
<p dir="ltr">If you define product as a complex type with a few type variables, changes will be more difficult.</p>