Re: [Haskell-cafe] strange hangs with -threaded runtime

2012-07-13 Thread Joey Adams
On Fri, Jul 13, 2012 at 2:26 PM, Joey Hess  wrote:
> Are there any common gotchas with converting to the threaded runtime
> that might provide a hint to what's wrong? My code does not currently
> use Control.Concurrent or threads, although it does use some libraries
> like MissingH that use forkIO or forkOS.

Off the top of my head, I'm not aware of any (non-Windows-related)
gotchas with using -threaded.  However, some functions in MissingH
(e.g. in System.Cmd.Utils) call forkProcess.  To quote the
documentation of forkProcess [1]:

---
forkProcess comes with a giant warning: since any other running
threads are not copied into the child process, it's easy to go wrong:
e.g. by accessing some shared resource that was held by another thread
in the parent.
---

Perhaps the forked process is inheriting an interleaved computation
that tries to use resources in the parent process.

 [1]: 
http://hackage.haskell.org/packages/archive/unix/latest/doc/html/System-Posix-Process.html#v:forkProcess

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


[Haskell-cafe] strange hangs with -threaded runtime

2012-07-13 Thread Joey Hess
I have a rather large program that works fine with ghc's default
runtime, but now I'd like to build it with -threaded, and this
causes it to hang in a way I have not been able to pin down to anything
specific. It hangs at different points each time it's run; running
it in strace will consistently avoid the problem. If I look at
it once it's hung, I always see a pair of processes, both blocked
in futex:

