Re: [Haskell-cafe] adding the elements of two lists

2012-03-29 Thread David Fox
On Sun, Mar 25, 2012 at 5:06 AM, Michael Snoyman mich...@snoyman.com wrote: On Sun, Mar 25, 2012 at 2:01 PM, TP paratribulati...@free.fr wrote: Hello, My primary problem may be reduced to adding elements of two lists: [1,2,3] + [4,5,6] = [5,7,9] My first idea was to declare a list of Int as

[Haskell-cafe] a code that cannot compile with or without NoMonomorphismRestriction

2012-03-29 Thread Ting Lei
Hi I have met a piece of code that cannot be compiled whether I add or remove the NoMonomorphismRestriction flag (as of GHC 7.0.4, Haskell platform 2011.4.0.0).I have extracted a minimal example below: {-# LANGUAGE NoMonomorphismRestriction #-} (f1, f2) = let commond_definitions =

Re: [Haskell-cafe] adding the elements of two lists

2012-03-29 Thread Ketil Malde
Richard O'Keefe o...@cs.otago.ac.nz writes: newtype PS a = PS [a] deriving (Eq, Show) u f (PS x)= PS $ map f x b f (PS x) (PS y) = PS $ zipWith f x y to_ps x = PS (x : repeat 0) BTW, isn't this a good candidate for an Applicative instance (similar to ZipList)? u f p

Re: [Haskell-cafe] Fail-back monad

2012-03-29 Thread oleg
Alberto G. Corona wrote about a monad to set a checkpoint and be able to repeatedly go to that checkpoint and re-execute the computations following the checkpoint. http://haskell-web.blogspot.com.es/2012/03/failback-monad.html The typical example is as follows. test= runBackT $ do

Re: [Haskell-cafe] Google Summer of Code - Lock-free data structures

2012-03-29 Thread Heinrich Apfelmus
Florian Hartwig wrote: Hi everyone, I would like to do the GSoC project outlined in http://hackage.haskell.org/trac/summer-of-code/ticket/1608 One of Haskell's great strengths is its support for all kinds of concurrent and parallel programmming, so I think that the Haskell ecosystem would

Re: [Haskell-cafe] Google Summer of Code - Lock-free data structures

2012-03-29 Thread Eugene Kirpichov
Though of course you can implement CAS in terms of STM, CAS is much more low-level and will probably be many times (though not asymptotically) faster. On Thu, Mar 29, 2012 at 12:01 PM, Heinrich Apfelmus apfel...@quantentunnel.de wrote: Florian Hartwig wrote: Hi everyone, I would like to do

Re: [Haskell-cafe] a code that cannot compile with or without NoMonomorphismRestriction

2012-03-29 Thread Ketil Malde
Ting Lei tin...@hotmail.com writes: (f1, f2) = let commond_definitions = undefined in let f1 = id.show f2 x = ( x) in (f1, f2) I think the type signatures should be: f1 :: Show a = a - String and f2 :: Ord b = b - b - Bool When I define these

Re: [Haskell-cafe] Google Summer of Code - Lock-free data structures

2012-03-29 Thread Florian Hartwig
On 29 March 2012 05:57, Ryan Newton rrnew...@gmail.com wrote: I just read in your proposal that you started looking into the casMutArray# issue as well.  How far have you gotten with that?  Do you want to work on this together a bit? I've got an implementation of a casArray# primop that

Re: [Haskell-cafe] Google Summer of Code - Lock-free data structures

2012-03-29 Thread Florian Hartwig
On 29 March 2012 at 12:01 PM, Heinrich Apfelmus apfelmus at quantentunnel.de wrote: Since I don't know much about concurrency, I have a simple question: what is the difference between atomic compare-and-swap and software transactional memory? Both are lock-free? Well, terminology-wise it would

Re: [Haskell-cafe] a code that cannot compile with or without NoMonomorphismRestriction

2012-03-29 Thread Heinrich Apfelmus
Ketil Malde wrote: Ting Lei tin...@hotmail.com writes: (f1, f2) = let commond_definitions = undefined in let f1 = id.show f2 x = ( x) in (f1, f2) I think the type signatures should be: f1 :: Show a = a - String and f2 :: Ord b = b - b - Bool When I

Re: [Haskell-cafe] Google Summer of Code - Lock-free data structures

2012-03-29 Thread Heinrich Apfelmus
Florian Hartwig wrote: Heinrich Apfelmus wrote: So while the two are related, CAS is a machine primitive that works for a single operation and on a single word while STM is a software abstraction that isolates sequences of operations on multiple memory locations from each other. Is it

Re: [Haskell-cafe] Google Summer of Code - Lock-free data structures

2012-03-29 Thread Gregory Collins
On Thu, Mar 29, 2012 at 6:57 AM, Ryan Newton rrnew...@gmail.com wrote: The ByteArray versions will be more annoying, requiring more variations, but they are also less essential, because the user can always use ForeignPtr and bits-atomic in this case, and I believe for our concurrent data

Re: [Haskell-cafe] Google Summer of Code - Lock-free data structures

2012-03-29 Thread Ryan Newton
On Thu, Mar 29, 2012 at 9:01 AM, Gregory Collins g...@gregorycollins.netwrote: On Thu, Mar 29, 2012 at 6:57 AM, Ryan Newton rrnew...@gmail.com wrote: The ByteArray versions will be more annoying, requiring more variations, but they are also less essential, because the user can always use

Re: [Haskell-cafe] Google Summer of Code - Lock-free data structures

2012-03-29 Thread Ryan Newton
I think so. Atomically reading and writing a single memory location (which CAS does) is just a very simple transaction. But using a CAS instruction should be more efficient, since STM has to maintain a transaction log and commit transactions, which creates some overhead. Ah, I see. In that

Re: [Haskell-cafe] Google Summer of Code - Lock-free data structures

2012-03-29 Thread Tim Harris (RESEARCH)
Hi, Somewhat related to this... Next month we have a paper coming up at EuroSys about a middle-ground between using STM and programming directly with CAS: http://research.microsoft.com/en-us/um/people/tharris/papers/2012-eurosys.pdf This was done in the context of shared memory data

Re: [Haskell-cafe] adding the elements of two lists

2012-03-29 Thread Doug McIlroy
From: Richard O'Keefe o...@cs.otago.ac.nz Date: Thu, 29 Mar 2012 16:34:46 +1300 On 29/03/2012, at 3:08 PM, Doug McIlroy wrote: - without newtype toSeries f = f : repeat 0 -- coerce scalar to series instance Num a = Num [a] where (f:fs) + (g:gs) = f+g : fs+gs

Re: [Haskell-cafe] a code that cannot compile with or without NoMonomorphismRestriction

2012-03-29 Thread Haisheng Wu
I think the error message tell you how to fix: use -XNoMonomorphismRestriction One approach is add following line into top of your hs file and it works for me. {-# LANGUAGE NoMonomorphismRestriction #-} Regarding the deeper reason, I think you would be able to find via GHC user guide and

Re: [Haskell-cafe] a code that cannot compile with or without NoMonomorphismRestriction

2012-03-29 Thread Ting Lei
Ketil, Thanks for the response. It seems that defining them as a pair only postphones the error.GHC will give an error when you extract the components of the pair, no matter whether you addthe NoMonomorphismRestriction flag or not. --{-# LANGUAGE NoMonomorphismRestriction #-}p :: (Show a, Ord

[Haskell-cafe] Is this a correct explanation of FRP?

2012-03-29 Thread Peter Minten
Hi, I've been trying to get my head around Functional Reactive Programming by writing a basic explanation of it, following the logic that explaining something is the best way to understand it. Am I on the right track with this explanation? Greetings, Peter Minten P.S. Sorry about the long

Re: [Haskell-cafe] Mathematics and Statistics libraries

2012-03-29 Thread Carter Tazio Schonwald
Hey All, Theres actually a number of issues the come up with an effective dataframe-like for haskell, and data vis as well. (both of which I have some strong personal opinions on for haskell and which I'm exploring / experimenting with this spring). While folks have touched on a bunch, I just

Re: [Haskell-cafe] adding the elements of two lists

2012-03-29 Thread Ozgur Akgun
On 29 March 2012 04:34, Richard O'Keefe o...@cs.otago.ac.nz wrote: u f (PS x)= PS $ map f x b f (PS x) (PS y) = PS $ zipWith f x y to_ps x = PS (x : repeat 0) Also see: http://hackage.haskell.org/package/newtype -- Ozgur Akgun

[Haskell-cafe] ANN: Happstack 7

2012-03-29 Thread Jeremy Shaw
We are pleased to announce the release of Happstack 7! Happstack is a fast, modern, web application framework written in Haskell. Please check out the brand new happstack.com website to read about what is new in Happstack 7, and what we are planning for Happstack 8, and what makes Happstack

Re: [Haskell-cafe] for = flip map

2012-03-29 Thread Sjoerd Visscher
Some more bikeshedding: Perhaps ffor, as in ffor = flip fmap or perhaps infixr 0 $$ ($$) = flip ($) xs $$ \x - ... (cf. **) In both cases they should go in Data.Functor Sjoerd On Mar 28, 2012, at 11:26 PM, e...@ezrakilty.net wrote: I would very much like to see a

Re: [Haskell-cafe] winhugs interrupts

2012-03-29 Thread Henk-Jan van Tuyl
On Wed, 28 Mar 2012 22:42:58 +0200, Doug McIlroy d...@cs.dartmouth.edu wrote: On windows I have long used hugs under cygwin, but hugs doesn't get along well with cygwin's latest terminal emulator. So I switched to winhugs. Small problem that looms big: how do you interrupt an interminable

Re: [Haskell-cafe] for = flip map

2012-03-29 Thread Thomas Schilling
On 29 March 2012 22:03, Sjoerd Visscher sjo...@w3future.com wrote: Some more bikeshedding: Perhaps ffor, as in    ffor = flip fmap or perhaps    infixr 0 $$    ($$) = flip ($)    xs $$ \x - ... I don't think it makes sense to add a whole new operator for that. You can just use

Re: [Haskell-cafe] Google Summer of Code - Lock-free data

2012-03-29 Thread John Lato
Slightly related: I think it would be interesting to compare a Disruptor-based concurrency communications mechanism and compare it to e.g. TChans 1. Disruptor - http://code.google.com/p/disruptor/ From: Ryan Newton rrnew...@gmail.com I think so. Atomically reading and writing a single memory

Re: [Haskell-cafe] Is this a correct explanation of FRP?

2012-03-29 Thread Ertugrul Söylemez
Peter Minten peter.min...@orange.nl wrote: I've been trying to get my head around Functional Reactive Programming by writing a basic explanation of it, following the logic that explaining something is the best way to understand it. Am I on the right track with this explanation? You are

[Haskell-cafe] How helpful is h-99 (and should we complete the missing ones)?

2012-03-29 Thread Ziyao Wei
Hi all, I am new at Haskell, but I am trying to learn as much as possible. While learning, I noticed that h-99 (the 99 Haskell problems) are highly recommended on haskell.org. However, the answers to the 99 problems are not finished, and some of the answers are not really Haskell-ish. So here's