``a+b+'', is a pattern that can be
used to express a searching problem. (In this case the pattern matches a string of 1 or more a's followed by a string of 1 or more b's.)
There are a number of regular expression libraries around. One of the best can be found in the Perl programming language. The new GHC regexp library, provided here, is a regular expression package for the purely functional language Haskell. It has a number of important features:
data Temp = Celsius Int
| Fahrenheit Int
| Kelvin Int
and a list of Temp elements,
xs = [Kelvin 200, Kelvin 200, Celcius 5]
we could use the polymorphic library to search for a sequence of Kelvin 200:
search "< Kelvin 200>*" xs
(((...)))
case prog of
</--.*\n/> -> A -- deal with comment
</>.*\n/> -> B -- deal with line of code
_ -> C -- otherwise
This would do A if a comment (line beginning with --) was found. It would do B, if a line of code
(line beginning with >) were found. Otherwise it would do C.
The regexp library works with all current versions of GHC (the Glasgow haskell compiler).
The regexp library (including all documentation) is available in three versions.