<div>Dear Haskell folks,</div><div><br></div>I was attempting to do an EDSL that would allow me to describe regular expressions in Hakell and generate Perl as target - <div><br></div><div><a href="https://github.com/ckkashyap/LearningPrograms/blob/master/Haskell/edsl/regex.hs">https://github.com/ckkashyap/LearningPrograms/blob/master/Haskell/edsl/regex.hs</a></div>
<div><br></div><div><div>$ ghci regex.hs </div><div>GHCi, version 7.0.3: <a href="http://www.haskell.org/ghc/">http://www.haskell.org/ghc/</a>  :? for help</div><div>Loading package ghc-prim ... linking ... done.</div><div>
Loading package integer-gmp ... linking ... done.</div><div>Loading package base ... linking ... done.</div><div>Loading package ffi-1.0 ... linking ... done.</div><div>[1 of 1] Compiling Main             ( regex.hs, interpreted )</div>
<div>Ok, modules loaded: Main.</div><div>*Main&gt; let hello = stringToRegularExpression &quot;hello&quot;</div><div>*Main&gt; let world = stringToRegularExpression &quot;world&quot;</div><div>*Main&gt; :t hello</div><div>
hello :: RegularExpression</div><div>*Main&gt; :t world</div><div>world :: RegularExpression</div><div>*Main&gt; let re = listToSequence [ hello, oneOrMore world, hello ]</div><div>*Main&gt; re</div><div>hello(world)+hello</div>
<div><div>*Main&gt; :t re</div><div>re :: RegularExpression</div></div></div><div><br></div><div>I am looking for suggestions on how I could encode the anchors - ^ and $ and also how I could refer to captures. My goal is to be able to extend the idea to create an EDSL that could be used to build Perl tasks - such as filters, report generators etc</div>
<div><br></div><div>Arguably this could be seen as a pointless exercise because I could chose to do the scripting in Haskell itself but I have a practical problem that I have to deal with clusters that have a little dated version of Linux where I could not really build the Haskell and where Haskell generated executables don&#39;t seem to run. When I started out with this idea, I was thinking of embedding Perl in Haskell but later I thought that perhaps that will sort of beat the point of &quot;DS&quot; bit in EDSL. So, I have started on this idea of trying to encode very precise &quot;tasks&quot;.</div>
<div><br></div><div>Regards,</div><div>Kashyap</div>