haskell / fgl

A Functional Graph Library for Haskell
http://hackage.haskell.org/package/fgl
Other
184 stars 54 forks source link

Documentation updates for predicate functions that rely on match #97

Open nstepp opened 3 years ago

nstepp commented 3 years ago

Functions that rely on match and also take a function involving Context show expected, but poorly documented behavior.

The issue comes up when user functions that are supposed to operate on Contexts receive them as part of a recursive graph decomposition. As such, the graph that the contexts belong to gets smaller and smaller. User expectations are usually that if the starting graph has a particular context, that is the one that their function receives, as opposed to a context from a subsequent decomposition. This has come up before in #55 and #89.

I think this is at least a documentation fix, but it would also be useful to add some functions for mapping and folding over "full" contexts.

Would the maintainers be interested in pull requests for either?

nstepp commented 3 years ago

I just saw 84a89c4e280059d59a8d73a5238d9951ffbec3f3, but I still wonder if the ramifications of recursively calling match should be spelled out somewhere.

In any case, I'm also still curious about the possibility of something like cmap :: Graph g => (Context a b -> Context c d) -> g a b -> g c d or cfold :: Graph g => (Context a b -> c -> c) -> c -> g a b -> c that do not recursively call match. At the very least, it would be useful to have an efficient version of something that does Graph g => g a b -> [Context a b].