Reputation: 582
I have problem to extract extra information from my parsing.
I have my own data structure to parse, and that works fine. I wrote the parser for my data structure as Parse MyDataStructure
which parse all the information about MyDataStructure
.
The problem is that in the string I'm parsing, mixed with MyDataStructure
, there is also some information about what should I do with MyDataStructure
which is of course not part of MyDataStructure
, i.e. I cannot store this information inside MyDataStructure
.
Now the problem is that I don't know how to store this information, since in Haskell I cannot change some global variable to store information, and the return value of my parser is already MyDataStructure
.
Is there a way I can somehow store this new information, without changing MyDataStructure
, i.e. including field to store the extra information (but the extra information are not part of MyDataStructure
so I would really like avoiding doing that)?
I hope I have been clear enough.
Upvotes: 1
Views: 139
Reputation: 3375
As @9000 says, you could use a tuple. If you find yourself needing to pass it through a number of functions, using the State Monad might make things easier.
Upvotes: 2