Skip to content
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

Irrefutable pattern exception when inserting edge from non-existent vertex #14

Closed
robstewart57 opened this issue Jun 4, 2015 · 0 comments

Comments

@robstewart57
Copy link
Contributor

Take the following example:

test :: Gr Int String
test = insEdge (0,1,"foo") (mkGraph [] [])

An evaluation attempt of test throws the following exception:

mkGraph *** Exception: Data/Graph/Inductive/Graph.hs:229:5-38: Irrefutable pattern failed for pattern (Just (pr, _, la, su), g')

The reason this is being thrown is because the vertex indexed with 0 does not exist in the graph I am trying to insert the edge into:

-- | Insert a 'LEdge' into the 'Graph'.
insEdge :: (DynGraph gr) => LEdge b -> gr a b -> gr a b
insEdge (v,w,l) g = (pr,v,la,(l,w):su) & g'
  where
    (Just (pr,_,la,su),g') = match v g

I'll send a pull request to add an informative error message in this case.

robstewart57 added a commit to robstewart57/fgl that referenced this issue Jun 4, 2015
As documented in haskell#14 , an
irrefutable pattern exception is thrown when attempting to insert an
edge from a vertex that does not exist in the graph, .e.g

    insEdge (0,1,"foo") (mkGraph [] [])

The previous behaviour of fgl was:

mkGraph *** Exception: Data/Graph/Inductive/Graph.hs:229:5-38: Irrefutable pattern failed for pattern (Just (pr, _, la, su), g')

The new behaviour is:

mkGraph *** Exception: insEdge: unable to add edge from non-existent vertex 0
robstewart57 added a commit to robstewart57/fgl that referenced this issue Jun 5, 2015
As documented in haskell#14 , an irrefutable pattern exception is
thrown when attempting to insert an edge from a vertex that does not
exist in the graph, .e.g

    insEdge (0,1,"foo") (mkGraph [] [])

The previous behaviour of fgl was:

mkGraph *** Exception: Data/Graph/Inductive/Graph.hs:229:5-38: Irrefutable pattern failed for pattern (Just (pr, _, la, su), g')

The new behaviour is:

mkGraph *** Exception: insEdge: unable to add edge from non-existent vertex 0

closes haskell#14
@ivan-m ivan-m closed this as completed in 7e9ffde Jul 13, 2015
psteiger pushed a commit to psteiger/fgl that referenced this issue Nov 8, 2015
As documented in haskell#14 , an irrefutable pattern exception is
thrown when attempting to insert an edge from a vertex that does not
exist in the graph, .e.g

    insEdge (0,1,"foo") (mkGraph [] [])

The previous behaviour of fgl was:

mkGraph *** Exception: Data/Graph/Inductive/Graph.hs:229:5-38: Irrefutable pattern failed for pattern (Just (pr, _, la, su), g')

The new behaviour is:

mkGraph *** Exception: insEdge: unable to add edge from non-existent vertex 0

closes haskell#14
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 a pull request may close this issue.

1 participant