[Haskell-cafe] Pattern match failure, then inconsistent function behavior

Adam Wyner adam at wyner.info
Mon Aug 22 10:41:45 EDT 2005


Hi,

I am getting a "pattern match failure", and then a function
which worked right works wrong.  I am using Hugs and Trex.

While most of the other functions in my module work fine, the function 
"findCoordinatesUtil" generates an error, then misbehaves.  The function 
takes a record and a list of records, then searches the list of records 
to find other records which are in a specified relationship with the 
input function.  In the first example, it works fine:

LexicalSemantics03> findCoordinatesUtil (giveActionFromLabel "Action6"
  testLexActions03) testLexActions03

[(label="Action7", xcond=["prop1","prop7","prop5"], ycond=["prop3","pr
op4","neg-prop6"]),(label="Action08", xcond=["prop1","prop7","prop5"],
  ycond=["prop3","neg-prop6","prop5"]),(label="Action09", xcond=["prop1
","prop7","prop5"], ycond=["prop3","neg-prop6","neg-prop1"])]

However, when I run the function on a larger list of records (here
testList01), it generates an error message.

LexicalSemantics03> findCoordinatesUtil (giveActionFromLabel "Action33
" testList01) testList01

Program error: pattern match failure: map_v780 (instEq_v20 instEq_v11
Eq_== "neg-prop2") map_v780
INTERNAL ERROR: Error in graph

Moreover, when I subsequently run the function, I get a different (and
wrong) result -- label-"Action08" is missing.

LexicalSemantics03> findCoordinatesUtil (giveActionFromLabel "Action6"
  testLexActions03) testLexActions03

[(label="Action7", xcond=["prop1","prop7","prop5"], ycond=["prop3","pr
op4","neg-prop6"]),(label="Action09", xcond=["prop1","prop7","prop5"],
  ycond=["prop3","neg-prop6","neg-prop1"])]

When I reload the module, it correctly works again.

LexicalSemantics03> :r
LexicalSemantics03> findCoordinatesUtil (giveActionFromLabel "Action6"
  testLexActions03) testLexActions03

[(label="Action7", xcond=["prop1","prop7","prop5"], ycond=["prop3","pr
op4","neg-prop6"]),(label="Action08", xcond=["prop1","prop7","prop5"],
  ycond=["prop3","neg-prop6","prop5"]),(label="Action09", xcond=["prop1
","prop7","prop5"], ycond=["prop3","neg-prop6","neg-prop1"])]

I don't understand the pattern match failure or how to correct it.  What
is this error message telling me?

Thanks,
Adam Wyner


More information about the Haskell-Cafe mailing list