Skip to content

Workcraft Parsing#36

Open
thisiswhereitype wants to merge 6 commits into
tuura:masterfrom
thisiswhereitype:feature/workcraft
Open

Workcraft Parsing#36
thisiswhereitype wants to merge 6 commits into
tuura:masterfrom
thisiswhereitype:feature/workcraft

Conversation

@thisiswhereitype

Copy link
Copy Markdown
Collaborator

Adds:
Workcraft parsing and associated docs.
Implemented with Protograph interface.
Closes #12

@thisiswhereitype thisiswhereitype added this to the 0.2.1 milestone Sep 26, 2018

@snowleopard snowleopard left a comment

Copy link
Copy Markdown
Member

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.

Comment thread changelog.md

## pangraph-0.2.1
* Bump Algebraic Graphs from 0.1.* to 0.2.*
* Add Worcraft parsing via Pangraph.Workcraft.Parser

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member

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.

Comment thread src/Pangraph/Example.hs

main :: IO ()
main = do
workcraftXML <- BS.readFile "./examples/graphs/model.xml"

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member

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"])

Copy link
Copy Markdown
Member

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.

@thisiswhereitype thisiswhereitype self-assigned this Oct 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants