Re: [Haskell-cafe] "too many open files" using snap

2012-01-08 Thread Eric Wong
Forget to mention it, I am using HTTPS to serve all the APIs. And int the 
error.log file, I got lots of ConnectionAbruptlyTerminated exceptions, which I 
think is defined in OpenSSL.

在 2012-1-9,下午2:48, Gregory Collins 写道:

> 2012/1/9 Eric Wong 
> Yes, I know it's not related to the static files now. But do I have to close 
> socket in snap monad? Shouldn't it be closed by snap-server? 
> 
> Without knowing what your code looks like one way or the other, it's hard to 
> tell. Snap does close the sockets it opens, of course.
> 
> G
> -- 
> Gregory Collins 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] "too many open files" using snap

2012-01-08 Thread Gregory Collins
2012/1/9 Eric Wong 

> Yes, I know it's not related to the static files now. But do I have to
> close socket in snap monad? Shouldn't it be closed by snap-server?
>

Without knowing what your code looks like one way or the other, it's hard
to tell. Snap does close the sockets it opens, of course.

G
-- 
Gregory Collins 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] "too many open files" using snap

2012-01-08 Thread Eric Wong
Yes, I know it's not related to the static files now. But do I have to close 
socket in snap monad? Shouldn't it be closed by snap-server? 

在 2012-1-9,下午2:29, Gregory Collins 写道:

> 2012/1/9 Eric Wong 
> I run both of these commands and found out that there're sockets leaking.
> Most of them are TCP connections in CLOSE_WAIT state. There're also some 
> socket with "can't identify protocol".
> 
> So, What's the problem? Is it related to the timeout in the server config? 
> I'm using the default value.
> 
> CLOSE_WAIT indicates that the other side has closed its side of the 
> connection and the OS is waiting for you to close() the socket. At this point 
> I'd start looking at your database layer.
> 
> G
> -- 
> Gregory Collins 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] "too many open files" using snap

2012-01-08 Thread Gregory Collins
2012/1/9 Eric Wong 

> I run both of these commands and found out that there're sockets leaking.
> Most of them are TCP connections in CLOSE_WAIT state. There're also some
> socket with "can't identify protocol".
>
> So, What's the problem? Is it related to the timeout in the server config?
> I'm using the default value.
>

CLOSE_WAIT indicates that the other side has closed its side of the
connection and the OS is waiting for you to close() the socket. At this
point I'd start looking at your database layer.

G
-- 
Gregory Collins 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] How to use IndentParser. Any example/tutorial?

2012-01-08 Thread Sukit Tretriluxana
Hi,

I need to construct a parser that parse a language that use indentation to
define blocks as Python does. I ran into
Text.ParserCombinators.Parsec.IndentParser module but have no idea how to
use it. Can anyone point me out to how to use this module? Any short
example, tutorial, or whatever would be highly appreciated.

Thanks,
Ed
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] numeric coercion in ghci vs hugs

2012-01-08 Thread Doug McIlroy
After loading the one-line file
default (Integer,Rational,Double)
the input
1::Fractional t => t
in ghci yields the output
1.0
and in hugs
1%1
The ghci answer appears not to respect the default
declaration.  What's going on?

Doug McIlroy

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] "too many open files" using snap

2012-01-08 Thread Antoine Latter
2012/1/8 Eric Wong :
> I run both of these commands and found out that there're sockets leaking.
> Most of them are TCP connections in CLOSE_WAIT state. There're also some
> socket with "can't identify protocol".
>
> So, What's the problem? Is it related to the timeout in the server config?
> I'm using the default value.
>
>

Since they're sockets, it could be either the database connections or
the HTTP connections, right? Is there some way you can insert a fake
database layer to see if that makes your problem go away, to try and
isolate the problem?

Antoine

> 在 2012-1-8,下午10:56, Brandon Allbery 写道:
>
> On Sun, Jan 8, 2012 at 09:50, Felipe Almeida Lessa 
> wrote:
>>
>> If you're on Linux, then you may
>>
>>  $ ls -lah /proc/PID/fd
>>
>> to see where these open files are pointing to.
>
>
> And on other systems lsof can determine this information.
>
>     $ lsof -p PID
>
> --
> brandon s allbery                                      allber...@gmail.com
> wandering unix systems administrator (available)     (412) 475-9364 vm/sms
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] "too many open files" using snap

2012-01-08 Thread Eric Wong
I run both of these commands and found out that there're sockets leaking.
Most of them are TCP connections in CLOSE_WAIT state. There're also some socket 
with "can't identify protocol".

So, What's the problem? Is it related to the timeout in the server config? I'm 
using the default value.


在 2012-1-8,下午10:56, Brandon Allbery 写道:

> On Sun, Jan 8, 2012 at 09:50, Felipe Almeida Lessa  
> wrote:
> If you're on Linux, then you may
> 
>  $ ls -lah /proc/PID/fd
> 
> to see where these open files are pointing to.
> 
> And on other systems lsof can determine this information.
> 
> $ lsof -p PID 
> 
> -- 
> brandon s allbery  allber...@gmail.com
> wandering unix systems administrator (available) (412) 475-9364 vm/sms
> 
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: wxHaskell 0.13.2

2012-01-08 Thread Jeremy O'Donoghue
On 5 January 2012 17:44, Jeremy O'Donoghue wrote:
>
>
> The source repository at code.haskell.org has not yet been updated with
> the patches. This will happen in the next day or so.
>
>

The source repository at code.haskell.org has now been updated with
wxHaskell 0.13.2 plus the two patches (add IOExtra to wxdirect and remove
old-time from wxcore) from Shelarcy.

I suggest a period of one more week (i.e. until 15th Jan 2012) for any
further issues or fixes on the 0.13.2 series. After that, Dave, Eric and
others will start to upload the changes needed to support wxWidgets 2.9.x.

These changes will not work against wxWidgets 2.8.x installations, and are
pretty significant in places. Please expect the main repo to unstable for a
while after next Sunday.

Best regards
Jeremy
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Simple type-class experiment turns out not so simple...

2012-01-08 Thread Brandon Allbery
On Sun, Jan 8, 2012 at 15:55, Christoph Breitkopf <
chbreitk...@googlemail.com> wrote:

> On Sun, Jan 8, 2012 at 9:25 PM, Brent Yorgey wrote:
>
>> On Fri, Jan 06, 2012 at 10:51:58AM +, Steve Horne wrote:
>> > If I specify both extensions (-XMultiParamTypeClasses and
>> > -XFlexibleInstances) it seems to work, but needing two language
>> > extensions is a pretty strong hint that I'm doing it the wrong way.
>>
>> Not necessarily.  These two extensions in particular (and especially
>> the second) are quite uncontroversial.
>>
>
>
> http://hackage.haskell.org/trac/haskell-prime/wiki/MultiParamTypeClassesDilemma
>
> does not sound "uncontroversial" to me. That's why I avoided them so far.
>

MPTCs are not controversial.  They're also of limited (but extant)
usefulness without an additional extension; and, while there is
"controversy" there, it's not especially relevant until type families are
stabilized.  They could in theory go into the standard *now*; they'd just
be of limited use until functional dependencies vs. type families is
settled.  (Also, de facto I think it's already more or less been decided in
favor of type families, just because functional dependencies are (a) a bit
alien [being a glob of Prolog-style logic language imported into the middle
of System Fc] and (b) [as I understand it] difficult to verify that the
code in the compiler is handling all the potential corner cases right
[mainly because of (a)].

In any case, if the code in question doesn't happen to need either
functional dependencies or type classes, the controversy doesn't touch it.

-- 
brandon s allbery  allber...@gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] cabal and conditional build-depends

2012-01-08 Thread Tristan Ravitch
Hi Cafe,

I have a package that depends on several other Haskell libraries.  One
of these libraries depends on some native libraries (and associated
headers) to build.  I would like to make this dependency optional in
my package if the libraries don't exist.

To do this, I tried to switch my build-type from Simple to Configure
in my .cabal file.  Then I made a configure script that generates a
.buildinfo file as suggested in the cabal guide.

The buildinfo file is generated and looks as I would expect.  If the
library is found on the system, it has a "build-info: ..." line.
Unfortunately, when Cabal processes it, it says:

  Warning: archive-inspection.buildinfo: Unknown fields: build-depends (line 2)
Fields allowed in this section:
buildable, build-tools, cpp-options, cc-options, ld-options,
pkgconfig-depends, frameworks, c-sources, default-language,
other-languages, default-extensions, other-extensions, extensions,
extra-libraries, extra-lib-dirs, includes, install-includes,
include-dirs, hs-source-dirs, other-modules, ghc-prof-options,
ghc-shared-options, ghc-options, hugs-options, nhc98-options,
jhc-options


It really doesn't seem to like conditional build-depends entries.  Is
this expected behavior?  And is there a better way to go about having
conditional build-time dependencies on Haskell libraries using Cabal?


I guess I could start playing with a custom Setup.hs, but I always
hate doing that unless absolutely necessary.

Thanks


pgpNpgVCNacaI.pgp
Description: PGP signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Simple type-class experiment turns out not so simple...

2012-01-08 Thread Christoph Breitkopf
On Sun, Jan 8, 2012 at 9:25 PM, Brent Yorgey  wrote:

> On Fri, Jan 06, 2012 at 10:51:58AM +, Steve Horne wrote:
> >
> > If I specify both extensions (-XMultiParamTypeClasses and
> > -XFlexibleInstances) it seems to work, but needing two language
> > extensions is a pretty strong hint that I'm doing it the wrong way.
>
> Not necessarily.  These two extensions in particular (and especially
> the second) are quite uncontroversial.
>

I really don't know much about the subject, but

http://hackage.haskell.org/trac/haskell-prime/wiki/MultiParamTypeClassesDilemma

does not sound "uncontroversial" to me. That's why I avoided them so far.

- Chris
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Simple type-class experiment turns out not so simple...

2012-01-08 Thread Brent Yorgey
On Fri, Jan 06, 2012 at 10:51:58AM +, Steve Horne wrote:
> 
> If I specify both extensions (-XMultiParamTypeClasses and
> -XFlexibleInstances) it seems to work, but needing two language
> extensions is a pretty strong hint that I'm doing it the wrong way.

Not necessarily.  These two extensions in particular (and especially
the second) are quite uncontroversial.

-Brent

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Questions on the Haskell 2010 report

2012-01-08 Thread Silvio Frischknecht
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Thanks for the response

> Pardon?  As I read the spec you quoted, the former agrees with it 
> and the latter does not.   How do you get the (illegal) latter?

Oh, yes your right. I must have mixed up something.

> If you don't name a module, the module is imputed to be Main and 
> the symbol main is exported from it.  See the final paragraph of 
> Section 5.1.

Didn't see that

I also think I figured out number why there should be an error in
number 3. Though I still thinks it's a very roundabout way of saying it

Silvio
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJPCeimAAoJEDLsP+zrbatWtvQQALa58yEivnJ2BSvwZpAgDGKx
SstxyoE2a4dxv+4bVfu2ngJzdtSGjP0Xf0vY7jTL4VO2aDO/uBbHW4wR/tzitEhI
vsES1PBrHZHPO+pctVNqaKn9O738tDktF2KU7wu789epTafvkQKeNbmlloZfMrkB
W0IlWHsWW3BaqdmBXb8M7nGaBUPyX1iLH3lXU5M5BQnWndv/99A0k+fuoj//TvwI
w6N2ct6mI12ohVbBi8xmSANvel5ZePRi4mj3GfnGtFuETRqxqRd/IQNb0VjgTx1k
UlpbHA7GDV2OtRavMu0BlfRdYwQJ/eIinFhd3mT1ICZ3mBtbTsZC5JBQi1x4EbFJ
/jgFU4DWdskIT3RXjiKXAQxDRRwtvFhqDVA3OxZeKBZAMAVUCvcAGwWpGNMD27/3
OkUptukFkHil6KGUbY3K6IwkGKMK5aBuHOl2ZxCHjZo3rnskfQz8CIk34Dxv/mOG
idhZhT/EGv3nkKH0ny1zUEgkFHmkJRS9ytp36ubi1cC4ptTPOkUt6cIeFEhCMmCH
bcWIZez1c7xvkTygbQAF6kj8V4vwgxwmYxjga5/kn4toRRmuD6anY/DZd5JJ4/2E
RgI24R7hJlBmZLoNpNBOlyhMoDWfE5baECZH2IGiJq+mREskIBVui64LsL5xqJCP
gvR1od0nzAkZkHNoowew
=Egb5
-END PGP SIGNATURE-

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Questions on the Haskell 2010 report

