Ivan Miljenovic wrote: > Heinrich Apfelmus wrote: >> >> Yes, the integers are just indexes. Of course, the example with the even >> integers is a bit silly; but if the integers are actually indexes, then >> it's conceptually cleaner to make them abstract, i.e. >> >> data Node -- constructors are not exported >> >> and provide combinators to operate on these abstract indexes, including >> a corresponding Data.Graph.Inductive.NodeMap module. >> >> I'd like to see such an abstract Node type, because then the library >> will provide all operations I need. It took me some time to figure out >> how to best use Int as indexes in my example code; an abstract Node >> type and a good NodeMap module would have made my life much easier. > > I'm not sure I understand what you're saying here: first you said you > wanted to be able to specify a vertex type, now you're saying that you > don't want to know what the vertex type even is (except that it's some > abstract Node type)? Whilst this would make graph usage safer/more > robust, this seems to contradict your earlier arguments...
I'd be happy with either one. :) In both cases, I want to specify a custom vertex type. I can either do that directly if the library permits, though I think the solution with associated types is too cumbersome to be useful for my make example. Or I get an abstract Node type and the library provides just the right functions that make it easy to manage a custom vertex type myself. I had hoped that the Data.Graph.Inductive.NodeMap module provides this, which it doesn't. In other words, the abstractness of Node forces the library to provide a well-designed set of functions to work with them, and that's what I'm after. In my make example, I spent the most time thinking about how to manage the Int nodes, finally settling with Data.Map.findIndex , and I prefer the library to think about that for me. >> Darn, I meant >> >> data Graph node a b = >> Graph { internal :: Graph Int a b, nodes :: Map Int a } >> >> The idea is to use Ints internally and only store a loose association >> to the custom vertex type. In particular, no Map a Int is required, >> only from Int to a . Now, I realize that the other way round is >> required as well for querying the context of a node in a graph. > > What's the point of that useless node type parameter then? And how > does the nodes map differ from just getting the graph label? You're right, I now realize that this design doesn't work. But you asked for wishes, so I wished for something. ;) Regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe