Re: [Haskell-cafe] Can a GC delay TCP connection formation?

2012-11-28 Thread Neil Davies
Jeff

Are you certain that all the delay can be laid at the GHC runtime? 

How much of the end-to-end delay budget is being allocated to you? I recently 
moved a static website from a 10-year old server in telehouse into AWS in 
Ireland and watched the access time (HTTP GET to check time on top index page) 
increase by 150ms.

Neil

On 27 Nov 2012, at 19:02, Jeff Shaw shawj...@gmail.com wrote:

 Hello Timothy and others,
 One of my clients hosts their HTTP clients in an Amazon cloud, so even when 
 they turn on persistent HTTP connections, they use many connections. Usually 
 they only end up sending one HTTP request per TCP connection. My specific 
 problem is that they want a response in 120 ms or so, and at times they are 
 unable to complete a TCP connection in that amount of time. I'm looking at on 
 the order of 100 TCP connections per second, and on the order of 1000 HTTP 
 requests per second (other clients do benefit from persistent HTTP 
 connections).
 
 Once each minute, a thread of my program updates a global state, stored in an 
 IORef, and updated with atomicModifyIORef', based on query results via 
 HDBC-obdc. The query results are strict, and atomicModifyIORef' should 
 receive the updated state already evaluated. I reduced the amount of time 
 that query took from tens of seconds to just a couple, and for some reason 
 that reduced the proportion of TCP timeouts drastically. The approximate 
 before and after TCP timeout proportions are 15% and 5%. I'm not sure why 
 this reduction in timeouts resulted from the query time improving, but this 
 discovery has me on the task of removing all database code from the main 
 program and into a cron job. My best guess is that HDBC-odbc somehow disrupts 
 other communications while it waits for the DB server to respond.
 
 To respond to Ertugrul, I'm compiling with -threaded, and running with +RTS 
 -N.
 
 I hope this helps describe my problem. I c an probably come up with some hard 
 information if requested, E.G. threadscope.
 
 Jeff
 
 On 11/27/2012 10:55 AM, timothyho...@seznam.cz wrote:
 Could you give us more info on what your constraints are?  Is it necessary 
 that you have a certain number of connections per second, or is it necessary 
 that the connection results very quickly after some other message is 
 received?
 
 
 ___
 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] Conduit and pipelined protocol processing using a threadpool

2012-11-28 Thread Nicolas Trangez
On Wed, 2012-11-28 at 09:17 +0200, Michael Snoyman wrote:
 
 
 
 On Tue, Nov 27, 2012 at 7:25 PM, Nicolas Trangez
 nico...@incubaid.com wrote:
 Michael,
 
 On Tue, 2012-11-27 at 17:14 +0200, Michael Snoyman wrote:
  I think the stm-conduit package[1] may be helpful for this
 use case.
  Each time you get a new command, you can fork a thread and
 give it the
  TBMChan to write to, and you can use sourceTBMChan to get a
 source to
  send to the client.
 
 
 That's +- what I had in mind. I did find stm-conduit before
 and did try
 to get the thing working using it, but these attempts failed.
 
 I attached an example which might clarify what I intend to do.
 I'm aware
 it contains several potential bugs (leaking threads etc), but
 that's
 beside the question ;-)
 
 If only I could figure out what to put on the 3 lines of
 comment I left
 in there...
 
 Thanks for your help,
 
 Nicolas
 
 
 
 The issue is that you're trying to put everything into a single
 Conduit, which forces reading and writing to occur in a single thread
 of execution. Since you want your writing to be triggered by a
 separate event (data being available on the Chan), you're running into
 limitations.
 
 
 The reason network-conduit provides a Source for the incoming data and
 a Sink for outgoing data is specifically to address your use case. You
 want to take the data from the Source and put it into the Chan in one
 thread, and take the data from the other Chan and put it into the Sink
 in a separate thread. Something like:
 
 
 myApp appdata = do
 chan1 - ...
 chan2 - ...
 replicateM_ 5 $ forkIO $ worker chan1 chan2
 forkIO $ appSource appdata $$ sinkTBMChan chan1
 sourceTBMChan chan2 $$ appSink appdata
 
 
 You'll also want to make sure to close chan1 and chan2 to make sure
 that your threads stop running.

Thanks, I +- figured that out last night. Only thing left is managing
the handshake before forking off the workers, if possible (otherwise
things become very messy IMHO), but ResumableSources etc might be of use
here.

Maybe there's a library somewhere in here...

Thanks a bunch,

Nicolas



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


[Haskell-cafe] How to incrementally update list

2012-11-28 Thread Branimir Maksimovic

Problem is following short program:list = [1,2,3,4,5]
advance l = map (\x - x+1) l
run 0 s = srun n s = run (n-1) $ advance s
main = dolet s =  run 5000 listputStrLn $ show s
I want to incrementally update list lot of times, but don't knowhow to do 
this.Since Haskell does not have loops I have to use recursion,but problem is 
that recursive calls keep previous/state parameterleading to excessive 
stack.and memory usage.I don't know how to tell Haskell not to keep 
previousstate rather to release so memory consumption becomesmanagable.
Is there some solution to this problem as I think it is rathercommon?
  ___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to incrementally update list

2012-11-28 Thread Benjamin Edwards
TCO + strictnesses annotations should take care of your problem.
On 28 Nov 2012 11:44, Branimir Maksimovic bm...@hotmail.com wrote:

  Problem is following short program:
 list = [1,2,3,4,5]

 advance l = map (\x - x+1) l

 run 0 s = s
 run n s = run (n-1) $ advance s

 main = do
 let s =  run 5000 list
 putStrLn $ show s

 I want to incrementally update list lot of times, but don't know
 how to do this.
 Since Haskell does not have loops I have to use recursion,
 but problem is that recursive calls keep previous/state parameter
 leading to excessive stack.and memory usage.
 I don't know how to tell Haskell not to keep previous
 state rather to release so memory consumption becomes
 managable.

 Is there some solution to this problem as I think it is rather
 common?


 ___
 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] How to incrementally update list

2012-11-28 Thread Clark Gaebel
Here's a version that works:

*import Control.DeepSeq*

list = [1,2,3,4,5]

advance l = *force $* map (\x - x+1) l

run 0 s = s
run n s = run (n-1) $ advance s

main = do
let s =  run 5000 list
putStrLn $ show s

The problem is that you build of a huge chain of updates to the list. If we
just commit each update as it happens, we'll use a constant amount of
memory.

Haskell's laziness is tricky to understand coming from imperative
languages, but once you figure out its evaluation rules, you'll begin to
see the elegance.

Ηope this helps,
  - Clark


On Wed, Nov 28, 2012 at 7:07 AM, Benjamin Edwards edwards.b...@gmail.comwrote:

 TCO + strictnesses annotations should take care of your problem.
 On 28 Nov 2012 11:44, Branimir Maksimovic bm...@hotmail.com wrote:

  Problem is following short program:
 list = [1,2,3,4,5]

 advance l = map (\x - x+1) l

 run 0 s = s
 run n s = run (n-1) $ advance s

 main = do
 let s =  run 5000 list
 putStrLn $ show s

 I want to incrementally update list lot of times, but don't know
 how to do this.
 Since Haskell does not have loops I have to use recursion,
 but problem is that recursive calls keep previous/state parameter
 leading to excessive stack.and memory usage.
 I don't know how to tell Haskell not to keep previous
 state rather to release so memory consumption becomes
 managable.

 Is there some solution to this problem as I think it is rather
 common?


 ___
 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] How to incrementally update list

2012-11-28 Thread Kim-Ee Yeoh
 I want to incrementally update list lot of times, but don't know how to
do this.

Are you using the right data structure for the job? Maybe you want an array
instead?

-- Kim-Ee


On Wed, Nov 28, 2012 at 6:43 PM, Branimir Maksimovic bm...@hotmail.comwrote:

  Problem is following short program:
 list = [1,2,3,4,5]

 advance l = map (\x - x+1) l

 run 0 s = s
 run n s = run (n-1) $ advance s

 main = do
 let s =  run 5000 list
 putStrLn $ show s

 I want to incrementally update list lot of times, but don't know
 how to do this.
 Since Haskell does not have loops I have to use recursion,
 but problem is that recursive calls keep previous/state parameter
 leading to excessive stack.and memory usage.
 I don't know how to tell Haskell not to keep previous
 state rather to release so memory consumption becomes
 managable.

 Is there some solution to this problem as I think it is rather
 common?


 ___
 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] OpenAL - compiling problem

2012-11-28 Thread Gary Klindt

Dear Haskell Cafe,

I tried installing the haskell openal library via
cabal install openal

I get the following error:

...
[ 7 of 30] Compiling Sound.OpenAL.ALC.QueryUtils ( 
Sound/OpenAL/ALC/QueryUtils.hs, dist/build/Sound/OpenAL/ALC/QueryUtils.o )


Sound/OpenAL/ALC/QueryUtils.hs:66:1:
Unacceptable argument type in foreign declaration: ALCdevice
When checking declaration:
  foreign import ccall unsafe static alcGetString alcGetString
:: ALCdevice - ALCenum - IO (Ptr ALCchar)

Sound/OpenAL/ALC/QueryUtils.hs:102:1:
Unacceptable argument type in foreign declaration: ALCdevice
When checking declaration:
  foreign import ccall unsafe static alcGetIntegerv alcGetIntegerv
:: ALCdevice - ALCenum - ALCsizei - Ptr ALCint - IO ()

Sound/OpenAL/ALC/QueryUtils.hs:120:1:
Unacceptable argument type in foreign declaration: ALCdevice
When checking declaration:
  foreign import ccall unsafe static alcIsExtensionPresent 
alcIsExtensionPresent_

:: ALCdevice - Ptr ALCchar - IO ALCboolean
Failed to install OpenAL-1.4.0.1
cabal: Error: some packages failed to install:
OpenAL-1.4.0.1 failed during the building phase. The exception was:
ExitFailure 1


The version of my openal installation is 1.14-1.

I also tried to install via darcs, but the error is the same.

Any ideas?

Greets Gary

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


Re: [Haskell-cafe] How to incrementally update list

2012-11-28 Thread Branimir Maksimovic

Thank you very much! That solved it ;)I had to put explicit type signature in 
front of advance in order to compile
From: cgae...@uwaterloo.ca
Date: Wed, 28 Nov 2012 08:01:38 -0500
Subject: Re: [Haskell-cafe] How to incrementally update list
To: edwards.b...@gmail.com
CC: bm...@hotmail.com; haskell-cafe@haskell.org

Here's a version that works:

import Control.DeepSeq

list = [1,2,3,4,5]
advance l = force $ map (\x - x+1) l


run 0 s = srun n s = run (n-1) $ advance s
main = dolet s =  run 5000 listputStrLn $ show s

The problem is that you build of a huge chain of updates to the list. If we 
just commit each update as it happens, we'll use a constant amount of memory.



Haskell's laziness is tricky to understand coming from imperative languages, 
but once you figure out its evaluation rules, you'll begin to see the elegance.

Ηope this helps,
  - Clark




On Wed, Nov 28, 2012 at 7:07 AM, Benjamin Edwards edwards.b...@gmail.com 
wrote:


TCO + strictnesses annotations should take care of your problem.
On 28 Nov 2012 11:44, Branimir Maksimovic bm...@hotmail.com wrote:







Problem is following short program:list = [1,2,3,4,5]
advance l = map (\x - x+1) l
run 0 s = srun n s = run (n-1) $ advance s



main = dolet s =  run 5000 listputStrLn $ show s
I want to incrementally update list lot of times, but don't knowhow to do this.


Since Haskell does not have loops I have to use recursion,but problem is that 
recursive calls keep previous/state parameterleading to excessive stack.and 
memory usage.I don't know how to tell Haskell not to keep previous


state rather to release so memory consumption becomesmanagable.
Is there some solution to this problem as I think it is rathercommon?
  




___

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


[Haskell-cafe] SOX - play simple

2012-11-28 Thread Gary Klindt

Dear Cafe,

after installing the Sox library
(cabal install sox)
I wanted to let run a minimal example from
http://hackage.haskell.org/packages/archive/sox/0.2.2.2/doc/html/Sound-Sox-Play.html


module Main where

import Sound.Sox.Play
import Sound.Sox.Signal.List
--import Sound.Sox.Option.Format

import Data.Int

main = do
simple Sound.Sox.Signal.List.put
   Option.none
   11025
   (iterate (1000+) (0::Data.Int.Int16))

