-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workcraft Parsing #36
base: master
Are you sure you want to change the base?
Conversation
…tesBy to Pangraph.Internal.HexmlExtra
…it from Pangraph.Workcraft.Parse.parse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good, but see some comments above.
@@ -2,6 +2,7 @@ | |||
|
|||
## pangraph-0.2.1 | |||
* Bump Algebraic Graphs from 0.1.* to 0.2.* | |||
* Add Worcraft parsing via Pangraph.Workcraft.Parser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo "Worcraft"
|
||
-- An unsafe version of the 'Text.XML.Hexml.parse' upon failure throws error to stderr. | ||
-- An unsafe version of the 'Text.XML.Hexml.parse' upon failure throws error to stderr, showing the resulting error message. | ||
hexmlParse :: ByteString -> Node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we use unsafe
prefix for unsafe functions -- let's keep doing this for consistency.
main :: IO () | ||
main = do | ||
workcraftXML <- BS.readFile "./examples/graphs/model.xml" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also support parsing directly from work
files?
followChildren h [] = [h] | ||
followChildren h bs = (concatMap recurse . childrenBy h) (head bs) | ||
followChildren _ [] = [] | ||
followChildren h bs = if head bs == name h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be easier to read this if you use guard expressions, e.g. | head bs == ...
. Even better, avoid using partial functions like head
by pattern-matching (otherwise a future refactoring could introduce a bug).
extractEdgeData :: H.Node -> [Attribute] | ||
extractEdgeData h' = let | ||
-- Find the child node for this Edge | ||
child = (head $ H.followChildren h' ["node", "MathConnection"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, can we get rid of partial functions like head
? If the list is guaranteed to be non-empty, use Data.List.NonEmpty
.
Adds:
Workcraft parsing and associated docs.
Implemented with Protograph interface.
Closes #12