very general directed hypergraphs over text

I'm writing a graph class that generalizes the traditional mathematical graph: Nodes can be statements or relationships, and relationships ("edges") can involve any number of nodes, including other relationships. [1] describes the motivation in a little more detail. [2] explains the idea behind the major types -- Graph, Node, Stmt, and Rel. Of the .hs files in the project, at this time I believe only the primary one, Dwt.hs [3], deserves your attention. It is only about 100 lines of code. I am interested in any kind of feedback at all, no matter how minute in detail or expansive in scope. [4] lists what I already think might be likely problems and solutions. In particular I wonder whether I should interpret these two patterns: "case ni of Rel -> .. Stmt -> .." and "if (Maybe.isJust nMb) ... else error ..." as signs that I'm not completely solving the problem. I suspect it might be helpful to make the graph operations Maybe or Either, and use <|> on them -- but while I can monkey those words, I don't really know what I'm saying. [1] https://github.com/JeffreyBenjaminBrown/digraphs-with-text/blob/master/engli... [2] https://github.com/JeffreyBenjaminBrown/digraphs-with-text/blob/master/engli... [3] https://github.com/JeffreyBenjaminBrown/digraphs-with-text/blob/master/src/D... [4] https://github.com/JeffreyBenjaminBrown/digraphs-with-text/blob/master/engli... Thank you, Jeff

First, make statement structure richer. Instead of just String, make its'
parameter a list of something like this:
data SExpr = Underscore | Word String
and Stmt thus:
data Stmt = Stmt [SExpr]
This way it is easier to construct and/or combine.
Second, make graph operations to operate on bulk of data. Singleton data is
a special case of bulk data and bulk operations are much more efficient in
general.
So instead of addRelIdxToNode :: RelIdx -> Node -> Node create something
like addRelIdxToNodes :: RelIdx -> [Node] -> [Node] (use your collection of
choice instead of lists).
This will pay rather quickly (in terms of performance and brevity).
Those are my two humble suggestions.
2015-07-17 9:19 GMT+03:00 Jeffrey Brown
I'm writing a graph class that generalizes the traditional mathematical graph: Nodes can be statements or relationships, and relationships ("edges") can involve any number of nodes, including other relationships. [1] describes the motivation in a little more detail.
[2] explains the idea behind the major types -- Graph, Node, Stmt, and Rel.
Of the .hs files in the project, at this time I believe only the primary one, Dwt.hs [3], deserves your attention. It is only about 100 lines of code.
I am interested in any kind of feedback at all, no matter how minute in detail or expansive in scope.
[4] lists what I already think might be likely problems and solutions. In particular I wonder whether I should interpret these two patterns: "case ni of Rel -> .. Stmt -> .." and "if (Maybe.isJust nMb) ... else error ..." as signs that I'm not completely solving the problem.
I suspect it might be helpful to make the graph operations Maybe or Either, and use <|> on them -- but while I can monkey those words, I don't really know what I'm saying.
[1] https://github.com/JeffreyBenjaminBrown/digraphs-with-text/blob/master/engli... [2] https://github.com/JeffreyBenjaminBrown/digraphs-with-text/blob/master/engli... [3] https://github.com/JeffreyBenjaminBrown/digraphs-with-text/blob/master/src/D... [4] https://github.com/JeffreyBenjaminBrown/digraphs-with-text/blob/master/engli...
Thank you, Jeff
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
participants (2)
-
Jeffrey Brown
-
Serguey Zefirov