In case of a type definition and a variable declaration from that type:
data Relation = Relation with
var1: Text
var2: Text
var3: Text
relations: Relation
Now, let’s say I want to create a list of that type - meaning [relations]:
How can i filter the list and find the item that matches a certain criteria
(e.g relations.var2 == “xyz”)
Type declaration is necessary to prevent ambiguous type reference error in the filter function.
Also keep in mind that you have to add “deriving (Eq,Show)” in your data type to enable pattern matching for the data type.
In this case, let filteredList= filter (\(var : Relation) -> var.var2=="xyz") listVariable