Hi Roger,<div>On the contrary, I think that a parser combinator is a very modular solution. Each type of parseable string can be</div><div>recursively defined with the monadic functions of the combinator. These functions, of course, don&#39;t care about context and can be used wherever appropriate. If you send me a test file of headers and related outputs, I might see if I can whip something up to try to change your mind.</div>
<div><br></div><div>Regards,</div><div>Tim Holland<br><br><div class="gmail_quote">On 28 June 2013 09:40,  <span dir="ltr">&lt;<a href="mailto:beginners-request@haskell.org" target="_blank">beginners-request@haskell.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send Beginners mailing list submissions to<br>
        <a href="mailto:beginners@haskell.org">beginners@haskell.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
or, via email, send a message with subject or body &#39;help&#39; to<br>
        <a href="mailto:beginners-request@haskell.org">beginners-request@haskell.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:beginners-owner@haskell.org">beginners-owner@haskell.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than &quot;Re: Contents of Beginners digest...&quot;<br>
<br>
<br>
Today&#39;s Topics:<br>
<br>
   1. Re:  How to Lex, Parse, and Serialize-to-XML email messages<br>
      (Costello, Roger L.)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Fri, 28 Jun 2013 16:40:01 +0000<br>
From: &quot;Costello, Roger L.&quot; &lt;<a href="mailto:costello@mitre.org">costello@mitre.org</a>&gt;<br>
Subject: Re: [Haskell-beginners] How to Lex, Parse, and<br>
        Serialize-to-XML email messages<br>
To: &quot;The Haskell-Beginners Mailing List - Discussion of primarily<br>
        beginner-level topics related to Haskell&quot; &lt;<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>&gt;<br>
Message-ID:<br>
        &lt;<a href="mailto:B5FEE00B53CF054AA8439027E8FE17751EFA91FE@IMCMBX04.MITRE.ORG">B5FEE00B53CF054AA8439027E8FE17751EFA91FE@IMCMBX04.MITRE.ORG</a>&gt;<br>
Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<br>
<br>
Hi Tim,<br>
<br>
<br>
?  I realize you&#39;ve already finished with the project ...<br>
<br>
Actually, your message comes at an excellent time. I am not finished with the project. I have only finished one of the email headers -- the From Header.<br>
<br>
Just today I was wondering how to proceed next:<br>
<br>
<br>
-          Should I extend my parser so that it deals with each of the other email headers? That is, create one monolithic parser for the entire email message? That doesn&#39;t seem very modular. I don&#39;t think that Happy supports importing other Happy parsers. Ideally I would create a parser for the From Header, a parser for the To Header, a parser for the Subject Header,  and so forth. Then I would import each of them to create one unified email parser. If Happy doesn&#39;t support importing, I figured it might be better to switch to something that can combine parsers - a parser combinator - such as parsec. Unfortunately, I don&#39;t know anything about Parsec, but am eager to learn.<br>

<br>
-          I wonder if I can use Happy to generate individual parsers - a parser for the From Header, a parser for the To Header, a parser for the Subject Header - and then use Parsec to combine them?<br>
<br>
As you see Tim, your suggestion to use parsec falls on receptive ears. I welcome all suggestions.<br>
<br>
/Roger<br>
<br>
From: <a href="mailto:beginners-bounces@haskell.org">beginners-bounces@haskell.org</a> [mailto:<a href="mailto:beginners-bounces@haskell.org">beginners-bounces@haskell.org</a>] On Behalf Of Tim Holland<br>
Sent: Friday, June 28, 2013 12:18 PM<br>
To: <a href="mailto:beginners@haskell.org">beginners@haskell.org</a><br>
Subject: Re: [Haskell-beginners] How to Lex, Parse, and Serialize-to-XML email messages<br>
<br>
Hi Roger,<br>
<br>
I realize you&#39;ve already finished with the project, but for the future I think its a lot easier to use a parser combinator with Text.Parsec and Text.Parsec.String to  do a similar thing. For example, if you were parsing XML to get a parse a single tag, you would try something like this:<br>

