I am trying to understand the code in this article . This explains the use of inductive graphs, which seems very nice, and at some point it determines the depth search for inductive graphs. The code for it is as follows:
dfs :: Graph.Node -> Gr ab -> [Node] dfs start graph = go [start] graph where go [] _ = [] go _ g | Graph.isEmpty g = [] go (n:ns) (match n -> (Just c, g)) = n : go (Graph.neighbors' c ++ ns) g go (_:ns)
I do not understand these two lines:
go (n:ns) (match n -> (Just c, g)) = n : go (Graph.neighbors' c ++ ns) g
It seems to define a go function that takes a list as the first argument, which maps to the pattern (n:ns) . The second argument, however, I do not understand: (match n -> (Just c, g)) . What does the -> operator mean here? Looking up an operator can be one of three things:
- Function type mapping operator.
- The lambda definition operator.
- Separator when building the hull.
Since there is no case or backslash variable for a lambda expression, this can only happen if it is a function type mapping operator. In this case, I donโt understand how it binds the values โโto these variables, c and g ? And what does this exactly mean, how can it be in an argument?
Thanks in advance!
Goens source share