No subject
Wed Apr 10 17:18:51 CEST 2013
nbsp;and so forth. Then I would import each of them
to create one unified email parser. If Happy doesn’t support importi=
ng, I figured it might be better to switch to something that can combine pa=
rsers – a parser combinator – such as parsec. Unfortunately, I =
don’t know anything about Parsec, but am eager to
learn. <o:p></o:p></span></p>
<p class=3D"MsoListParagraph" style=3D"text-indent:-.25in;mso-list:l0 level=
1 lfo2"><![if !supportLists]><span style=3D"font-size:11.0pt;font-family:&q=
uot;Calibri","sans-serif";color:#1F497D"><span style=3D"mso-=
list:Ignore">-<span style=3D"font:7.0pt "Times New Roman""> =
</span></span></span><![endif]><span style=3D"font-size:11.0pt;font-family:=
"Calibri","sans-serif";color:#1F497D">I wonder if I can=
use Happy to generate individual parsers – a parser for the From Hea=
der, a parser for the To Header, a parser for the Subject Header
– and then use Parsec to combine them?<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><o:p> </o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">As you see Tim, your sugg=
estion to use parsec falls on receptive ears. I welcome all suggestions.<o:=
p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><o:p> </o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D">/Roger<o:p></o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:"Ca=
libri","sans-serif";color:#1F497D"><o:p> </o:p></span><=
/p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><b><span style=3D"font-si=
ze:10.0pt;font-family:"Tahoma","sans-serif"">From:</spa=
n></b><span style=3D"font-size:10.0pt;font-family:"Tahoma","=
sans-serif""> beginners-bounces at haskell.org [mailto:beginners-bounces@=
haskell.org]
<b>On Behalf Of </b>Tim Holland<br>
<b>Sent:</b> Friday, June 28, 2013 12:18 PM<br>
<b>To:</b> beginners at haskell.org<br>
<b>Subject:</b> Re: [Haskell-beginners] How to Lex, Parse, and Serialize-to=
-XML email messages<o:p></o:p></span></p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p> </o:p></p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">Hi Roger,<o:p></o:p></p>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">I realize you've already =
finished with the project, but for the future I think its a lot easier to u=
se 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=
:<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">parseTag :: Parser Tag<o:=
p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">parseTag =3D many1 alphan=
um <?> "tag"<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">To get a tagged form, try=
<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">parseTagged :: Parser (Ta=
g, [Elem])<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">parseTagged =3D do<o:p></=
o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> char '<'<o:p></=
o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> name <- parseTa=
g<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> char '>'<o:p></=
o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> content <- many=
(try parseElem)<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> string "</=
"<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> parseTag<o:p></o:p=
></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> char '>'<o:p></=
o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> return (name, cont=
ent)<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> <?> "ta=
gged form"<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">and so one. I haven't tri=
ed this out, but a parser similar to yours would go something like this:<o:=
p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">--Datatypes<o:p></o:p></p=
>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">type DisplayName =3D Stri=
ng<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">type EmailAddress =3D Str=
ing<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">data Mailbox =3D Mailbox =
DisplayName EmailAddress deriving (Show)<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">parseFromHeader :: Parser=
[Mailbox]<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">parseFromHeader =3D do<o:=
p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> string "From:=
"<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> mailboxes =3D many=
(try parseMailbox)<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> return mailboxes<o=
:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">parseMailbox :: Parser Ma=
ilbox<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">parseMailbox =3D do<o:p><=
/o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> parseComments<o:p>=
</o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> -- Names are optio=
nal<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> parseComments<o:p>=
</o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> name <- try par=
seDisplayName<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> parseComments =
;<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> address <- pars=
eEmailAddress<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> parseComments<o:p>=
</o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> try char ','<o:p><=
/o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> return Mailbox nam=
e address<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> <?> "Pa=
rse an indidivuals mailbox"<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">parseEmailAddress :: Pars=
er EmailAddress<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">parseEmailAddress =3D do<=
o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> try char '<'<o:=
p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> handle <- many1=
(noneof "@") -- Or whatever is valid here<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> char '@'<o:p></o:p=
></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> domain <- parse=
Domain<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> try char '<'<o:=
p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> return handle+=
+@++domain<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">parseDomain :: Parser Str=
ing<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">parseDomain =3D <o:p=
></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> (char '[' >>=
parseDomain >>=3D (\domainName -> do char ']'<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> return doma=
inName))<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><|> parseWebsiteNam=
e >>=3D return<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">And so on. Again, I've te=
sted 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's a mu=
ch simpler may to parse.<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">Regards,<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">Tim Holland<o:p></o:p></p=
>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> &nbs=
p; &n=
bsp; <o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"> <o:p></o:p></=
p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p> </o:p></p>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">On 28 June 2013 03:00, &l=
t;<a href=3D"mailto:beginners-request at haskell.org" target=3D"_blank">beginn=
ers-request at haskell.org</a>> wrote:<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">Send Beginners mailing li=
st submissions to<br>
<a href=3D"mailto:beginners at haskell.org">beginn=
ers at haskell.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href=3D"http://www.haskell.org/mailman/listi=
nfo/beginners" target=3D"_blank">
http://www.haskell.org/mailman/listinfo/beginners</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href=3D"mailto:beginners-request at haskell.org=
">beginners-request at haskell.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href=3D"mailto:beginners-owner at haskell.org">=
beginners-owner at haskell.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Beginners digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. data declaration using other type's names? (Patrick R=
edmond)<br>
2. Re: data declaration using other type's names? (Brand=
on Allbery)<br>
3. Re: data declaration using other type's names? (Nikit=
a Danilenko)<br>
4. Re: what to do about excess memory usage (Chadda? Fou=
ch?)<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 <<a href=3D"mailto:plredmond at gmail.com">plredmond@=
gmail.com</a>><br>
Subject: [Haskell-beginners] data declaration using other type's<br>
names?<br>
To: <a href=3D"mailto:beginners at haskell.org">beginners at haskell.org</a><br>
Message-ID:<br>
<CAHUea4FfBP8L1kU+tS1-2cVPvAB4h22j35JcNw=
RC-jGds0=3D<a href=3D"mailto:v6g at mail.gmail.com">v6g at mail.gmail.com</a>>=
<br>
Content-Type: text/plain; charset=3DUTF-8<br>
<br>
Hey Haskellers,<br>
<br>
I noticed that ghci lets me do this:<br>
<br>
> data Foo =3D Int Int | Float<br>
> :t Int<br>
Int :: Int -> Foo<br>
> :t Float<br>
Float :: Foo<br>
> :t Int 4<br>
Int 4 :: Foo<br>
<br>
It's confusing to have type constructors that use names of existing<br>
types. It's not intuitive that the name "Int" could refer to two<=
br>
different things, which brings me to:<br>
<br>
> data Bar =3D Bar Int<br>
> :t Bar<br>
Bar :: Int -> Bar<br>
<br>
Yay? I can have a simple type with one constructor named the same as the ty=
pe.<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 <<a href=3D"mailto:allbery.b at gmail.com">allbery.b@=
gmail.com</a>><br>
Subject: Re: [Haskell-beginners] data declaration using other type's<br>
names?<br>
To: The Haskell-Beginners Mailing List - Discussion of primarily<br>
beginner-level topics related to Haskell <<a=
href=3D"mailto:beginners at haskell.org">beginners at haskell.org</a>><br>
Message-ID:<br>
<<a href=3D"mailto:CAKFCL4U-E4B_%2Bcts0vpNX8=
Ar9wccQDjgzWOYHLXLsLAv%2BQn_cg at mail.gmail.com">CAKFCL4U-E4B_+cts0vpNX8A=
r9wccQDjgzWOYHLXLsLAv+Qn_cg at mail.gmail.com</a>><br>
Content-Type: text/plain; charset=3D"utf-8"<br>
<br>
On Thu, Jun 27, 2013 at 11:24 AM, Patrick Redmond <<a href=3D"mailto:plr=
edmond at gmail.com">plredmond at gmail.com</a>>wrote:<br>
<br>
> I noticed that ghci lets me do this:<br>
><br>
<br>
Not just ghci, but ghc as well.<br>
<br>
<br>
> Yay? I can have a simple type with one constructor named the same as t=
he<br>
> type.<br>
> Why is this allowed? Is it useful somehow?<br>
><br>
<br>
It'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'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 "there is no good reason to *prev=
ent*<br>
it from happening, from a language standpoint".<br>
<br>
--<br>
brandon s allbery kf8nh &n=
bsp; sine nomine associate=
s<br>
<a href=3D"mailto:allbery.b at gmail.com">allbery.b at gmail.com</a>  =
; &nb=
sp; <a href=3D"mailto:ballbery at sinenomine.net">b=
allbery at sinenomine.net</a><br>
unix, openafs, kerberos, infrastructure, xmonad =
<a href=3D"http://sinenomine.net" target=3D"_blank">http://sinenomine.net</=
a><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href=3D"http://www.haskell.org/pipermail/beginners/attachments/=
20130627/ea0e9cc5/attachment-0001.htm" target=3D"_blank">http://www.haskell=
.org/pipermail/beginners/attachments/20130627/ea0e9cc5/attachment-0001.htm<=
/a>><br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Thu, 27 Jun 2013 18:02:00 +0200<br>
From: Nikita Danilenko <<a href=3D"mailto:nda at informatik.uni-kiel.de">nd=
a at informatik.uni-kiel.de</a>><br>
Subject: Re: [Haskell-beginners] data declaration using other type's<br>
names?<br>
To: <a href=3D"mailto:beginners at haskell.org">beginners at haskell.org</a><br>
Message-ID: <<a href=3D"mailto:51CC61F8.9020506 at informatik.uni-kiel.de">=
51CC61F8.9020506 at informatik.uni-kiel.de</a>><br>
Content-Type: text/plain; charset=3DISO-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>
> data Bar =3D Bar Int<br>
<br>
or even shorter<br>
<br>
> data A =3D A<br>
<br>
This is particularly useful for single-constructor types ? la<br>
<br>
> data MyType a =3D MyType a<br>
<br>
Clearly, using "Int" or "Float" as constructor names ma=
y seem odd, but<br>
when dealing with a simple grammar it is quite natural to write<br>
<br>
> data Exp =3D Num Int | Add Exp Exp<br>
<br>
although "Num" 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>
> Hey Haskellers,<br>
><br>
> I noticed that ghci lets me do this:<br>
><br>
>> data Foo =3D Int Int | Float<br>
>> :t Int<br>
> Int :: Int -> Foo<br>
>> :t Float<br>
> Float :: Foo<br>
>> :t Int 4<br>
> Int 4 :: Foo<br>
><br>
> It's confusing to have type constructors that use names of existing<br=
>
> types. It's not intuitive that the name "Int" could refer to=
two<br>
> different things, which brings me to:<br>
><br>
>> data Bar =3D Bar Int<br>
>> :t Bar<br>
> Bar :: Int -> Bar<br>
><br>
> Yay? I can have a simple type with one constructor named the same as t=
he type.<br>
><br>
> Why is this allowed? Is it useful somehow?<br>
><br>
> --Patrick<br>
><br>
> _______________________________________________<br>
> Beginners mailing list<br>
> <a href=3D"mailto:Beginners at haskell.org">Beginners at haskell.org</a><br>
> <a href=3D"http://www.haskell.org/mailman/listinfo/beginners" target=
=3D"_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? <<a href=3D"mailto:chaddai.fouche at gmail.com">chadda=
i.fouche at gmail.com</a>><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 <<a=
href=3D"mailto:beginners at haskell.org">beginners at haskell.org</a>><br>
Message-ID:<br>
<<a href=3D"mailto:CANfjZRbGTvoECTMsriNDAUoz=
bow1fUGt-9FRtG-XwRJ%2BDamiAw at mail.gmail.com">CANfjZRbGTvoECTMsriNDAUozbow1f=
UGt-9FRtG-XwRJ+DamiAw at mail.gmail.com</a>><br>
Content-Type: text/plain; charset=3D"utf-8"<br>
<br>
First 2MB isn'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>
> powersOfTen =3D 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'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 "good enou=
gh"<br>
and you could just switch to another project)<br>
--<br>
Jedai<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href=3D"http://www.haskell.org/pipermail/beginners/attachments/=
20130627/f2da75ff/attachment-0001.htm" target=3D"_blank">http://www.haskell=
.org/pipermail/beginners/attachments/20130627/f2da75ff/attachment-0001.htm<=
/a>><br>
<br>
------------------------------<br>
<br>
Message: 5<br>
Date: Thu, 27 Jun 2013 18:28:27 -0500<br>
From: James Jones <<a href=3D"mailto:jejones3141 at gmail.com">jejones3141@=
gmail.com</a>><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 <<a=
href=3D"mailto:beginners at haskell.org">beginners at haskell.org</a>><br>
Message-ID: <<a href=3D"mailto:51CCCA9B.40807 at gmail.com">51CCCA9B.40807@=
gmail.com</a>><br>
Content-Type: text/plain; charset=3DISO-8859-1; format=3Dflowed<br>
<br>
On 06/27/2013 11:23 AM, Chadda? Fouch? wrote:<br>
> First 2MB isn't a lot of RAM nowadays, do you mean 2GB or is that just=
<br>
> compared to the rest of the program ?<br>
<br>
It's a lot compared to the rest of the program... not to mention that<br>
I'm a fossil from the days of 8-bit microprocessors, so 2 MB seems like<br>
a lot of RAM to me. :)<br>
<br>
> Second, your powersOfTen should probably be :<br>
><br>
> > powersOfTen =3D iterate (10*) 1<br>
><br>
> Or maybe even a Vector (if you can guess the maximum value asked of<br=
>
> it) or a MemoTrie (if you can't) since list indexing is slow as hell.<=
br>
> That could help with memoPair which should definitely be a Vector and<=
br>
> not a list.<br>
<br>
Thanks!<br>
><br>
> Good luck (on the other hand, maybe your program is already "good=
<br>
> enough" and you could just switch to another project)<br>
> --<br>
> Jedai<br>
><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'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: "Costello, Roger L." <<a href=3D"mailto:costello at mitre.o=
rg">costello at mitre.org</a>><br>
Subject: [Haskell-beginners] How to Lex, Parse, and Serialize-to-XML<br>
email messages<br>
To: "<a href=3D"mailto:beginners at haskell.org">beginners at haskell.org</a=
>" <<a href=3D"mailto:beginners at haskell.org">beginners at haskell.org<=
/a>><br>
Message-ID:<br>
<<a href=3D"mailto:B5FEE00B53CF054AA8439027E=
8FE17751EFA9005 at IMCMBX04.MITRE.ORG">B5FEE00B53CF054AA8439027E8FE17751EFA900=
5 at IMCMBX04.MITRE.ORG</a>><br>
Content-Type: text/plain; charset=3D"us-ascii"<br>
<br>
Hi Folks,<br>
<br>
I am working toward being able to input any email message and output an equ=
ivalent XML encoding.<br>
<br>
I am starting small, with one of the email headers -- the "From Header=
"<br>
<br>
Here is an example of a From Header:<br>
<br>
From: John Doe <<a href=3D"mailto:john at doe.o=
rg">john at doe.org</a>><br>
<br>
I have successfully transformed it into this XML:<br>
<br>
<From><br>
<Mailbox><br>
<DisplayName>=
John Doe</DisplayName><br>
<Address><a h=
ref=3D"mailto:john at doe.org">john at doe.org</a></Address><br>
</Mailbox><br>
</From><br>
<br>
I used the lexical analyzer "Alex" [1] to break apart (tokenize) =
the From Header.<br>
<br>
I used the parser "Happy" [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=3D"http://stackoverflow.com/questions/17354442/how-to-lex-parse-and=
-serialize-to-xml-email-messages-using-alex-and-happy" target=3D"_blank">ht=
tp://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's Guide may be found at this URL: <a href=3D"http://www.h=
askell.org/alex/doc/html/" target=3D"_blank">
http://www.haskell.org/alex/doc/html/</a><br>
<br>
[2] The Happy User's Guide may be found at this URL: <a href=3D"http://www.=
haskell.org/happy/" target=3D"_blank">
http://www.haskell.org/happy/</a><br>
<br>
<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href=3D"mailto:Beginners at haskell.org">Beginners at haskell.org</a><br>
<a href=3D"http://www.haskell.org/mailman/listinfo/beginners" target=3D"_bl=
ank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br>
<br>
End of Beginners Digest, Vol 60, Issue 38<br>
*****************************************<o:p></o:p></p>
</div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p> </o:p></p>
</div>
</div>
</body>
</html>
--_000_B5FEE00B53CF054AA8439027E8FE17751EFA91FEIMCMBX04MITREOR_--
More information about the Beginners
mailing list