Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Haskell POP3S (Franco)
2. Re: Haskell POP3S (Krzysztof Skrz?tnicki)
3. Re: Warp and Yesod benchmark puzzle (Felipe Almeida Lessa)
4. Re: <- (Patrick Redmond)
5. Re: Warp and Yesod benchmark puzzle (Lorenzo Bolla)
6. Re: Warp and Yesod benchmark puzzle (Felipe Almeida Lessa)
7. Re: Warp and Yesod benchmark puzzle (Felipe Almeida Lessa)
8. Re: <- (Brandon Allbery)
----------------------------------------------------------------------
Message: 1
Date: Sat, 1 Sep 2012 10:57:43 +0000
From: Franco <[email protected]>
Subject: [Haskell-beginners] Haskell POP3S
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII
Hello everyone,
I am trying to write a simple script in Haskell. Such script is meant to:
- contact my email (pop3)
- ask the server wheter there are new messages
- report the result back to me
This was trivial to write, using the "pop3-client" library, but I soon realized
the whole thing is pretty unsecure. User and password are sent in plain text
and I would like to encrypt those.
So I asked Hayoo: it seems there is only one package which supports pop3s,
curlhs; still, I didn't manage to get it. So I am asking you:
- do you know wheter curlhs is fit for my goal? pop3-client had a nice
'getNumberOfMessages' function. I don't see anything similar in there
- do you have examples of querying mail via curl? I found very few of
those
Thanks in advance.
I should mention this thing was meant to be fed to xmobar, to check at
intervals of, say, 15 minutes, wheter I got new mail without having a mail
client always open
-Franco
--
Franco <[email protected]>
------------------------------
Message: 2
Date: Sat, 1 Sep 2012 16:13:53 +0200
From: Krzysztof Skrz?tnicki <[email protected]>
Subject: Re: [Haskell-beginners] Haskell POP3S
To: Franco <[email protected]>
Cc: [email protected]
Message-ID:
<CAM7aEVGpXO+UYrsW342cA5inrnBqzdFCGBMxggF=jf4xedv...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
I don't know about either library, but from what I read about pop3s
protocol it might be feasible to hack on pop3-client library to make it
work with pop3s protocol. This way you would retain the nice API and gain
security.
The other option, i.e. using curlhs, may easier still. I just wanted you to
consider extending the pop3-client library.
Best regards,
Krzysztof Skrz?tnicki
On Sat, Sep 1, 2012 at 12:57 PM, Franco <[email protected]> wrote:
> Hello everyone,
>
> I am trying to write a simple script in Haskell. Such script is meant to:
>
> - contact my email (pop3)
> - ask the server wheter there are new messages
> - report the result back to me
>
> This was trivial to write, using the "pop3-client" library, but I soon
> realized the whole thing is pretty unsecure. User and password are sent in
> plain text and I would like to encrypt those.
>
> So I asked Hayoo: it seems there is only one package which supports pop3s,
> curlhs; still, I didn't manage to get it. So I am asking you:
>
> - do you know wheter curlhs is fit for my goal? pop3-client had a
> nice
> 'getNumberOfMessages' function. I don't see anything similar in
> there
> - do you have examples of querying mail via curl? I found very few
> of those
>
> Thanks in advance.
> I should mention this thing was meant to be fed to xmobar, to check at
> intervals of, say, 15 minutes, wheter I got new mail without having a mail
> client always open
>
> -Franco
>
>
> --
> Franco <[email protected]>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120901/3bf935f0/attachment-0001.htm>
------------------------------
Message: 3
Date: Sat, 1 Sep 2012 11:20:06 -0300
From: Felipe Almeida Lessa <[email protected]>
Subject: Re: [Haskell-beginners] Warp and Yesod benchmark puzzle
To: Krzysztof Skrz?tnicki <[email protected]>
Cc: [email protected], [email protected]
Message-ID:
<CANd=OGEq9Vy0O0B0VWF7dzrTCp6-bqF3xJ6Y2s7+2oC+04V=_...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
On Sat, Sep 1, 2012 at 6:33 AM, Krzysztof Skrz?tnicki <[email protected]> wrote:
> makeSessionBackend calls "getKey" from clientsession:
>
> http://hackage.haskell.org/packages/archive/clientsession/0.8.0/doc/html/src/Web-ClientSession.html#getKey
>
> Looking at that function no wonder it is a bottleneck:
>
> -- | Get a key from the given text file.
> --
> -- If the file does not exist or is corrupted a random key will
> -- be generated and stored in that file.
> getKey :: FilePath -- ^ File name where key is stored.
> -> IO Key -- ^ The actual key.
> getKey keyFile = do
> exists <- doesFileExist keyFile
> if exists
> then S.readFile keyFile >>= either (const newKey) return . initKey
> else newKey
> where
> newKey = do
> (bs, key') <- randomKey
> S.writeFile keyFile bs
> return key'
>
>
> Plenty of syscalls, reading and parsing the same file over and over again.
> Perhaps the default should be to store the key within the foundation
> datatype at startup?
Unfortunately it's not so simple: makeSessionBackend is called just
once by 'toWaiAppPlain', which is in turn called just once when your
application starts.
Cheers, =)
--
Felipe.
------------------------------
Message: 4
Date: Sat, 1 Sep 2012 10:42:15 -0400
From: Patrick Redmond <[email protected]>
Subject: Re: [Haskell-beginners] <-
To: Haskell Beginners <[email protected]>
Message-ID:
<cahuea4f9dgqkwntcjdb3on1kn6p_oxinv+h_hzj6gbumc9r...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
On Thu, Aug 30, 2012 at 11:09 PM, David McBride <[email protected]> wrote:
> It is a syntatic sugar that is expanded to
>
> getLine >>= \x -> putStrLn $ reverse x
>
>>>= is defined in the typeclass for Monad.
Interesting. Does that mean the lines following a "x <- getLine" are
simply balled up into a function? What if there are multiple lines?
main = do
fn <- getLine
ln <- getLine
putStr $ reverse ln
putStr " "
putStr $ reverse fn
> In general, if something is using <- notation, it's type is Monad m => m a,
> where m could be any of many monads, IO, Maybe, [] (lists), Parser or even
> some type of yours that you made an instance of Monad, which you can do if
> you would like to use that syntax.
I thought it might start to get at monads..
On Thu, Aug 30, 2012 at 11:10 PM, Tony Morris <[email protected]> wrote:
> The (<-) symbol is syntax, so doesn't really have a type and probably
> shouldn't be thought of as having one.
>
> It's more like, given the expression that appears to its right of the
> type (m a) implies that the value to its left is of the type a.
And then that implication is realized through the syntactic
transformation which occurs when (<-) is desugared..? I'll keep
reading.
On Thu, Aug 30, 2012 at 11:54 PM, Karl Voelker <[email protected]> wrote:
> There are other things in Haskell which don't have a type. Here's something
> very similar to your example:
>
> foo = let x = 3 in x + x
>
> Does "let x = 3" have a type? Does the "=" in there have a type? (The answer
> is no, and the reasons are basically the same.)
I've taken a pl class in which we learned that "let <name> = <expr1>
in <expr2>" is implemented by expanding to something like "(\<name> ->
<expr2>) <expr1>", so I'm familiar with this, but I appreciate your
making the parallel to (<-). Thanks!
------------------------------
Message: 5
Date: Sat, 1 Sep 2012 15:55:38 +0100
From: Lorenzo Bolla <[email protected]>
Subject: Re: [Haskell-beginners] Warp and Yesod benchmark puzzle
To: Felipe Almeida Lessa <[email protected]>
Cc: [email protected], [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
On Sat, Sep 01, 2012 at 11:20:06AM -0300, Felipe Almeida Lessa wrote:
> On Sat, Sep 1, 2012 at 6:33 AM, Krzysztof Skrz?tnicki <[email protected]>
> wrote:
> > makeSessionBackend calls "getKey" from clientsession:
> >
> > http://hackage.haskell.org/packages/archive/clientsession/0.8.0/doc/html/src/Web-ClientSession.html#getKey
> >
> > Looking at that function no wonder it is a bottleneck:
> >
> > -- | Get a key from the given text file.
> > --
> > -- If the file does not exist or is corrupted a random key will
> > -- be generated and stored in that file.
> > getKey :: FilePath -- ^ File name where key is stored.
> > -> IO Key -- ^ The actual key.
> > getKey keyFile = do
> > exists <- doesFileExist keyFile
> > if exists
> > then S.readFile keyFile >>= either (const newKey) return . initKey
> > else newKey
> > where
> > newKey = do
> > (bs, key') <- randomKey
> > S.writeFile keyFile bs
> > return key'
> >
> >
> > Plenty of syscalls, reading and parsing the same file over and over again.
> > Perhaps the default should be to store the key within the foundation
> > datatype at startup?
>
> Unfortunately it's not so simple: makeSessionBackend is called just
> once by 'toWaiAppPlain', which is in turn called just once when your
> application starts.
>
> Cheers, =)
>
> --
> Felipe.
I wonder if the problem is rather the `decrypt`ion of the _SESSION cookie at
each request, in which case the bottleneck is the encryption library (AES?).
L.
--
Lorenzo Bolla
http://lbolla.info
------------------------------
Message: 6
Date: Sat, 1 Sep 2012 12:01:10 -0300
From: Felipe Almeida Lessa <[email protected]>
Subject: Re: [Haskell-beginners] Warp and Yesod benchmark puzzle
To: Lorenzo Bolla <[email protected]>
Cc: [email protected], [email protected]
Message-ID:
<CANd=OGE=gtbg0wu3nb7s6hrnuxwejf2nrbw0off_4caieaj...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
On Sat, Sep 1, 2012 at 11:55 AM, Lorenzo Bolla <[email protected]> wrote:
> I wonder if the problem is rather the `decrypt`ion of the _SESSION cookie at
> each request, in which case the bottleneck is the encryption library (AES?).
I'm trying to test right now what happens to the performance when I
change (pseudo-code)
save = encrypt . encode
load = decode . decrypt
to just
save = encode
load = decode
The clientsession library does not encode or decode the data and it's
pretty fast. Maybe not fast enough, though =).
Cheers,
--
Felipe.
------------------------------
Message: 7
Date: Sat, 1 Sep 2012 12:48:34 -0300
From: Felipe Almeida Lessa <[email protected]>
Subject: Re: [Haskell-beginners] Warp and Yesod benchmark puzzle
To: Lorenzo Bolla <[email protected]>
Cc: [email protected], [email protected]
Message-ID:
<CANd=oghz5b6u0+kbab9abrft7cjmxhjowjtgeivc19wpfox...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
Just in case someone is following along this thread just on the
mailing list, I've done some analysis on the GitHub issue
(https://github.com/yesodweb/yesod/issues/415). Since it's easier to
have an archive of the discussion there, I'd like to welcome anyone to
bring your comments to GitHub =).
Cheers,
--
Felipe.
------------------------------
Message: 8
Date: Sat, 1 Sep 2012 12:06:14 -0400
From: Brandon Allbery <[email protected]>
Subject: Re: [Haskell-beginners] <-
To: Patrick Redmond <[email protected]>
Cc: Haskell Beginners <[email protected]>
Message-ID:
<CAKFCL4WA1WpFPtYszQm=1voykzdc2zbvobe5t7n78drkcdi...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Sat, Sep 1, 2012 at 10:42 AM, Patrick Redmond <[email protected]>wrote:
> Interesting. Does that mean the lines following a "x <- getLine" are
> simply balled up into a function? What if there are multiple lines?
>
I'll insert the translation:
> main = do main =
> fn <- getLine getLine >>= \fn ->
> ln <- getLine getLine >>= \ln ->
> putStr $ reverse ln putStr (reverse ln) >>
> putStr " " putStr " " >>
> putStr $ reverse fn putStr (reverse fn)
Which is just a single large expression. "do" syntax is not magic, nor is
it some fundamentally different language. It's just a convenient way to
write a certain repetitious pattern.
--
brandon s allbery [email protected]
wandering unix systems administrator (available) (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120901/457438f9/attachment.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 51, Issue 2
****************************************