2012-01-08 Thread Brandon Allbery
On Sun, Jan 8, 2012 at 12:53, Silvio Frischknecht
wrote:

>module  →   module modid [exports] where body
>|   body
>body→   { impdecls ; topdecls }
>|   { impdecls }
>|   { topdecls }
>
> You can't see it in this mail because there is no font but
> the curly braces { } are meant to match the tokens { } and are not
> meant as repetition. However, as I understand it, the layout parser
> would modify this code:
>
>module Foo where
>import Bar
>baz=baz
>
> to this code (which doesn't match):
>
>module Foo where { import Bar ; baz=baz }
>
> and not to this code (which would be required to match):
>
>module Foo where { { import Bar } ; { baz=baz } }
>

Pardon?  As I read the spec you quoted, the former agrees with it and the
latter does not.   How do you get the (illegal) latter?

2)
> In the same section what is it supposed to mean if "module" consists
> of only a "body" and not "module modid [exports] where body".
>

If you don't name a module, the module is imputed to be Main and the symbol
main is exported from it.  See the final paragraph of Section 5.1.

-- 
brandon s allbery  allber...@gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Questions on the Haskell 2010 report

2012-01-08 Thread Silvio Frischknecht
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I am trying to write a haskell compiler and i have stumbled upon 2
issues that i don't understand in the Haskell report 2010. Btw. these
issues are also present in the 98 report.

1)
first is this in section 5.1 Module Structure [1]. A module is defined
like this.

module  →   module modid [exports] where body
|   body
body→   { impdecls ; topdecls }
|   { impdecls }
|   { topdecls }

You can't see it in this mail because there is no font but
the curly braces { } are meant to match the tokens { } and are not
meant as repetition. However, as I understand it, the layout parser
would modify this code:

module Foo where
import Bar
baz=baz

to this code (which doesn't match):

module Foo where { import Bar ; baz=baz }

and not to this code (which would be required to match):

module Foo where { { import Bar } ; { baz=baz } }

So as i see the definition should state this instead:

module  →   module modid [exports] where body
|   body
body→   { impdecls ; topdecls }
|   impdecls
|   topdecls

2)
In the same section what is it supposed to mean if "module" consists
of only a "body" and not "module modid [exports] where body".

3)
In section 10.3 Layout [2] it is written.

If a let, where, do, or of keyword is not followed by the lexeme {,
the token {n} is inserted after the keyword, where n is the
indentation of the next lexeme if there is one, or 0 if the end of
file has been reached.

Together with this rule

L [] (m : ms) = }  :  L [] ms if m≠0 (Note 6)

This results in an error if the program ends in a "where", ...
Wouldn't it make more sense to put a {1} in case of EOF or just insert
the tokens '{' and '}'. On the other hand if you really won't accept
that why not simply say that it is an error.

btw. GHC doesn't give an error.

