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&quot;,&quot;sans-serif&quot;;color:#1F497D"><span style=3D"mso-=
list:Ignore">-<span style=3D"font:7.0pt &quot;Times New Roman&quot;">&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]><span style=3D"font-size:11.0pt;font-family:=
&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">I wonder if I can=
 use Happy to generate individual parsers &#8211; a parser for the From Hea=
der, a parser for the To Header, a parser for the Subject Header
 &#8211; 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:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;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:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D">/Roger<o:p></o:p></span><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span><=
/p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><b><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</spa=
n></b><span style=3D"font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;=
sans-serif&quot;"> 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>&nbsp;</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>&nbsp;</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 &nbsp;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>&nbsp;</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 &lt;?&gt; &quot;tag&quot;<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p>&nbsp;</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">&nbsp; char '&lt;'<o:p></=
o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; name &lt;- parseTa=
g<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; char '&gt;'<o:p></=
o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; content &lt;- many=
 (try parseElem)<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; string &quot;&lt;/=
&quot;<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; parseTag<o:p></o:p=
></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; char '&gt;'<o:p></=
o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; return (name, cont=
ent)<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; &lt;?&gt; &quot;ta=
gged form&quot;<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p>&nbsp;</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>&nbsp;</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>&nbsp;</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">&nbsp; string &quot;From:=
 &quot;<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; mailboxes =3D many=
 (try parseMailbox)<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; return mailboxes<o=
:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p>&nbsp;</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">&nbsp; parseComments<o:p>=
</o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; -- Names are optio=
nal<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; parseComments<o:p>=
</o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; name &lt;- try par=
seDisplayName<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; parseComments&nbsp=
;<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; address &lt;- pars=
eEmailAddress<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; parseComments<o:p>=
</o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; try char ','<o:p><=
/o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; return Mailbox nam=
e address<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; &lt;?&gt; &quot;Pa=
rse an indidivuals mailbox&quot;<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p>&nbsp;</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">&nbsp; try char '&lt;'<o:=
p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; handle &lt;- many1=
 (noneof &quot;@&quot;) -- Or whatever is valid here<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; char '@'<o:p></o:p=
