Workcraft Parsing#36
Open
thisiswhereitype wants to merge 6 commits into
Open
Conversation
…tesBy to Pangraph.Internal.HexmlExtra
…it from Pangraph.Workcraft.Parse.parse.
snowleopard
reviewed
Sep 26, 2018
snowleopard
left a comment
Member
There was a problem hiding this comment.
Thanks, looks good, but see some comments above.
|
|
||
| ## pangraph-0.2.1 | ||
| * Bump Algebraic Graphs from 0.1.* to 0.2.* | ||
| * Add Worcraft parsing via Pangraph.Workcraft.Parser |
|
|
||
| -- 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 |
Member
There was a problem hiding this comment.
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" |
Member
There was a problem hiding this comment.
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 |
Member
There was a problem hiding this comment.
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"]) |
Member
There was a problem hiding this comment.
Again, can we get rid of partial functions like head? If the list is guaranteed to be non-empty, use Data.List.NonEmpty.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds:
Workcraft parsing and associated docs.
Implemented with Protograph interface.
Closes #12