I am considering the problem of representing search results in a graph database. (Define such a database as a collection N of nodes and E of labeled edges, where a labeled edge consists of a triplet (l, n1, n2), where l is some kind of label and n1 and n2 are members of N.)

I think a type something like the following would be useful:
  data Search =
    Fan { origin :: Node
          , label :: Label
          , members :: [Node]
        }
    | And Search Search
    | Or Search Search
    | Not Search
In a Fan with origin o, members would be the set of Nodes p such that (label, o, p) is an edge. A Search is ultimately built out of Fans.

I've seen this kind of thing before, and I believe it will lead me to some substantial problems that other people have already solved. What should I study?