></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; domain &lt;- parse=
Domain<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; try char '&lt;'<o:=
p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; return handle&#43;=
&#43;@&#43;&#43;domain<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p>&nbsp;</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&nbsp;<o:p=
></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; (char '[' &gt;&gt;=
 parseDomain &gt;&gt;=3D (\domainName -&gt; do char ']'<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; &nbsp; return doma=
inName))<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&lt;|&gt; parseWebsiteNam=
e &gt;&gt;=3D return<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p>&nbsp;</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>&nbsp;</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>&nbsp;</o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<o:p></o:p></p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">&nbsp;&nbsp;<o:p></o:p></=
p>
</div>
<div>
<p class=3D"MsoNormal" style=3D"margin-left:.5in"><o:p>&nbsp;</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>&gt; wrote:<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"margin-left:.5in">Send Beginners mailing li=
st submissions to<br>
&nbsp; &nbsp; &nbsp; &nbsp; <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>
&nbsp; &nbsp; &nbsp; &nbsp; <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>
&nbsp; &nbsp; &nbsp; &nbsp; <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>
&nbsp; &nbsp; &nbsp; &nbsp; <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 &quot;Re: Contents of Beginners digest...&quot;<br>
<br>
<br>
Today's Topics:<br>
<br>
&nbsp; &nbsp;1. &nbsp;data declaration using other type's names? (Patrick R=
edmond)<br>
&nbsp; &nbsp;2. Re: &nbsp;data declaration using other type's names? (Brand=
on Allbery)<br>
&nbsp; &nbsp;3. Re: &nbsp;data declaration using other type's names? (Nikit=
a Danilenko)<br>
&nbsp; &nbsp;4. Re: &nbsp;what to do about excess memory usage (Chadda? Fou=
ch?)<br>
&nbsp; &nbsp;5. Re: &nbsp;what to do about excess memory usage (James Jones=
)<br>
&nbsp; &nbsp;6. &nbsp;How to Lex, Parse, &nbsp; &nbsp; &nbsp; and Serialize=
-to-XML email messages<br>
&nbsp; &nbsp; &nbsp; (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=3D"mailto:plredmond at gmail.com">plredmond@=
gmail.com</a>&gt;<br>
Subject: [Haskell-beginners] data declaration using other type's<br>
&nbsp; &nbsp; &nbsp; &nbsp; names?<br>
To: <a href=3D"mailto:beginners at haskell.org">beginners at haskell.org</a><br>
Message-ID:<br>
&nbsp; &nbsp; &nbsp; &nbsp; &lt;CAHUea4FfBP8L1kU&#43;tS1-2cVPvAB4h22j35JcNw=
RC-jGds0=3D<a href=3D"mailto:v6g at mail.gmail.com">v6g at mail.gmail.com</a>&gt;=
<br>
Content-Type: text/plain; charset=3DUTF-8<br>
<br>
Hey Haskellers,<br>
<br>
I noticed that ghci lets me do this:<br>
<br>
&gt; data Foo =3D 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's confusing to have type constructors that use names of existing<br>
types. It'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 =3D 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 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 &lt;<a href=3D"mailto:allbery.b at gmail.com">allbery.b@=
gmail.com</a>&gt;<br>
Subject: Re: [Haskell-beginners] data declaration using other type's<br>
&nbsp; &nbsp; &nbsp; &nbsp; names?<br>
To: The Haskell-Beginners Mailing List - Discussion of primarily<br>
&nbsp; &nbsp; &nbsp; &nbsp; beginner-level topics related to Haskell &lt;<a=
 href=3D"mailto:beginners at haskell.org">beginners at haskell.org</a>&gt;<br>
Message-ID:<br>
&nbsp; &nbsp; &nbsp; &nbsp; &lt;<a href=3D"mailto:CAKFCL4U-E4B_%2Bcts0vpNX8=
Ar9wccQDjgzWOYHLXLsLAv%2BQn_cg at mail.gmail.com">CAKFCL4U-E4B_&#43;cts0vpNX8A=
r9wccQDjgzWOYHLXLsLAv&#43;Qn_cg at mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=3D&quot;utf-8&quot;<br>
<br>
On Thu, Jun 27, 2013 at 11:24 AM, Patrick Redmond &lt;<a href=3D"mailto:plr=
edmond at gmail.com">plredmond at gmail.com</a>&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 t=
he<br>
&gt; type.<br>
&gt; Why is this allowed? Is it useful somehow?<br>
&gt;<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 &quot;there is no good reason to *prev=
ent*<br>
it from happening, from a language standpoint&quot;.<br>
<br>
--<br>
brandon s allbery kf8nh &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sine nomine associate=
s<br>
<a href=3D"mailto:allbery.b at gmail.com">allbery.b at gmail.com</a> &nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp;<a href=3D"mailto:ballbery at sinenomine.net">b=
allbery at sinenomine.net</a><br>
unix, openafs, kerberos, infrastructure, xmonad &nbsp; &nbsp; &nbsp; &nbsp;=
<a href=3D"http://sinenomine.net" target=3D"_blank">http://sinenomine.net</=
a><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: &lt;<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>&gt;<br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Thu, 27 Jun 2013 18:02:00 &#43;0200<br>
From: Nikita Danilenko &lt;<a href=3D"mailto:nda at informatik.uni-kiel.de">nd=
a at informatik.uni-kiel.de</a>&gt;<br>
Subject: Re: [Haskell-beginners] data declaration using other type's<br>
&nbsp; &nbsp; &nbsp; &nbsp; names?<br>
To: <a href=3D"mailto:beginners at haskell.org">beginners at haskell.org</a><br>
Message-ID: &lt;<a href=3D"mailto:51CC61F8.9020506 at informatik.uni-kiel.de">=
51CC61F8.9020506 at informatik.uni-kiel.de</a>&gt;<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>
&gt; data Bar =3D Bar Int<br>
<br>
or even shorter<br>
<br>
&gt; data A =3D A<br>
<br>
This is particularly useful for single-constructor types ? la<br>
<br>
&gt; data MyType a =3D MyType a<br>
<br>
Clearly, using &quot;Int&quot; or &quot;Float&quot; as constructor names ma=
y seem odd, but<br>
when dealing with a simple grammar it is quite natural to write<br>
<br>
&gt; data Exp =3D 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 =3D 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's confusing to have type constructors that use names of existing<br=
>
&gt; types. It'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 =3D 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 t=
he 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=3D"mailto:Beginners at haskell.org">Beginners at haskell.org</a><br>
&gt; <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 &#43;0200<br>
From: Chadda? Fouch? &lt;<a href=3D"mailto:chaddai.fouche at gmail.com">chadda=
i.fouche at gmail.com</a>&gt;<br>
Subject: Re: [Haskell-beginners] what to do about excess memory usage<br>
To: The Haskell-Beginners Mailing List - Discussion of primarily<br>
&nbsp; &nbsp; &nbsp; &nbsp; beginner-level topics related to Haskell &lt;<a=
 href=3D"mailto:beginners at haskell.org">beginners at haskell.org</a>&gt;<br>
Message-ID:<br>
&nbsp; &nbsp; &nbsp; &nbsp; &lt;<a href=3D"mailto:CANfjZRbGTvoECTMsriNDAUoz=
bow1fUGt-9FRtG-XwRJ%2BDamiAw at mail.gmail.com">CANfjZRbGTvoECTMsriNDAUozbow1f=
UGt-9FRtG-XwRJ&#43;DamiAw at mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=3D&quot;utf-8&quot;<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>
&gt; 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 &quot;good enou=
gh&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=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>&gt;<br>
<br>
------------------------------<br>
<br>
Message: 5<br>
Date: Thu, 27 Jun 2013 18:28:27 -0500<br>
From: James Jones &lt;<a href=3D"mailto:jejones3141 at gmail.com">jejones3141@=
gmail.com</a>&gt;<br>
Subject: Re: [Haskell-beginners] what to do about excess memory usage<br>
To: The Haskell-Beginners Mailing List - Discussion of primarily<br>
&nbsp; &nbsp; &nbsp; &nbsp; beginner-level topics related to Haskell &lt;<a=
 href=3D"mailto:beginners at haskell.org">beginners at haskell.org</a>&gt;<br>
Message-ID: &lt;<a href=3D"mailto:51CCCA9B.40807 at gmail.com">51CCCA9B.40807@=
gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=3DISO-8859-1; format=3Dflowed<br>
<br>
On 06/27/2013 11:23 AM, Chadda? Fouch? wrote:<br>
&gt; First 2MB isn'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'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>
&gt; Second, your powersOfTen should probably be :<br>
&gt;<br>
&gt; &gt; powersOfTen =3D 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'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 &#43; 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 &#43;0000<br>
From: &quot;Costello, Roger L.&quot; &lt;<a href=3D"mailto:costello at mitre.o=
rg">costello at mitre.org</a>&gt;<br>
Subject: [Haskell-beginners] How to Lex, Parse, and Serialize-to-XML<br>
&nbsp; &nbsp; &nbsp; &nbsp; email messages<br>
To: &quot;<a href=3D"mailto:beginners at haskell.org">beginners at haskell.org</a=
>&quot; &lt;<a href=3D"mailto:beginners at haskell.org">beginners at haskell.org<=
/a>&gt;<br>
Message-ID:<br>
&nbsp; &nbsp; &nbsp; &nbsp; &lt;<a href=3D"mailto:B5FEE00B53CF054AA8439027E=
8FE17751EFA9005 at IMCMBX04.MITRE.ORG">B5FEE00B53CF054AA8439027E8FE17751EFA900=
5 at IMCMBX04.MITRE.ORG</a>&gt;<br>
Content-Type: text/plain; charset=3D&quot;us-ascii&quot;<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 &quot;From Header=
&quot;<br>
<br>
Here is an example of a From Header:<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; From: John Doe &lt;<a href=3D"mailto:john at doe.o=
rg">john at doe.org</a>&gt;<br>
<br>
I have successfully transformed it into this XML:<br>
<br>
&nbsp; &nbsp; &nbsp; &nbsp; &lt;From&gt;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Mailbox&gt;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;DisplayName&gt;=
John Doe&lt;/DisplayName&gt;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Address&gt;<a h=
ref=3D"mailto:john at doe.org">john at doe.org</a>&lt;/Address&gt;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/Mailbox&gt;<br>
&nbsp; &nbsp; &nbsp; &nbsp; &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=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>&nbsp;</o:p></p>
</div>
</div>
</body>
</html>

--_000_B5FEE00B53CF054AA8439027E8FE17751EFA91FEIMCMBX04MITREOR_--



More information about the Beginners mailing list