[1]
http://www.haskell.org/onlinereport/haskell2010/haskellch5.html#x11-990005.1
[2]
http://www.haskell.org/onlinereport/haskell2010/haskellch10.html#x17-17800010.3
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJPCdgeAAoJEDLsP+zrbatWIjgP/RLISOIz6xZRDso/mVn+xbwh
eMPdeqmzJJYpVm+sDdjmoEIAsrwXtYKc9r8LrlUOugbtXFhYYPcSox7Te4DO+Cm+
X+b8b80UQu1nKNoUofDqAXSQb/n7f5zgmaIoF2uvFieuJTE709oZCmBdTgupVdyJ
D16VqmKmqpskNepnQuh9rV7vwSPs4PjnsUQDpxjXDvh0tSdp9byBZPcMwEgQb172
FJAAryCuKFBE8FRG+ANlSw2h8fH7rkMLmkjabje5NKtLa2UMKvBlXYa2p0EZwcd2
/bj/2GTksWdsDmqFp3lQJgPk2uxp5reosTiTk5JQz56GcPOTK3wmL62qDeH3+tdS
pX5ZD8HeX8RdkLjuFi0fjiJq3L4HEy+OqHbLWoStPPqfY9clueSUJ0g0Dfc4OukU
0naJlASxKr4ovHBiTinrLI6bTTeeMj9QCDGh5hU0x1hJ5f80iQQaKYpI8cq1DxQv
CICBFibFnbJ0Zfzfuk0ZJZ8Db1dJUdEGSYZo/QCtpxXwTyKr4zEU6FYHprScRRX8
H6ZDnVE6ZbzDbaUqeQVBXvUGHF+2vTmDo1EZ80BFhDVHjifvV9eHslbF0XD+NjYY
iRPsgDzACYsMxvYaBsRlXWwmwWD+EfNerdHZL6h9dBZICwSr0pu4SCp616BR2BpK
IuO4MG/B5vAoCs9cb0lG
=O6Wd
-END PGP SIGNATURE-

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [web-devel] [ANNOUNCE] First release of crypto-conduit

2012-01-08 Thread Thomas DuBuisson
Aristid Breitkreuz  wrote:
> To use the hash, I have to convert it to a ByteString, and then I
> suddenly have lost all this safety. I don't really see how there is
> any real safety gained.

But that isn't true for all users.  Sometimes a hash is computed long
before it is transmitted, so while you're passing it around you can be
sure it won't be confused with other raw data (basically, what Vincent
said).  Also, some users never want to convert to a bytestring - using
the Eq and Ord instances are enough.

> That said, just exposing a direct method of getting to that ByteString
> without cereal (as Thomas proposed) would be an improvement.

I'll do this and release crypto-api 0.9 soonish.

Cheers,
Thomas

>
>
>
> Aristid
>
>
> 2012/1/8 Vincent Hanquez :
>> On 01/08/2012 04:12 AM, Aristid Breitkreuz wrote:
>>>
>>> Why? I don't actually need the hash object for anything, usually. All
>>> I need is the ByteString, and then I need to learn how to use the
>>> cereal package to get it...
>>
>> The whole rationale i believe, is having meaningful types associated to your
>> values so that the type checker can do its job. i.e. you don't start mixing
>> a hash (in binary form) and a random piece of file.
>>
>> My only problem with the Serialize instance, is that dependencies (cereal in
>> this case) trickle through to the user of the API, which would be solved by
>> Thomas' suggestion.
>>
>> --
>> Vincent
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] RoseTree + Data.Typeable.Zipper

2012-01-08 Thread Sergey Mironov
2012/1/8 Sergey Mironov 

> Hi list!
> Could you please give me a quick example of navigating throw
> Data.Typeable.Zipper built on top of a Rose Tree?
> eg. (See ??? in the last line - is my question)
>
> {-#LANGUAGE TemplateHaskell, DeriveDataTypeable, TypeOperators #-}
>
> import Data.Typeable.Zipper
>
> data Tree k a = Tree {
> _rules :: [(k,Tree k a)]
> } deriving(Show, Typeable)
>
> $(mkLabelsNoTypes [''Tree])
>
> atree = Tree [(1, Tree []), (2, Tree []), (3, Tree [(11, Tree [])])]
>
> moveToLeftmostChild :: (Typeable k, Typeable a) =>
> Zipper1 (Tree k a) -> Zipper1 (Tree k a)
> moveToLeftmostChild z = moveTo ??? z
>
> Thanks,
> Sergey
>

Heh, look like I've found the solution by myself! Here is the missing part:

get_child n t = ((_rules t) !! n) -- fast'n'diry
set_child n c t = t{ _rules = (hs ++ (c:ts)) } where
(hs,ts) = splitAt n (_rules t)

focus_child :: Int -> Tree k a :-> (k, Tree k a)
focus_child n = lens (get_child n) (set_child n)

moveToLeftmostChild :: (Ord k, Typeable k, Typeable a)
=> Zipper (Tree k a) (Tree k a) -> Zipper (Tree k a) (k, Tree k a)
moveToLeftmostChild z = moveTo (focus_child 0) z

Thanks,
Sergey
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] All the random packages

