[Haskell] Irrefutable patterns allowing mutually dependent functions.

Michael Speer knomenet at gmail.com
Fri Jul 27 17:23:41 EDT 2007


Some time ago I wrote to this list linking to a regular expression
engine I was writing in order to learn the Haskell programming
language.  I had noted the ability to send a single functions output
into it as the its input and had tried using this property of the
language in a rather winding way to transform a string regular
expression into an integer based array of rules approximating DFAs.
At the time I just smashed the stack as mutually dependent functions
called one another recursively, each depending on the output of the
other to execute.  I didn't know a way around this, or even if Haskell
provided a way around this.

Yesterday a link from reddit to a site concerning `irrefutable
patterns` caused me to jump back to the code and see if they allowed
for what I wanted.

They did.

The working code can be found here :
   http://rx-haskell.googlecode.com/svn/trunk/rx.hs

The link goes to a simple regular expression matcher a little under
200 lines long that can accept a regex string with operands (*), (*?),
(?), (??), (+) and grouping using parenthesis.  I hope to update the
code with bracketed ranges and things soon.

Any comments, questions, or criticisms from the list would be highly
appreciated.

- Michael Speer .


More information about the Haskell mailing list