<br>
parseTag :: Parser Tag<br>
parseTag = many1 alphanum &lt;?&gt; &quot;tag&quot;<br>
<br>
To get a tagged form, try<br>
parseTagged :: Parser (Tag, [Elem])<br>
parseTagged = do<br>
  char &#39;&lt;&#39;<br>
  name &lt;- parseTag<br>
  char &#39;&gt;&#39;<br>
  content &lt;- many (try parseElem)<br>
  string &quot;&lt;/&quot;<br>
  parseTag<br>
  char &#39;&gt;&#39;<br>
  return (name, content)<br>
  &lt;?&gt; &quot;tagged form&quot;<br>
<br>
and so one. I haven&#39;t tried this out, but a parser similar to yours would go something like this:<br>
<br>
--Datatypes<br>
type DisplayName = String<br>
type EmailAddress = String<br>
data Mailbox = Mailbox DisplayName EmailAddress deriving (Show)<br>
<br>
parseFromHeader :: Parser [Mailbox]<br>
parseFromHeader = do<br>
  string &quot;From: &quot;<br>
  mailboxes = many (try parseMailbox)<br>
  return mailboxes<br>
<br>
parseMailbox :: Parser Mailbox<br>
parseMailbox = do<br>
  parseComments<br>
  -- Names are optional<br>
  parseComments<br>
  name &lt;- try parseDisplayName<br>
  parseComments<br>
  address &lt;- parseEmailAddress<br>
  parseComments<br>
  try char &#39;,&#39;<br>
  return Mailbox name address<br>
  &lt;?&gt; &quot;Parse an indidivuals mailbox&quot;<br>
<br>
parseEmailAddress :: Parser EmailAddress<br>
parseEmailAddress = do<br>
  try char &#39;&lt;&#39;<br>
  handle &lt;- many1 (noneof &quot;@&quot;) -- Or whatever is valid here<br>
  char &#39;@&#39;<br>
  domain &lt;- parseDomain<br>
  try char &#39;&lt;&#39;<br>
  return handle++@++domain<br>
<br>
parseDomain :: Parser String<br>
parseDomain =<br>
  (char &#39;[&#39; &gt;&gt; parseDomain &gt;&gt;= (\domainName -&gt; do char &#39;]&#39;<br>
    return domainName))<br>
&lt;|&gt; parseWebsiteName &gt;&gt;= return<br>
<br>
And so on. Again, I&#39;ve tested none of the Email header bits but the XML bit works. It requires some level of comfort with monadic operations, but beyond that I think it&#39;s a much simpler may to parse.<br>
<br>
Regards,<br>
Tim Holland<br>
<br>
<br>
<br>
<br>
<br>
On 28 June 2013 03:00, &lt;<a href="mailto:beginners-request@haskell.org">beginners-request@haskell.org</a>&lt;mailto:<a href="mailto:beginners-request@haskell.org">beginners-request@haskell.org</a>&gt;&gt; wrote:<br>
Send Beginners mailing list submissions to<br>
        <a href="mailto:beginners@haskell.org">beginners@haskell.org</a>&lt;mailto:<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>&gt;<br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
or, via email, send a message with subject or body &#39;help&#39; to<br>
        <a href="mailto:beginners-request@haskell.org">beginners-request@haskell.org</a>&lt;mailto:<a href="mailto:beginners-request@haskell.org">beginners-request@haskell.org</a>&gt;<br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:beginners-owner@haskell.org">beginners-owner@haskell.org</a>&lt;mailto:<a href="mailto:beginners-owner@haskell.org">beginners-owner@haskell.org</a>&gt;<br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than &quot;Re: Contents of Beginners digest...&quot;<br>
<br>
<br>
Today&#39;s Topics:<br>
<br>
   1.  data declaration using other type&#39;s names? (Patrick Redmond)<br>
   2. Re:  data declaration using other type&#39;s names? (Brandon Allbery)<br>
   3. Re:  data declaration using other type&#39;s names? (Nikita Danilenko)<br>
   4. Re:  what to do about excess memory usage (Chadda? Fouch?)<br>
   5. Re:  what to do about excess memory usage (James Jones)<br>
   6.  How to Lex, Parse,       and Serialize-to-XML email messages<br>
      (Costello, Roger L.)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Thu, 27 Jun 2013 11:24:51 -0400<br>
From: Patrick Redmond &lt;<a href="mailto:plredmond@gmail.com">plredmond@gmail.com</a>&lt;mailto:<a href="mailto:plredmond@gmail.com">plredmond@gmail.com</a>&gt;&gt;<br>
Subject: [Haskell-beginners] data declaration using other type&#39;s<br>
        names?<br>
To: <a href="mailto:beginners@haskell.org">beginners@haskell.org</a>&lt;mailto:<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>&gt;<br>
Message-ID:<br>
        &lt;CAHUea4FfBP8L1kU+tS1-2cVPvAB4h22j35JcNwRC-jGds0=<a href="mailto:v6g@mail.gmail.com">v6g@mail.gmail.com</a>&lt;mailto:<a href="mailto:v6g@mail.gmail.com">v6g@mail.gmail.com</a>&gt;&gt;<br>
Content-Type: text/plain; charset=UTF-8<br>
<br>
Hey Haskellers,<br>
<br>
I noticed that ghci lets me do this:<br>
<br>
&gt; data Foo = Int Int | Float<br>
&gt; :t Int<br>
Int :: Int -&gt; Foo<br>
&gt; :t Float<br>
Float :: Foo<br>
&gt; :t Int 4<br>
Int 4 :: Foo<br>
<br>
It&#39;s confusing to have type constructors that use names of existing<br>
types. It&#39;s not intuitive that the name &quot;Int&quot; could refer to two<br>
different things, which brings me to:<br>
<br>
&gt; data Bar = Bar Int<br>
&gt; :t Bar<br>
Bar :: Int -&gt; Bar<br>
<br>
Yay? I can have a simple type with one constructor named the same as the type.<br>
<br>
Why is this allowed? Is it useful somehow?<br>
<br>
--Patrick<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Thu, 27 Jun 2013 11:37:46 -0400<br>
From: Brandon Allbery &lt;<a href="mailto:allbery.b@gmail.com">allbery.b@gmail.com</a>&lt;mailto:<a href="mailto:allbery.b@gmail.com">allbery.b@gmail.com</a>&gt;&gt;<br>
Subject: Re: [Haskell-beginners] data declaration using other type&#39;s<br>
        names?<br>
To: The Haskell-Beginners Mailing List - Discussion of primarily<br>
        beginner-level topics related to Haskell &lt;<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>&lt;mailto:<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>&gt;&gt;<br>
Message-ID:<br>
        &lt;<a href="mailto:CAKFCL4U-E4B_%2Bcts0vpNX8Ar9wccQDjgzWOYHLXLsLAv%2BQn_cg@mail.gmail.com">CAKFCL4U-E4B_+cts0vpNX8Ar9wccQDjgzWOYHLXLsLAv+Qn_cg@mail.gmail.com</a>&lt;mailto:<a href="mailto:CAKFCL4U-E4B_%252Bcts0vpNX8Ar9wccQDjgzWOYHLXLsLAv%252BQn_cg@mail.gmail.com">CAKFCL4U-E4B_%2Bcts0vpNX8Ar9wccQDjgzWOYHLXLsLAv%2BQn_cg@mail.gmail.com</a>&gt;&gt;<br>

Content-Type: text/plain; charset=&quot;utf-8&quot;<br>
<br>
On Thu, Jun 27, 2013 at 11:24 AM, Patrick Redmond &lt;<a href="mailto:plredmond@gmail.com">plredmond@gmail.com</a>&lt;mailto:<a href="mailto:plredmond@gmail.com">plredmond@gmail.com</a>&gt;&gt;wrote:<br>
<br>
&gt; I noticed that ghci lets me do this:<br>
&gt;<br>
<br>
Not just ghci, but ghc as well.<br>
<br>
<br>
&gt; Yay? I can have a simple type with one constructor named the same as the<br>
&gt; type.<br>
&gt; Why is this allowed? Is it useful somehow?<br>
&gt;<br>
<br>
It&#39;s convenient for pretty much the situation you showed, where the type<br>
constructor and data constructor have the same name. A number of people do<br>
advocate that it not be used, though, because it can be confusing for<br>
people. (Not for the compiler; data and type constructors can&#39;t be used in<br>
the same places, it never has trouble keeping straight which is which.)<br>
<br>
It might be best to consider this as &quot;there is no good reason to *prevent*<br>
it from happening, from a language standpoint&quot;.<br>
<br>
--<br>
brandon s allbery kf8nh                               sine nomine associates<br>
<a href="mailto:allbery.b@gmail.com">allbery.b@gmail.com</a>&lt;mailto:<a href="mailto:allbery.b@gmail.com">allbery.b@gmail.com</a>&gt;                                  <a href="mailto:ballbery@sinenomine.net">ballbery@sinenomine.net</a>&lt;mailto:<a href="mailto:ballbery@sinenomine.net">ballbery@sinenomine.net</a>&gt;<br>