in this version, I get the error:
 Not in scope: `Option.none'

So, I imported Sound.Sox.Option.Format, because there is a none with the 
right type. I also changed Option.none to none.


Then the program compiles and I get the runtime error:
fd:4: hClose: resource vanished (Broken pipe)


What is wrong here?

I appreciate your help!

Best regards, Gary

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


Re: [Haskell-cafe] Can a GC delay TCP connection formation?

2012-11-28 Thread Alexander Kjeldaas
Jeff, this is somewhat off topic, but interesting.  Are telehouse and AWS
physically close?  Was this latency increase not expected due to geography?

Alexander

On 28 November 2012 06:21, Neil Davies semanticphilosop...@gmail.comwrote:

 Jeff

 Are you certain that all the delay can be laid at the GHC runtime?

 How much of the end-to-end delay budget is being allocated to you? I
 recently moved a static website from a 10-year old server in telehouse into
 AWS in Ireland and watched the access time (HTTP GET to check time on top
 index page) increase by 150ms.

 Neil

 On 27 Nov 2012, at 19:02, Jeff Shaw shawj...@gmail.com wrote:

  Hello Timothy and others,
  One of my clients hosts their HTTP clients in an Amazon cloud, so even
 when they turn on persistent HTTP connections, they use many connections.
 Usually they only end up sending one HTTP request per TCP connection. My
 specific problem is that they want a response in 120 ms or so, and at times
 they are unable to complete a TCP connection in that amount of time. I'm
 looking at on the order of 100 TCP connections per second, and on the order
 of 1000 HTTP requests per second (other clients do benefit from persistent
 HTTP connections).
 
  Once each minute, a thread of my program updates a global state, stored
 in an IORef, and updated with atomicModifyIORef', based on query results
 via HDBC-obdc. The query results are strict, and atomicModifyIORef' should
 receive the updated state already evaluated. I reduced the amount of time
 that query took from tens of seconds to just a couple, and for some reason
 that reduced the proportion of TCP timeouts drastically. The approximate
 before and after TCP timeout proportions are 15% and 5%. I'm not sure why
 this reduction in timeouts resulted from the query time improving, but this
 discovery has me on the task of removing all database code from the main
 program and into a cron job. My best guess is that HDBC-odbc somehow
 disrupts other communications while it waits for the DB server to respond.
 
  To respond to Ertugrul, I'm compiling with -threaded, and running with
 +RTS -N.
 
  I hope this helps describe my problem. I c an probably come up with some
 hard information if requested, E.G. threadscope.
 
  Jeff
 
  On 11/27/2012 10:55 AM, timothyho...@seznam.cz wrote:
  Could you give us more info on what your constraints are?  Is it
 necessary that you have a certain number of connections per second, or is
 it necessary that the connection results very quickly after some other
 message is received?
 
 
  ___
  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] Equality test between types that returns type-level Bool ?

2012-11-28 Thread Takayuki Muranushi
By tracing how unittyped produced the 'True-s and 'False-s in the error
messages, and by Oleg's lecture,

 1 meter + 5 second

interactive:17:9:
Couldn't match type 'False with 'True
When using functional dependencies to combine
  UnitTyped.And 'False 'False 'False,
arising from the dependency `a b - c'
in the instance declaration in `UnitTyped'
  UnitTyped.And 'False 'False 'True,
arising from a use of `+' at interactive:17:9
In the expression: 1 meter + 5 second
In an equation for `it': it = 1 meter + 5 second


I understood how type-level equalities
https://github.com/nushio3/dimensional-tf/blob/master/attic/typeeq-01.hs
and type-level list lookups
https://github.com/nushio3/dimensional-tf/blob/master/attic/typeeq-03.hs

can be implemented using overlapped instances. Thank you for the
instructions.

and I'm looking forward to see TYPEREP with ghc7.6.1's promoted integers
and TH pretty soon!


2012/11/27 Takayuki Muranushi muranu...@gmail.com

 Dear Gábor, Erik, and Oleg,

 Thank you for your advices. Also what I have wanted, the extensible
 dimensional type system, has just been released.

 http://hackage.haskell.org/package/unittyped-0.1

 Now I have homeworks to test these, thank you!




 2012/11/27 Erik Hesselink hessel...@gmail.com

 If you're up for it, Oleg has a lot of interesting material about this
 subject [1].

 Regards,

 Erik

 [1] http://okmij.org/ftp/Haskell/typeEQ.html


 On Sun, Nov 25, 2012 at 9:36 AM, Takayuki Muranushi 
 muranu...@gmail.comwrote:

 Is it possible to write

 type family SameType a b :: Bool

 which returns True if a and b are the same type, and False otherwise?

 I encountered this problem when I was practicing promoted lists and
 tuples in ghc-7.6.1. One of my goal for practice is to write more
 modular version of extensible-dimensional calculations, and to
 understand whether ghc-7.6.1 is capable of it.


 http://hackage.haskell.org/packages/archive/dimensional/0.10.2/doc/html/Numeric-Units-Dimensional-Extensible.html

 Some of my attempts:

 https://github.com/nushio3/dimensional-tf/blob/master/attic/list-02.hs
 This fails because :==: is not an equality test between a and b, but
 is a equality test within a (promoted) kind.

 https://github.com/nushio3/dimensional-tf/blob/master/attic/list-03.hs
 This fails because type instance declarations are not read from top to
 bottom. (not like function declarations.)

 https://github.com/nushio3/dimensional-tf/blob/master/attic/map-03.hs
 I could define a lookup using class constraints, but when I use it,
 results in overlapping instances.

 So, will somebody teach me which of the following is correct?

 * We can write a type family SameType a b :: Bool
 * We cannot do that because of theoretical reason (that leads to
 non-termination etc.)
 * We cannot write SameType, but there are ways to write functions like
 'filter' and 'merge' , over type-level lists, without using SameType.

 Always grateful to your help,
 --
 Takayuki MURANUSHI
 The Hakubi Center for Advanced Research, Kyoto University
 http://www.hakubi.kyoto-u.ac.jp/02_mem/h22/muranushi.html

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





 --
 Takayuki MURANUSHI
 The Hakubi Center for Advanced Research, Kyoto University
 http://www.hakubi.kyoto-u.ac.jp/02_mem/h22/muranushi.html




-- 
Takayuki MURANUSHI
The Hakubi Center for Advanced Research, Kyoto University
http://www.hakubi.kyoto-u.ac.jp/02_mem/h22/muranushi.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] delete http://www.haskell.org/haskellwiki/Haskell_IDE

2012-11-28 Thread Roman Beslik
Hi. There is more verbose page http://www.haskell.org/haskellwiki/IDEs . 
I registered on http://www.haskell.org/haskellwiki/ , but have not found 
the Delete Page command, wiki software help pages, or feedback 
channel, so I'm writing here.


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


[Haskell-cafe] Can not use ST monad with polymorphic function

2012-11-28 Thread Dmitry Kulagin
Hi Cafe,

I try to implement some sort of monadic fold, where traversing is
polymorphic over monad type.
The problem is that the code below does not compile. It works with any
monad except for ST.
I suspect that monomorphism is at work here, but it is unclear for me how
to change the code to make it work with ST.

fold :: Monad m = (Int - m ()) - m ()
fold f = mapM_ f [0..20]

selectFold :: Monad m = String - IO ((Int - m ()) - m ())
selectFold method = do
-- in real program I'd like to choose between
-- different fold methods, based on some IO context
return fold

useFold :: Monad m = ((Int - m ()) - m ()) - m ()
useFold fold' = fold' f
where f _ = return () -- some trivial iterator

main = do
fold'' - selectFold some-method-id
print $ runST $ useFold fold''


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


[Haskell-cafe] computation over containers, greatly simplified notation.

2012-11-28 Thread Takayuki Muranushi
Dear all,

I came up with an idea to greatly simplify some kinds of array
computations. It should work well with many kinds of arrays. Is this new?

https://gist.github.com/4162375



These few days, I've been trying to rewrite a hydrodynamic simulation code
that used Data.Vector (~250 lines), to Repa [1] . It seemed promising, but
soon I realized that I needed to use Repa.map and Repa.zipWith almost
everywhere. I need careful thinking to transform every lines (that used
vector's indexing) to Repa's point-free stile. Is there any better ways?

Then I realized that I was the author of Paraiso [2], a DSL for stencil
computation. One of its feature is to write down array computation just as
if it were scalar computation.

Basically what I need is ZipList-like Applicative instances for vectors and
Repa arrays. Why not they support ZipVector? Because 'pure' of zipList was
an infinite list and you can't do infinite vectors. Then I came up with
this idea.

https://gist.github.com/4162375

the wrapper W does several things: it represents the 'pure,' homogeneous
array in a space-efficient manner, and also serves as a newtype-wrapper of
Num (and possibly Fractional, Floating...) instances.

Questions are: is this technology new? or promising? doomed?
It seems to me like a free-Applicative, like the free-Monad theory. Are
they related?
The function 'backend' helps to mix in the non-zip-like computations. How
can we remove the 'undefined' in the 'backend?'
Some of Repa computations are Monads. W needs to be a monad transformer to
incooperate this.

Also I'm grateful to past cafe discussion on existing Zippable
implementations [3][4] .

[1] hackage.haskell.org/package/repa
[2] http://hackage.haskell.org/package/Paraiso
[3] http://www.haskell.org/pipermail/haskell-cafe/2009-July/064403.html
[4]
http://hackage.haskell.org/packages/archive/category-extras/latest/doc/html/Control-Functor-Zip.html


-- 
Takayuki MURANUSHI
The Hakubi Center for Advanced Research, Kyoto University
http://www.hakubi.kyoto-u.ac.jp/02_mem/h22/muranushi.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] OpenAL - compiling problem

2012-11-28 Thread Stephen Tetley
Hi Gary

Which version of GHC are you using?

My suspicion is that ALCdevice might be a newtype falling foul of
recent changes to GHC...

v7.4.1: GHC now requires, as per the standard, that if a newtype is
used in an FFI declaration, then the constructor for that type must be
in scope. For now you only get a warning if it is not, but in the
future this will be an error.

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


Re: [Haskell-cafe] OpenAL - compiling problem

2012-11-28 Thread Gary Klindt


On 11/28/2012 07:01 PM, Stephen Tetley wrote:

Hi Gary

Which version of GHC are you using?

My suspicion is that ALCdevice might be a newtype falling foul of
recent changes to GHC...

v7.4.1: GHC now requires, as per the standard, that if a newtype is
used in an FFI declaration, then the constructor for that type must be
in scope. For now you only get a warning if it is not, but in the
future this will be an error.



Thank you for answering. Maybe you're right, I'm using v7.6.1.
So I can only wait for a patch or use an older version of ghc, right?

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


Re: [Haskell-cafe] OpenAL - compiling problem

2012-11-28 Thread Stephen Tetley
I think OpenAL is now unmaintained. You could try to find AndrewMiller
who updated the last version, otherwise you might have to patch it
yourself or ask a developer of a dependent package if they would
consider pushing another unmaintained release to Hackage.

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


[Haskell-cafe] How can I avoid buffered reads?

2012-11-28 Thread Leon Smith
I have some code that reads (infrequently) small amounts of data from
/dev/urandom,  and because this is pretty infrequent,  I simply open the
handle and close it every time I need some random bytes.

The problem is that I recently discovered that,  thanks to buffering within
GHC,   I was actually reading 8096 bytes when I only need 16 bytes,  and
thus wasting entropy.   Moreover  calling hSetBuffering  handle NoBuffering
did not change this behavior.

I'm not sure if this behavior is a bug or a feature,  but in any case it's
unacceptable for dealing with /dev/urandom.   Probably the simplest way to
fix this is to write a little C helper function that will read from
/dev/urandom for me,  so that I have precise control over the system calls
involved. But I'm curious if GHC can manage this use case correctly;
I've just started digging into the GHC.IO code myself.

Best,
Leon

{-# LANGUAGE BangPatterns, ViewPatterns #-}
import   Control.Applicativeimport   Data.Bitsimport
Data.Word(Word64)import qualified Data.ByteString as Simport
qualified Data.ByteString.Lazy as Limport
Data.ByteString.Internal (c2w)import qualified System.IOas
IOimport qualified Data.Binary.Getas Get
showHex :: Word64 - S.ByteStringshowHex n = s
  where
(!s,_) = S.unfoldrN 16 f n

f n = Just (char (n `shiftR` 60), n `shiftL` 4)

char (fromIntegral - i)
  | i  10= (c2w '0' -  0) + i
  | otherwise = (c2w 'a' - 10) + i
twoRandomWord64s :: IO (Word64,Word64)twoRandomWord64s =
IO.withBinaryFile /dev/urandom IO.ReadMode $ \handle - do
   IO.hSetBuffering handle IO.NoBuffering
   Get.runGet ((,) $ Get.getWord64host * Get.getWord64host) $
L.hGet handle 16
main = do
   (x,y) - twoRandomWord64s
   S.hPutStrLn IO.stdout (S.append (showHex x) (showHex y))

{- Relevant part of strace:

open(/dev/urandom, O_RDONLY|O_NOCTTY|O_NONBLOCK) = 3
fstat(3, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 9), ...}) = 0
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7367e528) = -1 EINVAL
(Invalid argument)
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7367e528) = -1 EINVAL
(Invalid argument)
read(3, 
N\304\4\367/\26c\\3218\237f\214yKg~i\310\r\262\\224H\340y\n\376V?\265\344...,
8096) = 8096
close(3)= 0

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


Re: [Haskell-cafe] How can I avoid buffered reads?

2012-11-28 Thread Thomas DuBuisson
As an alternative, If there existed a Haskell package to give you fast
cryptographically secure random numbers or use the new Intel RDRAND
instruction (when available) would that interest you?

Also, what you are doing is identical to the entropy package on
hackage, which probably suffers from the same bug/performance issue.

Cheers,
Thomas

On Wed, Nov 28, 2012 at 11:38 AM, Leon Smith leon.p.sm...@gmail.com wrote:
 I have some code that reads (infrequently) small amounts of data from
 /dev/urandom,  and because this is pretty infrequent,  I simply open the
 handle and close it every time I need some random bytes.

 The problem is that I recently discovered that,  thanks to buffering within
 GHC,   I was actually reading 8096 bytes when I only need 16 bytes,  and
 thus wasting entropy.   Moreover  calling hSetBuffering  handle NoBuffering
 did not change this behavior.

 I'm not sure if this behavior is a bug or a feature,  but in any case it's
 unacceptable for dealing with /dev/urandom.   Probably the simplest way to
 fix this is to write a little C helper function that will read from
 /dev/urandom for me,  so that I have precise control over the system calls
 involved. But I'm curious if GHC can manage this use case correctly;
 I've just started digging into the GHC.IO code myself.

 Best,
 Leon

 {-# LANGUAGE BangPatterns, ViewPatterns #-}

 import   Control.Applicative
 import   Data.Bits
 import   Data.Word(Word64)
 import qualified Data.ByteString as S
 import qualified Data.ByteString.Lazy as L
 import   Data.ByteString.Internal (c2w)
 import qualified System.IOas IO
 import qualified Data.Binary.Getas Get

 showHex :: Word64 - S.ByteString
 showHex n = s
   where
 (!s,_) = S.unfoldrN 16 f n

 f n = Just (char (n `shiftR` 60), n `shiftL` 4)

 char (fromIntegral - i)
   | i  10= (c2w '0' -  0) + i
   | otherwise = (c2w 'a' - 10) + i

 twoRandomWord64s :: IO (Word64,Word64)
 twoRandomWord64s = IO.withBinaryFile /dev/urandom IO.ReadMode $ \handle -
 do
IO.hSetBuffering handle IO.NoBuffering
Get.runGet ((,) $ Get.getWord64host * Get.getWord64host) $ L.hGet
 handle 16

 main = do
(x,y) - twoRandomWord64s
S.hPutStrLn IO.stdout (S.append (showHex x) (showHex y))


 {- Relevant part of strace:

 open(/dev/urandom, O_RDONLY|O_NOCTTY|O_NONBLOCK) = 3
 fstat(3, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 9), ...}) = 0
 ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7367e528) = -1 EINVAL (Invalid
 argument)
 ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7367e528) = -1 EINVAL (Invalid
 argument)
 read(3,
 N\304\4\367/\26c\\3218\237f\214yKg~i\310\r\262\\224H\340y\n\376V?\265\344...,
 8096) = 8096
 close(3)= 0

 -}


 ___
 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] delete http://www.haskell.org/haskellwiki/Haskell_IDE

2012-11-28 Thread Brent Yorgey
On Wed, Nov 28, 2012 at 07:08:16PM +0200, Roman Beslik wrote:
 Hi. There is more verbose page
 http://www.haskell.org/haskellwiki/IDEs . I registered on
 http://www.haskell.org/haskellwiki/ , but have not found the Delete
 Page command, wiki software help pages, or feedback channel, so I'm
 writing here.

Deleting pages is rather drastic and not enabled for normal users.  It
is probably not a good idea anyway -- what if there are other pages
that link to it?  Just delete all the content and replace it with a
redirect to the IDEs page.

-Brent

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


Re: [Haskell-cafe] Can not use ST monad with polymorphic function

2012-11-28 Thread MigMit
Yes, monomorphism. do binding requires your fold'' to be of some monomorphic 
type, but runST requires some polymorphism.

If you want, you can use special type like that:

data FoldSTVoid = FoldSTVoid {runFold :: forall a. (Int - ST a ()) - ST a ()}

fold :: Monad m = (Int - m ()) - m ()
fold f = mapM_ f [0..20]

selectFold :: String - IO FoldSTVoid -- ((Int - m ()) - m ())
selectFold method = do
-- in real program I'd like to choose between 
-- different fold methods, based on some IO context
return $ FoldSTVoid fold

useFold :: FoldSTVoid - ST a ()
useFold fold' = runFold fold' f
where f _ = return () -- some trivial iterator

main = do
fold'' - selectFold some-method-id
print $ runST $ useFold fold''

On Nov 28, 2012, at 9:52 PM, Dmitry Kulagin dmitry.kula...@gmail.com wrote:

 Hi Cafe,
 
 I try to implement some sort of monadic fold, where traversing is polymorphic 
 over monad type.
 The problem is that the code below does not compile. It works with any monad 
 except for ST. 
 I suspect that monomorphism is at work here, but it is unclear for me how to 
 change the code to make it work with ST.
 
 fold :: Monad m = (Int - m ()) - m ()
 fold f = mapM_ f [0..20]
 
 selectFold :: Monad m = String - IO ((Int - m ()) - m ())
 selectFold method = do
 -- in real program I'd like to choose between 
 -- different fold methods, based on some IO context
 return fold
 
 useFold :: Monad m = ((Int - m ()) - m ()) - m ()
 useFold fold' = fold' f
 where f _ = return () -- some trivial iterator
 
 main = do
 fold'' - selectFold some-method-id
 print $ runST $ useFold fold''
 
 
 Thank you!
 Dmitry
 ___
 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] How can I avoid buffered reads?

2012-11-28 Thread Bardur Arantsson
On 11/28/2012 08:38 PM, Leon Smith wrote:
 I have some code that reads (infrequently) small amounts of data from
 /dev/urandom,  and because this is pretty infrequent,  I simply open the
 handle and close it every time I need some random bytes.
 
 The problem is that I recently discovered that,  thanks to buffering within
 GHC,   I was actually reading 8096 bytes when I only need 16 bytes,  and
 thus wasting entropy.   Moreover  calling hSetBuffering  handle NoBuffering
 did not change this behavior.
 
 I'm not sure if this behavior is a bug or a feature,  but in any case it's
 unacceptable for dealing with /dev/urandom.   Probably the simplest way to
 fix this is to write a little C helper function that will read from
 /dev/urandom for me,  so that I have precise control over the system calls
 involved. But I'm curious if GHC can manage this use case correctly;
 I've just started digging into the GHC.IO code myself.
 

Use openFd, fdReadBuf and closeFd from the System.Posix.IO.ByteString
module in the 'unix' package.

Those correspond directly to system calls and are thus unbuffered.


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


Re: [Haskell-cafe] delete http://www.haskell.org/haskellwiki/Haskell_IDE

2012-11-28 Thread Roman Beslik

A humble link What links here to the right will help you find those pages.

On 28.11.12 21:53, Brent Yorgey wrote:

is probably not a good idea anyway -- what if there are other pages
that link to it?



On Wed, Nov 28, 2012 at 07:08:16PM +0200, Roman Beslik wrote:

Hi. There is more verbose page
http://www.haskell.org/haskellwiki/IDEs . I registered on
http://www.haskell.org/haskellwiki/ , but have not found the Delete
Page command, wiki software help pages, or feedback channel, so I'm
writing here.


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


Re: [Haskell-cafe] delete http://www.haskell.org/haskellwiki/Haskell_IDE

2012-11-28 Thread Gwern Branwen
On Wed, Nov 28, 2012 at 3:24 PM, Roman Beslik rabes...@gmail.com wrote:
 A humble link What links here to the right will help you find those pages.

Only for wikipages, nowhere else on the Internet.

-- 
gwern
http://www.gwern.net

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


Re: [Haskell-cafe] Can a GC delay TCP connection formation?

2012-11-28 Thread Jeff Shaw

On 11/27/2012 4:59 PM, Nicolas Wu wrote:
Hi, I'm the maintainer of HDBC. I haven't yet released this code since 
it hasn't yet been fully tested. However, if you're happy with it, 
I'll push the version with proper ffi bindings up to Hackage. Nick 

Nick,
I pulled the latest version of HDBC-odbc, and it appears to be working 
MUCH better than before. I now have 0% timeouts from httperf with 50 
connections/second and timeout set to 0.1 seconds. It's looking like the 
safe imports vastly improved IO blocking. I haven't seen any new 
problems since the new version went live.


Jeff

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


Re: [Haskell-cafe] How can I avoid buffered reads?

2012-11-28 Thread Leon Smith
Quite possibly,  entropy does seem to be a pretty lightweight dependency...

Though doesn't recent kernels use rdrand to seed /dev/urandom if it's
available?   So /dev/urandom is the most portable source of random numbers
on unix systems,  though rdrand does have the advantage of avoiding system
calls,  so it certainly would be preferable, especially if you need large
numbers of random numbers.

Best,
Leon

On Wed, Nov 28, 2012 at 2:45 PM, Thomas DuBuisson 
thomas.dubuis...@gmail.com wrote:

 As an alternative, If there existed a Haskell package to give you fast
 cryptographically secure random numbers or use the new Intel RDRAND
 instruction (when available) would that interest you?

 Also, what you are doing is identical to the entropy package on
 hackage, which probably suffers from the same bug/performance issue.

 Cheers,
 Thomas

 On Wed, Nov 28, 2012 at 11:38 AM, Leon Smith leon.p.sm...@gmail.com
 wrote:
  I have some code that reads (infrequently) small amounts of data from
  /dev/urandom,  and because this is pretty infrequent,  I simply open the
  handle and close it every time I need some random bytes.
 
  The problem is that I recently discovered that,  thanks to buffering
 within
  GHC,   I was actually reading 8096 bytes when I only need 16 bytes,  and
  thus wasting entropy.   Moreover  calling hSetBuffering  handle
 NoBuffering
  did not change this behavior.
 
  I'm not sure if this behavior is a bug or a feature,  but in any case
 it's
  unacceptable for dealing with /dev/urandom.   Probably the simplest way
 to
  fix this is to write a little C helper function that will read from
  /dev/urandom for me,  so that I have precise control over the system
 calls
  involved. But I'm curious if GHC can manage this use case correctly;
  I've just started digging into the GHC.IO code myself.
 
  Best,
  Leon
 
  {-# LANGUAGE BangPatterns, ViewPatterns #-}
 
  import   Control.Applicative
  import   Data.Bits
  import   Data.Word(Word64)
  import qualified Data.ByteString as S
  import qualified Data.ByteString.Lazy as L
  import   Data.ByteString.Internal (c2w)
  import qualified System.IOas IO
  import qualified Data.Binary.Getas Get
 
  showHex :: Word64 - S.ByteString
  showHex n = s
where
  (!s,_) = S.unfoldrN 16 f n
 
  f n = Just (char (n `shiftR` 60), n `shiftL` 4)
 
  char (fromIntegral - i)
| i  10= (c2w '0' -  0) + i
| otherwise = (c2w 'a' - 10) + i
 
  twoRandomWord64s :: IO (Word64,Word64)
  twoRandomWord64s = IO.withBinaryFile /dev/urandom IO.ReadMode $
 \handle -
  do
 IO.hSetBuffering handle IO.NoBuffering
 Get.runGet ((,) $ Get.getWord64host * Get.getWord64host) $
 L.hGet
  handle 16
 
  main = do
 (x,y) - twoRandomWord64s
 S.hPutStrLn IO.stdout (S.append (showHex x) (showHex y))
 
 
  {- Relevant part of strace:
 
  open(/dev/urandom, O_RDONLY|O_NOCTTY|O_NONBLOCK) = 3
  fstat(3, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 9), ...}) = 0
  ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7367e528) = -1 EINVAL
 (Invalid
  argument)
  ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7367e528) = -1 EINVAL
 (Invalid
  argument)
  read(3,
 
 N\304\4\367/\26c\\3218\237f\214yKg~i\310\r\262\\224H\340y\n\376V?\265\344...,
  8096) = 8096
  close(3)= 0
 
  -}
 
 
  ___
  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] How can I avoid buffered reads?

2012-11-28 Thread Vincent Hanquez

On 11/28/2012 09:31 PM, Leon Smith wrote:
Quite possibly,  entropy does seem to be a pretty lightweight 
dependency...


Though doesn't recent kernels use rdrand to seed /dev/urandom if it's 
available?   So /dev/urandom is the most portable source of random 
numbers on unix systems,  though rdrand does have the advantage of 
avoiding system calls,  so it certainly would be preferable, 
especially if you need large numbers of random numbers.
There's no much information on this i think, but if you need large 
number of random numbers you should build a PRNG yourself on top of the 
best random seed you can get, and make sure you reseed your prng 
casually with more entropy bytes. Also if

you don't have enough initial entropy, you should block.

/dev/urandom is not the same thing on every unix system. leading to 
various assumptions broken when varying the unixes. It also varies with 
the hardware context: for example on an embedded or some virtualized 
platform, giving you really terrible entropy.


--
Vincent

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


Re: [Haskell-cafe] Can a GC delay TCP connection formation?

2012-11-28 Thread Nicolas Wu
On Wed, Nov 28, 2012 at 8:36 PM, Jeff Shaw shawj...@gmail.com wrote:
 On 11/27/2012 4:59 PM, Nicolas Wu wrote:
 I pulled the latest version of HDBC-odbc, and it appears to be working MUCH
 better than before. I now have 0% timeouts from httperf with 50
 connections/second and timeout set to 0.1 seconds. It's looking like the
 safe imports vastly improved IO blocking. I haven't seen any new problems
 since the new version went live.

That's great to hear! I'll aim to push this version to Hackage over the weekend.

Nick

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


Re: [Haskell-cafe] How can I avoid buffered reads?

2012-11-28 Thread Leon Smith
If you have rdrand,  there is no need to build your own PRNG on top of
rdrand.   RdRand already incorporates one so that it can produce random
numbers as fast as they can be requested,  and this number is continuously
re-seeded with the on-chip entropy source.

It would be nice to have a little more information about /dev/urandom and
how it varies by OS and hardware,   but on Linux and FreeBSD at least it's
supposed to be a cryptographically secure RNG that incorporates a PRNG to
produce numbers in case you exhaust the entropy pool.

On Wed, Nov 28, 2012 at 5:00 PM, Vincent Hanquez t...@snarc.org wrote:

 On 11/28/2012 09:31 PM, Leon Smith wrote:

 Quite possibly,  entropy does seem to be a pretty lightweight
 dependency...

 Though doesn't recent kernels use rdrand to seed /dev/urandom if it's
 available?   So /dev/urandom is the most portable source of random numbers
 on unix systems,  though rdrand does have the advantage of avoiding system
 calls,  so it certainly would be preferable, especially if you need large
 numbers of random numbers.

 There's no much information on this i think, but if you need large number
 of random numbers you should build a PRNG yourself on top of the best
 random seed you can get, and make sure you reseed your prng casually with
 more entropy bytes. Also if
 you don't have enough initial entropy, you should block.

 /dev/urandom is not the same thing on every unix system. leading to
 various assumptions broken when varying the unixes. It also varies with the
 hardware context: for example on an embedded or some virtualized platform,
 giving you really terrible entropy.

 --
 Vincent

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


Re: [Haskell-cafe] Can a GC delay TCP connection formation?

2012-11-28 Thread Neil Davies
No - the difference is 6.5ms each way



On 28 Nov 2012, at 14:44, Alexander Kjeldaas alexander.kjeld...@gmail.com 
wrote:

 
 Jeff, this is somewhat off topic, but interesting.  Are telehouse and AWS 
 physically close?  Was this latency increase not expected due to geography?
 
 Alexander
 
 On 28 November 2012 06:21, Neil Davies semanticphilosop...@gmail.com wrote:
 Jeff
 
 Are you certain that all the delay can be laid at the GHC runtime?
 
 How much of the end-to-end delay budget is being allocated to you? I recently 
 moved a static website from a 10-year old server in telehouse into AWS in 
 Ireland and watched the access time (HTTP GET to check time on top index 
 page) increase by 150ms.
 
 Neil
 
 On 27 Nov 2012, at 19:02, Jeff Shaw shawj...@gmail.com wrote:
 
  Hello Timothy and others,
  One of my clients hosts their HTTP clients in an Amazon cloud, so even when 
  they turn on persistent HTTP connections, they use many connections. 
  Usually they only end up sending one HTTP request per TCP connection. My 
  specific problem is that they want a response in 120 ms or so, and at times 
  they are unable to complete a TCP connection in that amount of time. I'm 
  looking at on the order of 100 TCP connections per second, and on the order 
  of 1000 HTTP requests per second (other clients do benefit from persistent 
  HTTP connections).
 
  Once each minute, a thread of my program updates a global state, stored in 
  an IORef, and updated with atomicModifyIORef', based on query results via 
  HDBC-obdc. The query results are strict, and atomicModifyIORef' should 
  receive the updated state already evaluated. I reduced the amount of time 
  that query took from tens of seconds to just a couple, and for some reason 
  that reduced the proportion of TCP timeouts drastically. The approximate 
  before and after TCP timeout proportions are 15% and 5%. I'm not sure why 
  this reduction in timeouts resulted from the query time improving, but this 
  discovery has me on the task of removing all database code from the main 
  program and into a cron job. My best guess is that HDBC-odbc somehow 
  disrupts other communications while it waits for the DB server to respond.
 
  To respond to Ertugrul, I'm compiling with -threaded, and running with +RTS 
  -N.
 
  I hope this helps describe my problem. I c an probably come up with some 
  hard information if requested, E.G. threadscope.
 
  Jeff
 
  On 11/27/2012 10:55 AM, timothyho...@seznam.cz wrote:
  Could you give us more info on what your constraints are?  Is it necessary 
  that you have a certain number of connections per second, or is it 
  necessary that the connection results very quickly after some other 
  message is received?
 
 
  ___
  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


[Haskell-cafe] A big hurray for lambda-case (and all the other good stuff)

2012-11-28 Thread Ben Franksen
Hi Everyone

just wanted to drop by to say how much I like the new lambda case extension. 
I use it all the time and I just *love* how it relieves me from conjuring up 
dummy variables, which makes teh code not only esier to write but also to 
read.

A big, huge thank you to the ghc developers. This has been so long on my 
wish list.

Also much appreciated and long awaited: tuple sections (though I use them 
not quite as often).

Both should *definitely* go into Haskell'13.

Of course, thank you also for all the other beautiful stuff in ghc-7.6.1, 
especially PolyKinds, DataKinds etc.

GHC is just simply amazing. You guys RULE THE WORLD!

Cheers
-- 
Ben Franksen
()  ascii ribbon campaign - against html e-mail 
/\  www.asciiribbon.org   - against proprietary attachments


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


Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-11-28 Thread Ben Franksen
Tony Morris wrote:
 As a side note, I think a direct superclass of Functor for Monad is not
 a good idea, just sayin'
 
 class Functor f where
   fmap :: (a - b) - f a - f b
 
 class Functor f = Apply f where
   (*) :: f (a - b) - f a - f b
 
 class Apply f = Bind f where
   (=) :: (a - f b) - f a - f b
 
 class Apply f = Applicative f where
   unit :: a - f a
 
 class (Applicative f, Bind f) = Monad f where
 
 Same goes for Comonad (e.g. [] has (=) but not counit)
 ... and again for Monoid, Category, I could go on...

Hi Tony

even though I dismissed your mentioning this on the Haskell' list, I do have 
to admit that the proposal has a certain elegance. However, before I buy 
into this scheme, I'd like to see some striking examples for types with 
natural (or at least useful) Apply and Bind instances that cannot be made 
Applicative resp. Monad. Also, it is not clear to me what laws should hold 
for them.

Cheers
-- 
Ben Franksen
()  ascii ribbon campaign - against html e-mail 
/\  www.asciiribbon.org   - against proprietary attachments


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


Re: [Haskell-cafe] Why Kleisli composition is not in the Monad signature?

2012-11-28 Thread Ben Franksen
Dan Doel wrote:
 On Tue, Oct 16, 2012 at 10:37 AM, AUGER Cédric sedri...@gmail.com wrote:
 join IS the most important from the categorical point of view.
 In a way it is natural to define 'bind' from 'join', but in Haskell, it
 is not always possible (see the Monad/Functor problem).

 As I said, from the mathematical point of view, join (often noted μ in
 category theory) is the (natural) transformation which with return (η
 that I may have erroneously written ε in some previous mail) defines a
 monad (and requires some additionnal law).
 
 This is the way it's typically presented. Can you demonstrate that it
 is the most important presentation?
 
 I'd urge caution in doing so, too. For instance, there is a paper,
 Monads Need Not Be Endofunctors, that describes a generalization of
 monads to monads relative to another functor. And there, bind is
 necessarily primary, because join isn't even well typed. I don't think
 it's written by mathematicians per se (rather, computer
 scientists/type theorists). But mathematicians have their own
 particular interests that affect the way they frame things, and that
 doesn't mean those ways are better for everyone.

Right. Mathematical /conventions/ can and should be questioned. Sometimes 
they are not appropriate to the application domain. Sometimes the 
conventions are just stupid or obsolete even in a purely mathematical 
context (a well-known example is the extra syntax sugar for binomial 
coefficients, but there are worse ones), and you still find them in modern 
text books. Talk about backwards compatibility...

My preference for Kleisli composition is because it makes the monad laws so 
much easier to write down and understand. Everywhere it is said that = 
must be associative and then the laws are written down for = and return 
and it is very hard to see what this lambda grave has to do with 
associativity or units. When I started with Haskell, this was all I could 
find. It was years later that I stumbled over a text that explained it with 
= and suddenly it all became simple and clear and I finally understood the 
monad laws!

So, maybe = is the better primitive operation w.r.t. implementation, but 
IMO = is *much* more efficient w.r.t. understanding the monad laws. Since 
it is natural to explain the laws of a class using only class methods, I 
would prefer if = was added to the class with default implementations for 
= in terms of = and vice versa, so that you can still use = as the 
primitive operation when implementing an instance.

Cheers
-- 
Ben Franksen
()  ascii ribbon campaign - against html e-mail 
/\  www.asciiribbon.org   - against proprietary attachments


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


Re: [Haskell-cafe] delete http://www.haskell.org/haskellwiki/Haskell_IDE

2012-11-28 Thread Conrad Parker
On 29 November 2012 01:08, Roman Beslik rabes...@gmail.com wrote:
 Hi. There is more verbose page http://www.haskell.org/haskellwiki/IDEs . I
 registered on http://www.haskell.org/haskellwiki/ , but have not found the
 Delete Page command, wiki software help pages, or feedback channel, so I'm
 writing here.

I think the right thing to do is replace the page contents with:

#REDIRECT [[IDEs]]

Conrad.

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


[Haskell-cafe] Haskell Weekly News: Issue 252

2012-11-28 Thread Daniel Santa Cruz
Welcome to issue 252 of the HWN, an issue covering crowd-sourced bits
of information about Haskell from around the web. This issue covers the
week of November 18 to 24, 2012.

Quotes of the Week

   * rwbarton: edwardk now has Lens under Control

   * atriq: My son looks a bit like me, he can put away the plates after
 dinner now thanks to edwardk!

   * mgsloan: Lens got 99 operators, but a (|) ain't one.

   * hiptobecubic: I feel like this program is just a bunch of glue and
 duct tape holding a bottle of nitroglycerine off of the ground.

   * xplat: Some software is worth trying; most is just plain trying.

   * edwardk: Control.Lens is my secret ploy to get everyone to give up
 on Haskell and just move on to Agda as they find the Haskell types
 too complicated by comparison.

   * rwbarton: alpha reduction is what happens when you let edwardk
 maintain your module

   * edwardk: er that was a tongue sticking out, not an operator
 suggestion

Top Reddit Stories

   * [Haskell] Leaving Microsoft
 Domain: haskell.org, Score: 139, Comments: 24
 On Reddit: [1] http://goo.gl/DnzZF
 Original: [2] http://goo.gl/eVcXi

   * Help Nikki (Game written in Haskell) jump on Steam!
 Domain: joyridelabs.de, Score: 77, Comments: 8
 On Reddit: [3] http://goo.gl/EzLh8
 Original: [4] http://goo.gl/H84Nl

   * Gaussian distributions are monoids
 Domain: izbicki.me, Score: 46, Comments: 24
 On Reddit: [5] http://goo.gl/i4keo
 Original: [6] http://goo.gl/C0gnN

   * Getting Started with Lenses
 Domain: newartisans.com, Score: 42, Comments: 32
 On Reddit: [7] http://goo.gl/nv4ab
 Original: [8] http://goo.gl/h2zCa

   * Designing the Haskell IDE
 Domain: fpcomplete.com, Score: 41, Comments: 112
 On Reddit: [9] http://goo.gl/yz1Rf
 Original: [10] http://goo.gl/gpJd7

   * Putting haskell down
 Domain: b7j0c.org, Score: 33, Comments: 279
 On Reddit: [11] http://goo.gl/8JWmr
 Original: [12] http://goo.gl/tZcbj

   * London Haskell Video (24-Oct-2012) – Why Do Monads Matter?
 Domain: youtube.com, Score: 33, Comments: 5
 On Reddit: [13] http://goo.gl/uWH6w
 Original: [14] http://goo.gl/KqDji

   * Combinatorial species definition (Brent Yorgey)
 Domain: byorgey.wordpress.com, Score: 31, Comments:
 On Reddit: [15] http://goo.gl/0llrA
 Original: [16] http://goo.gl/PWIep

   * PhD Positions in Functional Programming at Chalmers
 (appl. deadline 2012-12-12)
 Domain: chalmers.se, Score: 28, Comments:
 On Reddit: [17] http://goo.gl/WAmYP
 Original: [18] http://goo.gl/JenYO

   * Video of the presentations at the first NYC Haskell User's Group
meetup.
 Domain: vimeo.com, Score: 25, Comments: 10
 On Reddit: [19] http://goo.gl/rxN75
 Original: [20] http://goo.gl/uV4wc

Top StackOverflow Questions

   * Where to start with dependent type programming?
 votes: 16, answers: 1
 Read on SO: [21] http://goo.gl/HXdOu

   * What other ways can state be handled in a pure functional
 language besides with Monads?
 votes: 13, answers: 3
 Read on SO: [22] http://goo.gl/D86hV

   * Why are some Prelude functions defined in terms of foldl?
 votes: 8, answers: 3
 Read on SO: [23] http://goo.gl/wewrb

   * cabal FFI dependency
 votes: 8, answers: 1
 Read on SO: [24] http://goo.gl/JFtJM

   * How to write Ctrl-C handler in Haskell?
 votes: 7, answers: 1
 Read on SO: [25] http://goo.gl/pS651

   * Why does the 2-tuple Functor instance only apply the function
 to the second element?
 votes: 5, answers: 2
 Read on SO: [26] http://goo.gl/qGgSv

   * Type Families with GHC.Generics or Data.Data
 votes: 5, answers: 0
 Read on SO: [27] http://goo.gl/mERdP

   * Haskell Programmatically/Dynamically Define Functions
 votes: 5, answers: 6
 Read on SO: [28] http://goo.gl/22Wf0

   * is this implementation of merge sort good?
 votes: 5, answers: 1
 Read on SO: [29] http://goo.gl/Skznl

   * Railroad diagrams for Haskell?
 votes: 5, answers: 1
 Read on SO: [30] http://goo.gl/ZeJa9

   * Is FRP a proper way to implement most “event-driven” things?
 votes: 5, answers: 1
 Read on SO: [31] http://goo.gl/QglPp

   * Stack overflow in very simple code
 votes: 5, answers: 1
 Read on SO: [32] http://goo.gl/wB0kg

   * Mapping over Either's Left
 votes: 5, answers: 3
 Read on SO: [33] http://goo.gl/oJX4v

   * Haskell - strict vs non-strict with foldl
 votes: 5, answers: 2
 Read on SO: [34] http://goo.gl/3ElzK


Until next time,
Daniel Santa Cruz

References

   1. http://www.haskell.org/pipermail/haskell/2012-November/023566.html
   2.
http://www.reddit.com/r/haskell/comments/13m8eu/haskell_leaving_microsoft/
   3. http://joyridelabs.de/blog/?p=1548
   4.
http://www.reddit.com/r/haskell/comments/13muex/help_nikki_game_written_in_haskell_jump_on_steam/
   5. http://izbicki.me/blog/gausian-distributions-are-monoids