2012-01-08 Thread Aleksey Khudyakov

On 08.01.2012 11:18, Eugene Kirpichov wrote:

Hi,

I came across the beautiful algorithm for O(1) generation of rational
discrete distributions http://www.keithschwarz.com/darts-dice-coins/ and
though it'd be fun to implement it in Haskell and put on Hackage, but
then it turned out that there's about a dozen random number packages, so
I'm not sure to which one to contribute, or better to roll out my own
package and encourage authors of the other packages to reference it and
fit under their interface.

I think it was first described in the paper "Fast generation of discrete 
random variables" by Marsaglia et.al.[1] It's called squared histogram 
method in the paper. Another one is quite elegand as well. They claim 
claim that these algorithms are fastest.


Also I would avoid floating point numbers for following reasons. They 
are tricky and difficult to reason about. Random numbers are generated 
as words and conversion to float/double will inevitable lose some entropy.




Which random number packages are considered to be most mature or perhaps
promising - i.e., contributing to which ones will bring the community
the most benefit?


Difficult to say. Reverse dependencies[2] could be of interest.



Is there any effort on unifying them going on?


I'm not aware about such thing,

[1] http://ideas.repec.org/a/jss/jstsof/11i03.html
[2] http://packdeps.haskellers.com/reverse

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] "too many open files" using snap

2012-01-08 Thread Eric Wong
This is very helpful, I found currently almost all of the open files are 
sockets. But it don't have that much traffic. So it seems it's leaking socket 
file descriptors. 

在 2012-1-8,下午10:50, Felipe Almeida Lessa 写道:

> On Sun, Jan 8, 2012 at 12:27 PM, Gregory Collins
>  wrote:
>> A "too many open files" error is usually due to running out of file
>> descriptors for network sockets. On my Linux machine the per-process limit
>> for file descriptors defaults to 1024, and on my Mac the default is 256. You
>> can see your current limit by running "ulimit -a" from the terminal.
> 
> If you're on Linux, then you may
> 
>  $ ls -lah /proc/PID/fd
> 
> to see where these open files are pointing to.
> 
> HTH,
> 
> -- 
> Felipe.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [web-devel] [ANNOUNCE] First release of crypto-conduit

2012-01-08 Thread Vincent Hanquez

On 01/08/2012 02:35 PM, Aristid Breitkreuz wrote:

To use the hash, I have to convert it to a ByteString, and then I
suddenly have lost all this safety. I don't really see how there is
any real safety gained.
Using the hash and carrying it around are two different things. You don't get 
any usefulness once you have converted it indeed, but before hand this is quite 
handy sometimes. It's very similar to phantom types or newtype-ing.


It also have a useful self-documentation factor, for example the later tell the 
user of "myFunction" more information than the former:


myFunction :: ByteString -> ByteString -> SomeType
myFunction :: ByteString -> Hash SHA1 -> SomeType

--
Vincent

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] "too many open files" using snap

2012-01-08 Thread Brandon Allbery
On Sun, Jan 8, 2012 at 09:50, Felipe Almeida Lessa
wrote:

> If you're on Linux, then you may
>
>  $ ls -lah /proc/PID/fd
>
> to see where these open files are pointing to.
>

And on other systems lsof can determine this information.

$ lsof -p PID