joey@wren:~/src/git-annex>strace -p 21749
Process 21749 attached - interrupt to quit
futex(0x8b03930, FUTEX_WAIT_PRIVATE, 69, NULL^C 
Process 21749 detached
joey@wren:~/src/git-annex>strace -p 21811
Process 21811 attached - interrupt to quit
futex(0x8b03df8, FUTEX_WAIT_PRIVATE, 2, NULL

Are there any common gotchas with converting to the threaded runtime
that might provide a hint to what's wrong? My code does not currently
use Control.Concurrent or threads, although it does use some libraries
like MissingH that use forkIO or forkOS.

GHC 7.4.1, 7.4.2 on Debian Linux

-- 
see shy jo

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


[Haskell-cafe] RFCQ: The Classy Prelude: a more fully polymophic, drop-in alternative prelude http://www.yesodweb.com/blog/2012/07/classy-prelude

2012-07-13 Thread Max Cantor
I'd like to share Michael Snoyman's Classy Prelude:
http://www.yesodweb.com/blog/2012/07/classy-prelude .  The basic gist of
the work is that many of the standard prelude functions are made for
concrete types such as [a], [(a,b)], and [Char] but can be much more
polymorphic.  While this complicates error messages and makes learning
Haskell more difficult, we believe experienced Haskellers will benefit from
the added polymorphism.  Note that we aren't saying that the standard
Prelude should be replaced, rather we are offering this as a drop-in
alternative.  Note that it reexports most of the standard Prelude types so
it should be very low impact to switch over.

We love to hear your comments.  Note however, that this is a RFCQ with the
'C' standing for constructive..

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


Re: [Haskell-cafe] Plain lambda inside banana brackets in the arrow notation

2012-07-13 Thread Ross Paterson
On Thu, Jul 12, 2012 at 02:47:57PM +0100, Ross Paterson wrote:
> Though one possibility that might get
> us most of the way there would be to refactor the Arrow class as
> 
>   class PreArrow a where
> premap :: (b -> b') -> a b' c -> a b c
> 
>   class (Category a, PreArrow a) => Arrow a where
> arr :: (b -> c) -> a b c
> arr f = premap f id
> 
> first :: a b c -> a (b,d) (c,d)

I've done this and the associated GHC changes locally; it yields a simple
rule for determining which instances are needed, based on the keywords used:

* all commands ("proc" and operator arguments) need PreArrow
  * "do" needs Arrow
* "rec" needs ArrowLoop
  * "case" or "if" need ArrowChoice

I'm warming to it as a worthwhile generalization (though not exactly what
was asked for).

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


Re: [Haskell-cafe] Monads with "The" contexts?

2012-07-13 Thread Takayuki Muranushi
Thank you Tillman, and Oleg, for your advices! Since ICFP contest is
starting in a few hours, I will make a quick response with
gratefulness and will read the full paper later

Let me guess a few things, please tell me am I right.

The share :: m a -> m (m a) is almost the thing I am looking for. I
have independently (believe me!) invented an equivalent, "bind trick,"
for my DSL:
http://nushisblogger.blogspot.jp/2012/06/builder-monad.html
but am now enlighted with what it really meant. Still, `share` cannot
bring the shared binding to global scope (e.g. it doesn't allow place
sunMass, earthMass, marsMass in separate modules)

I guess, my original question is ill-posed, since all the values in
Haskell are pure, so in the following trivial example

> earthCopyMass = earthMass

there is no way to distinguish two masses, thus there's no telling if
Earth and EarthCopy is two reference to one planet or two distinct
planets.

I don't know if memo can solve this problem. I have to test. I'll try
implement `memo` in your JFP paper section 4.2 Memoization; seems like
it's not in explicit-sharing hackage.

I'm vaguely foreseeing, that like in memoized (f2 0, f2 1, f2 0, f2 1)
we need to pass around some `world` among it. That will be random
generator seeds if our continuous-nondeterminism is an MonadIO when we
perform Monte-Carlo simulations; or it's a virtual `world` if we make
Gaussian approximation of probabilistic density functions.

To Ben: Thank you for your comments anyway! But since I'm not going to
use the List monad (the use of List was just for explanation,) the
discreteness is not an issue here. That's my intent when I said
"another story." Sorry for confusion!

All the best,

Takayuki

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


Re: [Haskell-cafe] Control defaulting in ghci

2012-07-13 Thread Roman Cheplyaka
* Patrick Palka  [2012-07-08 14:39:26-0400]
> On 7/8/2012 11:28 AM, Roman Cheplyaka wrote:
> >Is there a way to control defaulting in ghci? (Like the "default"
> >declaration in source files does.)
> >
> >ghci 7.4.1 doesn't accept "default" declarations. I tried loading a
> >module with a "default" declaration, but that also didn't affect the
> >ghci session.
> >
> >It would be ironic if this is possible in source files but not in ghci,
> >since defaulting is much more useful in an interactive session than in
> >modules.
> >
> 
> I've too wanted this for quite some time, so I have created a ticket
> + a patch[1] that implements this feature. Feel free to test it.
> 
> [1]: http://hackage.haskell.org/trac/ghc/ticket/7061

Very nice, thanks!

I'm travelling at the moment and don't have a good enough internet
connection to fetch the GHC sources, but I'll try it and let you know in
a couple of weeks.

-- 
Roman I. Cheplyaka :: http://ro-che.info/

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


Re: [Haskell-cafe] ghci and TH cannot: unknown symbol `stat64`

2012-07-13 Thread Michael Snoyman
On Thu, Jul 12, 2012 at 7:30 PM, Tristan Ravitch wrote:

> On Thu, Jul 12, 2012 at 07:20:39PM +0300, Michael Snoyman wrote:
> > On Jul 12, 2012 7:13 PM, "Tristan Ravitch"  wrote:
> > >
> > > On Thu, Jul 12, 2012 at 11:07:05AM -0500, Tristan Ravitch wrote:
> > > > Are you trying this on a 32 bit system?  And when you compiled that C
> > > > program, did you try to add
> > > >
> > > >   -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
> > > >
> > > > to the compile command?  When I define those the resulting object
> file
> > > > from your example correctly references stat64 instead of stat.
> > >
> > > Er sorry, saw your earlier email now.  Could this be a mismatch
> > > between how your sqlite.so is compiled and how the cbits in
> > > persistent-sqlite are compiled, particularly with largefile support?
> >
> > I don't think so. The test case I put together had nothing to do with
> > sqlite. Also, persistent-sqlite will either use sqlite.so _or_ the
> included
> > sqlite3.c file (based on a compile-time flag). The former works
> perfectly,
> > only the latter causes problems.
> >
> > Michael
>
> I was looking at the symbols in libc and noticed that it doesn't
> actually export stat64/stat, so that would explain something at least.
> I think your idea about the switch to function pointers versus direct
> calls is probably right - the linker probably does some rewriting of
> calls to stat into __fxstat and company, but for some reason doesn't
> handle references to function pointers.
>
> I also ran across this stackoverflow post that mentions something
> similar:
>
>
> http://stackoverflow.com/questions/5478780/c-and-ld-preload-open-and-open64-calls-intercepted-but-not-stat64
>
> So stat64 is actually special and in this libc_nonshared.a library (it
> is on my system at least).  It would be ugly to have to link that
> manually - not sure what the right answer is, but at least this might
> explain it.
>

That's a great find, and it really explains a lot. It seems then that:

* GNU ld has some black magic do know about the stat/stat64 hack.
* Compiling via GHC just uses GNU ld, which is able to make the hack work.
* Interpreting with GHC doesn't get to take advantage of GNU ld's hack.

I've opened a trac ticket[1] for this issue, thank you very much for the
help!

Michael

[1] http://hackage.haskell.org/trac/ghc/ticket/7072
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] haskell.org is so fragile

2012-07-13 Thread Gaius Hammond
It would have to be rewritten in Haskell and called Harnish. 


Gaius



--

-Original Message-
From: Bardur Arantsson 
Sender: haskell-cafe-boun...@haskell.org
Date: Fri, 13 Jul 2012 01:28:30 
To: 
Subject: Re: [Haskell-cafe] haskell.org is so fragile

On 07/12/2012 11:04 PM, Ganesh Sittampalam wrote:
> Hi,
> 
> On 12/07/2012 13:06, Takayuki Muranushi wrote:
>> Today I have observed that hackage.haskell.org/ timeout twice (in the
>> noon and in the evening.)
>>
>> What is the problem? Is it that haskell users have increased so that
>> haskell.org is overloaded? That's very good news.
>> I am eager to donate some money if it requires server reinforcement.
> 
> The issue is unfortunately more to do with sysadmin resources than
> server hardware; there's noone with the time to actively manage the
> server and make sure that it's running well. Any ideas for improving the
> situation would be gratefully received.
> 
> Today there were some problems with some processes taking up a lot of
> resources. One of the problems was the hackage search script, which has
> been disabled for now.
> 

Since I don't have insight into the "inner sanctum" (aka.
"service/server setup") this may be way off base, but how about adding a
Varnish instance in front of haskell.org and its various subdomains? It
could cache everything for 5 minutes (unconditional) and reduce load by
ridiculous amounts.

Regards,


___
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