unix, openafs, kerberos, infrastructure, xmonad        <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: &lt;<a href="http://www.haskell.org/pipermail/beginners/attachments/20130627/ea0e9cc5/attachment-0001.htm" target="_blank">http://www.haskell.org/pipermail/beginners/attachments/20130627/ea0e9cc5/attachment-0001.htm</a>&gt;<br>

<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Thu, 27 Jun 2013 18:02:00 +0200<br>
From: Nikita Danilenko &lt;<a href="mailto:nda@informatik.uni-kiel.de">nda@informatik.uni-kiel.de</a>&lt;mailto:<a href="mailto:nda@informatik.uni-kiel.de">nda@informatik.uni-kiel.de</a>&gt;&gt;<br>
Subject: Re: [Haskell-beginners] data declaration using other type&#39;s<br>
        names?<br>
To: <a href="mailto:beginners@haskell.org">beginners@haskell.org</a>&lt;mailto:<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>&gt;<br>
Message-ID: &lt;<a href="mailto:51CC61F8.9020506@informatik.uni-kiel.de">51CC61F8.9020506@informatik.uni-kiel.de</a>&lt;mailto:<a href="mailto:51CC61F8.9020506@informatik.uni-kiel.de">51CC61F8.9020506@informatik.uni-kiel.de</a>&gt;&gt;<br>

Content-Type: text/plain; charset=ISO-8859-1<br>
<br>
Hi, Patrick,<br>
<br>
the namespaces for types and constructors are considered disjoint, i.e.<br>
you can use a name in both contexts. A simple example of this feature is<br>
your last definition<br>
<br>
&gt; data Bar = Bar Int<br>
<br>
or even shorter<br>
<br>
&gt; data A = A<br>
<br>
This is particularly useful for single-constructor types ? la<br>
<br>
&gt; data MyType a = MyType a<br>
<br>
Clearly, using &quot;Int&quot; or &quot;Float&quot; as constructor names may seem odd, but<br>
when dealing with a simple grammar it is quite natural to write<br>
<br>
&gt; data Exp = Num Int | Add Exp Exp<br>
<br>
although &quot;Num&quot; is a type class in Haskell.<br>
<br>
Best regards,<br>
<br>
Nikita<br>
<br>
On 27/06/13 17:24, Patrick Redmond wrote:<br>
&gt; Hey Haskellers,<br>
&gt;<br>
&gt; I noticed that ghci lets me do this:<br>
&gt;<br>
&gt;&gt; data Foo = Int Int | Float<br>
&gt;&gt; :t Int<br>
&gt; Int :: Int -&gt; Foo<br>
&gt;&gt; :t Float<br>
&gt; Float :: Foo<br>
&gt;&gt; :t Int 4<br>
&gt; Int 4 :: Foo<br>
&gt;<br>
&gt; It&#39;s confusing to have type constructors that use names of existing<br>
&gt; types. It&#39;s not intuitive that the name &quot;Int&quot; could refer to two<br>
&gt; different things, which brings me to:<br>
&gt;<br>
&gt;&gt; data Bar = Bar Int<br>
&gt;&gt; :t Bar<br>
&gt; Bar :: Int -&gt; Bar<br>
&gt;<br>
&gt; Yay? I can have a simple type with one constructor named the same as the type.<br>
&gt;<br>
&gt; Why is this allowed? Is it useful somehow?<br>
&gt;<br>
&gt; --Patrick<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Beginners mailing list<br>
&gt; <a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a>&lt;mailto:<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a>&gt;<br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 4<br>
Date: Thu, 27 Jun 2013 18:23:25 +0200<br>
From: Chadda? Fouch? &lt;<a href="mailto:chaddai.fouche@gmail.com">chaddai.fouche@gmail.com</a>&lt;mailto:<a href="mailto:chaddai.fouche@gmail.com">chaddai.fouche@gmail.com</a>&gt;&gt;<br>
Subject: Re: [Haskell-beginners] what to do about excess memory usage<br>
To: The Haskell-Beginners Mailing List - Discussion of primarily<br>
        beginner-level topics related to Haskell &lt;<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>&lt;mailto:<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>&gt;&gt;<br>
Message-ID:<br>
        &lt;<a href="mailto:CANfjZRbGTvoECTMsriNDAUozbow1fUGt-9FRtG-XwRJ%2BDamiAw@mail.gmail.com">CANfjZRbGTvoECTMsriNDAUozbow1fUGt-9FRtG-XwRJ+DamiAw@mail.gmail.com</a>&lt;mailto:<a href="mailto:CANfjZRbGTvoECTMsriNDAUozbow1fUGt-9FRtG-XwRJ%252BDamiAw@mail.gmail.com">CANfjZRbGTvoECTMsriNDAUozbow1fUGt-9FRtG-XwRJ%2BDamiAw@mail.gmail.com</a>&gt;&gt;<br>

Content-Type: text/plain; charset=&quot;utf-8&quot;<br>
<br>
First 2MB isn&#39;t a lot of RAM nowadays, do you mean 2GB or is that just<br>
compared to the rest of the program ?<br>
Second, your powersOfTen should probably be :<br>
<br>
&gt; powersOfTen = iterate (10*) 1<br>
<br>
Or maybe even a Vector (if you can guess the maximum value asked of it) or<br>
a MemoTrie (if you can&#39;t) since list indexing is slow as hell.<br>
That could help with memoPair which should definitely be a Vector and not a<br>
list.<br>
<br>
Good luck (on the other hand, maybe your program is already &quot;good enough&quot;<br>
and you could just switch to another project)<br>
--<br>
Jedai<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: &lt;<a href="http://www.haskell.org/pipermail/beginners/attachments/20130627/f2da75ff/attachment-0001.htm" target="_blank">http://www.haskell.org/pipermail/beginners/attachments/20130627/f2da75ff/attachment-0001.htm</a>&gt;<br>

<br>
------------------------------<br>
<br>
Message: 5<br>
Date: Thu, 27 Jun 2013 18:28:27 -0500<br>
From: James Jones &lt;<a href="mailto:jejones3141@gmail.com">jejones3141@gmail.com</a>&lt;mailto:<a href="mailto:jejones3141@gmail.com">jejones3141@gmail.com</a>&gt;&gt;<br>
Subject: Re: [Haskell-beginners] what to do about excess memory usage<br>
To: The Haskell-Beginners Mailing List - Discussion of primarily<br>
        beginner-level topics related to Haskell &lt;<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>&lt;mailto:<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>&gt;&gt;<br>
Message-ID: &lt;<a href="mailto:51CCCA9B.40807@gmail.com">51CCCA9B.40807@gmail.com</a>&lt;mailto:<a href="mailto:51CCCA9B.40807@gmail.com">51CCCA9B.40807@gmail.com</a>&gt;&gt;<br>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br>
<br>
On 06/27/2013 11:23 AM, Chadda? Fouch? wrote:<br>
&gt; First 2MB isn&#39;t a lot of RAM nowadays, do you mean 2GB or is that just<br>
&gt; compared to the rest of the program ?<br>
<br>
It&#39;s a lot compared to the rest of the program... not to mention that<br>
I&#39;m a fossil from the days of 8-bit microprocessors, so 2 MB seems like<br>
a lot of RAM to me. :)<br>
<br>
&gt; Second, your powersOfTen should probably be :<br>
&gt;<br>
&gt; &gt; powersOfTen = iterate (10*) 1<br>
&gt;<br>
&gt; Or maybe even a Vector (if you can guess the maximum value asked of<br>
&gt; it) or a MemoTrie (if you can&#39;t) since list indexing is slow as hell.<br>
&gt; That could help with memoPair which should definitely be a Vector and<br>
&gt; not a list.<br>
<br>
Thanks!<br>
&gt;<br>
&gt; Good luck (on the other hand, maybe your program is already &quot;good<br>
&gt; enough&quot; and you could just switch to another project)<br>
&gt; --<br>
&gt; Jedai<br>
&gt;<br>
I do want to find a better way to keep the list of positions for ones<br>
around than a [Int], and I want to save them only as long as I need to,<br>
i.e. until I have both the 2 * k and 2 * k + 1 digit palindromes. Once<br>
that&#39;s done, I will move on. Thanks again!<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Message: 6<br>
Date: Fri, 28 Jun 2013 09:30:30 +0000<br>
From: &quot;Costello, Roger L.&quot; &lt;<a href="mailto:costello@mitre.org">costello@mitre.org</a>&lt;mailto:<a href="mailto:costello@mitre.org">costello@mitre.org</a>&gt;&gt;<br>
Subject: [Haskell-beginners] How to Lex, Parse, and Serialize-to-XML<br>
        email messages<br>
To: &quot;<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>&lt;mailto:<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>&gt;&quot; &lt;<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>&lt;mailto:<a href="mailto:beginners@haskell.org">beginners@haskell.org</a>&gt;&gt;<br>

Message-ID:<br>
        &lt;<a href="mailto:B5FEE00B53CF054AA8439027E8FE17751EFA9005@IMCMBX04.MITRE.ORG">B5FEE00B53CF054AA8439027E8FE17751EFA9005@IMCMBX04.MITRE.ORG</a>&lt;mailto:<a href="mailto:B5FEE00B53CF054AA8439027E8FE17751EFA9005@IMCMBX04.MITRE.ORG">B5FEE00B53CF054AA8439027E8FE17751EFA9005@IMCMBX04.MITRE.ORG</a>&gt;&gt;<br>

Content-Type: text/plain; charset=&quot;us-ascii&quot;<br>
<br>
Hi Folks,<br>
<br>
I am working toward being able to input any email message and output an equivalent XML encoding.<br>
<br>
I am starting small, with one of the email headers -- the &quot;From Header&quot;<br>
<br>
Here is an example of a From Header:<br>
<br>
        From: John Doe &lt;<a href="mailto:john@doe.org">john@doe.org</a>&lt;mailto:<a href="mailto:john@doe.org">john@doe.org</a>&gt;&gt;<br>
<br>
I have successfully transformed it into this XML:<br>
<br>
        &lt;From&gt;<br>
            &lt;Mailbox&gt;<br>
                &lt;DisplayName&gt;John Doe&lt;/DisplayName&gt;<br>
                &lt;Address&gt;<a href="mailto:john@doe.org">john@doe.org</a>&lt;mailto:<a href="mailto:john@doe.org">john@doe.org</a>&gt;&lt;/Address&gt;<br>
            &lt;/Mailbox&gt;<br>
        &lt;/From&gt;<br>
<br>
I used the lexical analyzer &quot;Alex&quot; [1] to break apart (tokenize) the From Header.<br>
<br>
I used the parser &quot;Happy&quot; [2] to process the tokens and generate a parse tree.<br>
<br>
Then I used a serializer to walk the parse tree and output XML.<br>
<br>
I posted to stackoverflow a complete description of how to lex, parse, and serialize-to-XML email From Headers:<br>
<br>
<a href="http://stackoverflow.com/questions/17354442/how-to-lex-parse-and-serialize-to-xml-email-messages-using-alex-and-happy" target="_blank">http://stackoverflow.com/questions/17354442/how-to-lex-parse-and-serialize-to-xml-email-messages-using-alex-and-happy</a><br>

<br>
/Roger<br>
<br>
[1] The Alex User&#39;s Guide may be found at this URL: <a href="http://www.haskell.org/alex/doc/html/" target="_blank">http://www.haskell.org/alex/doc/html/</a><br>
<br>
[2] The Happy User&#39;s Guide may be found at this URL: <a href="http://www.haskell.org/happy/" target="_blank">http://www.haskell.org/happy/</a><br>
<br>
<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a>&lt;mailto:<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a>&gt;<br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br>
<br>
End of Beginners Digest, Vol 60, Issue 38<br>
*****************************************<br>
<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: &lt;<a href="http://www.haskell.org/pipermail/beginners/attachments/20130628/50dc9101/attachment.htm" target="_blank">http://www.haskell.org/pipermail/beginners/attachments/20130628/50dc9101/attachment.htm</a>&gt;<br>

<br>
------------------------------<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br>
<br>
End of Beginners Digest, Vol 60, Issue 40<br>
*****************************************<br>
</blockquote></div><br></div>