-- 
brandon s allbery  allber...@gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] "too many open files" using snap

2012-01-08 Thread Felipe Almeida Lessa
On Sun, Jan 8, 2012 at 12:27 PM, Gregory Collins
 wrote:
> A "too many open files" error is usually due to running out of file
> descriptors for network sockets. On my Linux machine the per-process limit
> for file descriptors defaults to 1024, and on my Mac the default is 256. You
> can see your current limit by running "ulimit -a" from the terminal.

If you're on Linux, then you may

  $ ls -lah /proc/PID/fd

to see where these open files are pointing to.

HTH,

-- 
Felipe.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] "too many open files" using snap

2012-01-08 Thread Ozgun Ataman
Not knowing how exactly you set up your interop with mysql, is there any chance 
your application tries to keep too many mysql connections open? A simple "show 
processlist;" inside of a mysql console should rule out this possibility.

Also, are you reading to or writing from any files at any point independently 
of the snap infrastructure? I have had issues in the past with intermittent 
background file reads not being strict enough and eventually starving the 
system of file descriptors.

Cheers,
Ozgun



On Sunday, January 8, 2012 at 4:27 PM, Gregory Collins wrote:

> On Sun, Jan 8, 2012 at 7:25 AM, Eric Wong  (mailto:wsy...@gmail.com)> wrote:
> > Hi haskellers,
> > 
> > I wrote a web server using snap framework. Basically, it's an API server 
> > using hdbc-mysql to connect to a mysql server. But it also serves some 
> > static web pages and images, using the serveDirectory function in 
> > snap-core. The program eats more and more memory slowly, but I couldn't 
> > spot the leak. It uses less than 10MB memory when starting. Sometimes, it 
> > can grow to 60-70MB and stop working correctly. Then I find that the log 
> > file is full of "too many open files" error. As I don't have any code open 
> > any files, I suspect it's the serveDirectory leaking. But I don't have any 
> > expertise on the core of snap, so, could some one give me some advice on 
> > this problem?  
> 
> I'm fairly certain there's no leak in Snap in this code, although I will 
> gladly accept evidence to the contrary -- I've been load-testing 
> "serveDirectory" at 20,000 qps for a couple of minutes now, with no increase 
> in the memory resident size.
> 
> A "too many open files" error is usually due to running out of file 
> descriptors for network sockets. On my Linux machine the per-process limit 
> for file descriptors defaults to 1024, and on my Mac the default is 256. You 
> can see your current limit by running "ulimit -a" from the terminal.
> 
> Each incoming socket occupies a file descriptor, as does every open 
> connection to your database and every open file. When these run out, calls to 
> accept() or to open files start failing and you get this error message. 
> 
> Memory profiling should help you find the leak.
> 
> G
> -- Gregory Collins mailto:g...@gregorycollins.net)>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org (mailto:Haskell-Cafe@haskell.org)
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [web-devel] [ANNOUNCE] First release of crypto-conduit

2012-01-08 Thread Aristid Breitkreuz
To use the hash, I have to convert it to a ByteString, and then I
suddenly have lost all this safety. I don't really see how there is
any real safety gained.

That said, just exposing a direct method of getting to that ByteString
without cereal (as Thomas proposed) would be an improvement.


Aristid


2012/1/8 Vincent Hanquez :
> On 01/08/2012 04:12 AM, Aristid Breitkreuz wrote:
>>
>> Why? I don't actually need the hash object for anything, usually. All
>> I need is the ByteString, and then I need to learn how to use the
>> cereal package to get it...
>
> The whole rationale i believe, is having meaningful types associated to your
> values so that the type checker can do its job. i.e. you don't start mixing
> a hash (in binary form) and a random piece of file.
>
> My only problem with the Serialize instance, is that dependencies (cereal in
> this case) trickle through to the user of the API, which would be solved by
> Thomas' suggestion.
>
> --
> Vincent

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] "too many open files" using snap

2012-01-08 Thread Gregory Collins
On Sun, Jan 8, 2012 at 7:25 AM, Eric Wong  wrote:

> Hi haskellers,
>
> I wrote a web server using snap framework. Basically, it's an API server
> using hdbc-mysql to connect to a mysql server. But it also serves some
> static web pages and images, using the serveDirectory function in
> snap-core. The program eats more and more memory slowly, but I couldn't
> spot the leak. It uses less than 10MB memory when starting. Sometimes, it
> can grow to 60-70MB and stop working correctly. Then I find that the log
> file is full of "too many open files" error. As I don't have any code open
> any files, I suspect it's the serveDirectory leaking. But I don't have any
> expertise on the core of snap, so, could some one give me some advice on
> this problem?
>

I'm fairly certain there's no leak in Snap in this code, although I will
gladly accept evidence to the contrary -- I've been load-testing
"serveDirectory" at 20,000 qps for a couple of minutes now, with no
increase in the memory resident size.

A "too many open files" error is usually due to running out of file
descriptors for network sockets. On my Linux machine the per-process limit
for file descriptors defaults to 1024, and on my Mac the default is 256.
You can see your current limit by running "ulimit -a" from the terminal.

Each incoming socket occupies a file descriptor, as does every open
connection to your database and every open file. When these run out, calls
to accept() or to open files start failing and you get this error message.

Memory profiling should help you find the leak.

G
-- 
Gregory Collins 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] RoseTree + Data.Typeable.Zipper

2012-01-08 Thread Sergey Mironov
Hi list!
Could you please give me a quick example of navigating throw
Data.Typeable.Zipper built on top of a Rose Tree?
eg. (See ??? in the last line - is my question)

{-#LANGUAGE TemplateHaskell, DeriveDataTypeable, TypeOperators #-}

import Data.Typeable.Zipper

data Tree k a = Tree {
_rules :: [(k,Tree k a)]
} deriving(Show, Typeable)

$(mkLabelsNoTypes [''Tree])

atree = Tree [(1, Tree []), (2, Tree []), (3, Tree [(11, Tree [])])]

moveToLeftmostChild :: (Typeable k, Typeable a) =>
Zipper1 (Tree k a) -> Zipper1 (Tree k a)
moveToLeftmostChild z = moveTo ??? z

Thanks,
Sergey
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] [web-devel] [ANNOUNCE] First release of crypto-conduit

2012-01-08 Thread Vincent Hanquez

On 01/08/2012 04:12 AM, Aristid Breitkreuz wrote:

Why? I don't actually need the hash object for anything, usually. All
I need is the ByteString, and then I need to learn how to use the
cereal package to get it...
The whole rationale i believe, is having meaningful types associated to your 
values so that the type checker can do its job. i.e. you don't start mixing a 
hash (in binary form) and a random piece of file.


My only problem with the Serialize instance, is that dependencies (cereal in 
this case) trickle through to the user of the API, which would be solved by 
Thomas' suggestion.


--
Vincent

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] OpenAL bindings?

2012-01-08 Thread shelarcy

Hi,

On Sun, 08 Jan 2012 16:49:40 +0900, Jason Dagit  wrote:

I see that the following darcs repositories are available on the
community server:

http://code.haskell.org/OpenAL/OpenAL
http://code.haskell.org/OpenAL/ALUT

Hope this helps,


Thank you so much!  Someone (I guess that's me) should update the wiki.


I updated link in OpenAL page now.

Best Regards,



On Sat, Jan 7, 2012 at 1:26 PM, Yitzchak Gale  wrote:

Jason Dagit wrote:

Looks like the repo [1] for the OpenAL bindings that Sven Panne
created [2] is no longer available. I assume this is a result of The
Great Server Outage of 2011 [3].
[1] http://darcs.haskell.org/packages/OpenAL/
[2] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/OpenAL
[3] http://www.haskell.org/pipermail/haskell-cafe/2011-February/088829.html


No, darcs.haskell.org is not the community server.
It is a separate server that seems to be located at Galois.


Ah yes, I always forget which servers are where.


--
shelarcy 
http://page.freett.com/shelarcy/

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe