Re: [Haskell-cafe] A question about laziness and performance in document serialization.

2013-08-22 Thread Roman Cheplyaka
* Kyle Hanson hanoo...@gmail.com [2013-08-20 18:23:48-0700] So I am not entirely clear on how to optimize for performance for lazy bytestrings. Currently I have a (Lazy) Map that contains large BSON values (more than 1mb when serialized each). I can serialize BSON documents to Lazy

[Haskell-cafe] A question about laziness and performance in document serialization.

2013-08-20 Thread Kyle Hanson
of bytestings so I have another Map object that has the serialized bytestrings that I populate it with every time the original BSON Map changes. Should the map be strict or lazy? Should the bytestrings it stores be strict or lazy? Any help in understanding laziness would be appreciated. -- Kyle Hanson

Re: [Haskell-cafe] Either Monad and Laziness

2012-09-18 Thread Malcolm Wallace
On 12 Sep 2012, at 16:04, Eric Velten de Melo wrote: The behaviour I want to achieve is like this: I want the program when compiled to read from a file, parsing the PGM and at the same time apply transformations to the entries as they are read and write them back to another PGM file. Such

Re: [Haskell-cafe] Either Monad and Laziness

2012-09-17 Thread John Lato
Subject: Re: [Haskell-cafe] Either Monad and Laziness On 9/14/12 5:16 PM, Eric Velten de Melo wrote: But now I'm kinda lost. Is there an easy way to explain the difference between: -iteratee -conduit -enumerator I tend to group them into three families. 'iteratee' and 'enumerator

Re: [Haskell-cafe] Either Monad and Laziness

2012-09-16 Thread wren ng thornton
On 9/14/12 5:16 PM, Eric Velten de Melo wrote: But now I'm kinda lost. Is there an easy way to explain the difference between: -iteratee -conduit -enumerator John Lato's iteratee library is the original one based on Oleg Kiselyov's work. I've used it a fair deal and am quite fond of it.

Re: [Haskell-cafe] Either Monad and Laziness

2012-09-14 Thread Eric Velten de Melo
On 13 September 2012 20:29, wren ng thornton w...@freegeek.org wrote: On 9/12/12 5:37 PM, Francesco Mazzoli wrote: At Wed, 12 Sep 2012 12:04:31 -0300, Eric Velten de Melo wrote: It would be really awesome, though, if it were possible to use a parser written in Parsec with this, in the

Re: [Haskell-cafe] Either Monad and Laziness

2012-09-13 Thread wren ng thornton
On 9/12/12 5:37 PM, Francesco Mazzoli wrote: At Wed, 12 Sep 2012 12:04:31 -0300, Eric Velten de Melo wrote: It would be really awesome, though, if it were possible to use a parser written in Parsec with this, in the spirit of avoiding code rewriting and enhancing expressivity and abstraction.

[Haskell-cafe] Either Monad and Laziness

2012-09-12 Thread oleg
I am currently trying to rewrite the Graphics.Pgm library from hackage to parse the PGM to a lazy array. Laziness and IO really do not mix. The problem is that even using a lazy array structure, because the parser returns an Either structure it is only possible to know if the parser

Re: [Haskell-cafe] Either Monad and Laziness

2012-09-12 Thread Eric Velten de Melo
array. Laziness and IO really do not mix. The problem is that even using a lazy array structure, because the parser returns an Either structure it is only possible to know if the parser was successful or not after the whole file is read, That is one of the problems. Unexpected memory blowups

Re: [Haskell-cafe] Either Monad and Laziness

2012-09-12 Thread Eric Velten de Melo
to rewrite the Graphics.Pgm library from hackage to parse the PGM to a lazy array. Laziness and IO really do not mix. The problem is that even using a lazy array structure, because the parser returns an Either structure it is only possible to know if the parser was successful or not after

Re: [Haskell-cafe] Either Monad and Laziness

2012-09-12 Thread Francesco Mazzoli
At Wed, 12 Sep 2012 12:04:31 -0300, Eric Velten de Melo wrote: It would be really awesome, though, if it were possible to use a parser written in Parsec with this, in the spirit of avoiding code rewriting and enhancing expressivity and abstraction. There is

[Haskell-cafe] Either Monad and Laziness

2012-09-11 Thread Eric Velten de Melo
the whole file is read, therefore requiring it to read the entire file before applying the transformations, ruining the property of laziness. Is there some way to keep this from happening? Should I even want to make it like this? Not really a real life situation, but imagine I want to read a really

Re: [Haskell-cafe] Either Monad and Laziness

2012-09-11 Thread Evan Laforge
On Tue, Sep 11, 2012 at 9:36 AM, Eric Velten de Melo ericvm...@gmail.com wrote: Any thoughts? Hopefully I'm not saying anything really stupid. You can intersperse decoding errors in the output, e.g. output is [Either Error DecodedChunk]. Then all the processors have to deal with it, but if you

Re: [Haskell-cafe] Either Monad and Laziness

2012-09-11 Thread timothyhobbs
Use a tuple: (Result,Maybe Error) rather than an Either.  Do everything lazily, and in the case of an error, undo the result. -- Původní zpráva -- Od: Eric Velten de Melo ericvm...@gmail.com Datum: 11. 9. 2012 Předmět: [Haskell-cafe] Either Monad and Laziness Hello, I am

Re: [Haskell-cafe] Hierarchical tracing for debugging laziness

2012-01-26 Thread Yves Parès
One day, I _really_ should learn all GHCI commands... Thanks, Felipe ^^ 2012/1/25 Felipe Almeida Lessa felipe.le...@gmail.com On Wed, Jan 25, 2012 at 7:38 PM, Yves Parès yves.pa...@gmail.com wrote: But I haven't found a way to tell GHCI to fully evaluate 'x' but _not_ print its value.

Re: [Haskell-cafe] Hierarchical tracing for debugging laziness

2012-01-25 Thread Eugene Kirpichov
Thanks! I released it: http://hackage.haskell.org/package/htrace http://github.com/jkff/htrace On Wed, Jan 25, 2012 at 4:18 AM, Felipe Almeida Lessa felipe.le...@gmail.com wrote: Really nice! Looks like it could be a useful mini-package on Hackage. -- Felipe. -- Eugene Kirpichov

Re: [Haskell-cafe] Hierarchical tracing for debugging laziness

2012-01-25 Thread Claus Reinke
Look how one can watch the evaluation tree of a computation, to debug laziness-related problems. You might like the old Hood/GHood: http://hackage.haskell.org/package/hood http://hackage.haskell.org/package/GHood Background info/papers: http://www.ittc.ku.edu/csdl/fpg/Tools/Hood http

Re: [Haskell-cafe] Hierarchical tracing for debugging laziness

2012-01-25 Thread Yves Parès
Hi, nice little package! I just made a fork and added a new function makeHTrace to be able to have separate variables 'level'. I also add the htrace type signature (or else haddock won't generate documentation for this module): https://github.com/YwenP/htrace I was also investigating in a way to

Re: [Haskell-cafe] Hierarchical tracing for debugging laziness

2012-01-25 Thread Felipe Almeida Lessa
On Wed, Jan 25, 2012 at 7:38 PM, Yves Parès yves.pa...@gmail.com wrote: But I haven't found a way to tell GHCI to fully evaluate 'x' but _not_ print its value. Use the :force, Yves! let {a = htrace a 12; b = htrace b 29; c = htrace c 10; d = htrace d 90; x = htrace , (htrace + (a+b), htrace

[Haskell-cafe] Hierarchical tracing for debugging laziness

2012-01-24 Thread Eugene Kirpichov
Hi cafe, Look how one can watch the evaluation tree of a computation, to debug laziness-related problems. {-# LANGUAGE BangPatterns #-} module HTrace where import Data.List (foldl') import Data.IORef import System.IO.Unsafe level = unsafePerformIO $ newIORef 0 htrace str x = unsafePerformIO

Re: [Haskell-cafe] Hierarchical tracing for debugging laziness

2012-01-24 Thread HASHIMOTO, Yusaku
] [] : : : : : : : : : : ys [10,9,8,7,6,5,4,3,2,1] Thanks for sharing! On 25 January 2012 01:47, Eugene Kirpichov ekirpic...@gmail.com wrote: Hi cafe, Look how one can watch the evaluation tree of a computation, to debug laziness-related problems

Re: [Haskell-cafe] Hierarchical tracing for debugging laziness

2012-01-24 Thread Felipe Almeida Lessa
Really nice! Looks like it could be a useful mini-package on Hackage. -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Robert Harper on monads and laziness

2011-05-03 Thread Dominique Devriese
2011/5/3 Manuel M T Chakravarty c...@cse.unsw.edu.au: Interestingly, today (at least the academic fraction of) the Haskell community appears to hold the purity of the language in higher regard than its laziness. I find Greg Morissett's comment on Lennart Augustsson's article pro lazy

Re: [Haskell-cafe] Robert Harper on monads and laziness

2011-05-03 Thread Jan-Willem Maessen
On Tue, May 3, 2011 at 1:32 AM, Manuel M T Chakravarty c...@cse.unsw.edu.au wrote: ...  Interestingly, today (at least the academic fraction of) the Haskell community appears to hold the purity of the language in higher regard than its laziness. As someone who implemented Haskell with quite

Re: [Haskell-cafe] Robert Harper on monads and laziness

2011-05-03 Thread Dan Doel
On Tue, May 3, 2011 at 2:26 AM, Dominique Devriese dominique.devri...@cs.kuleuven.be wrote: What I find interesting is that he considers (non-)termination an effect, which Haskell does not manage to control like it does other types of effects. Dependently typed purely functional languages like

Re: [Haskell-cafe] Robert Harper on monads and laziness

2011-05-03 Thread Manuel M T Chakravarty
I completely agree that laziness enables a number of nice coding idioms and, as Lennart described so eloquently, it does facilitate a combinator-based coding style among other things: http://augustss.blogspot.com/2011/05/more-points-for-lazy-evaluation-in.html (Note that even Bob admits

[Haskell-cafe] Robert Harper on monads and laziness

2011-05-02 Thread Ketil Malde
opinion from somebody who knows a bit about the business. Recently, he had a piece on monads, and how to do them in ML, and one statement puzzled me: There is a particular reason why monads had to arise in Haskell, though, which is to defeat the scourge of laziness. My own view

Re: [Haskell-cafe] Robert Harper on monads and laziness

2011-05-02 Thread MigMit
Yes, I'm following it too, and it seems to me that Harper just allows his dislike for Haskell to take advantage of his judgement. Monads as a way to deal with laziness are a very common misconception. Отправлено с iPhone May 2, 2011, в 11:54, Ketil Malde ke...@malde.org написал(а): I'm

Re: [Haskell-cafe] Robert Harper on monads and laziness

2011-05-02 Thread Scott Turner
On 2011-05-02 03:54, Ketil Malde wrote: There is a particular reason why monads had to arise in Haskell, though, which is to defeat the scourge of laziness. I wonder if there are any other rationale for a statement like that? He spends one paragraph dismissing the usefulness

Re: [Haskell-cafe] Robert Harper on monads and laziness

2011-05-02 Thread Dominique Devriese
2011/5/2 Ketil Malde ke...@malde.org: There is a particular reason why monads had to arise in Haskell, though, which is to defeat the scourge of laziness. My own view is/was that monads were so successful in Haskell since it allowed writing flexible programs with imperative features

Re: [Haskell-cafe] Robert Harper on monads and laziness

2011-05-02 Thread Felipe Almeida Lessa
On Mon, May 2, 2011 at 9:29 AM, Dominique Devriese dominique.devri...@cs.kuleuven.be wrote: I agree with your analysis. Throughout his different articles, I think Harper partly has a point when he says that laziness brings certain disadvantages (like e.g. complex memory and CPU behaviour

Re: [Haskell-cafe] Robert Harper on monads and laziness

2011-05-02 Thread Tony Morris
the scourge of laziness. My own view is/was that monads were so successful in Haskell since it allowed writing flexible programs with imperative features, without sacrificing referential transparency. Although people are quick (and rightly so) to point out that this flexibility goes way beyond IO, I

Re: [Haskell-cafe] Robert Harper on monads and laziness

2011-05-02 Thread Manuel M T Chakravarty
Tony Morris: Interesting how I have been authoring and subsequently using monads in scala for several years and it is strictness that gets in the way more than anything. Just to make sure that I understand you correctly. You are saying that when you use monads in Scala, then strictness makes

Re: [Haskell-cafe] Robert Harper on monads and laziness

2011-05-02 Thread Manuel M T Chakravarty
the language designers. Interestingly, today (at least the academic fraction of) the Haskell community appears to hold the purity of the language in higher regard than its laziness. Manuel Ketil Malde: I'm following Harper's blog, Existential Type¹, which I find to be an enjoyable

RE: Dictionaries and full laziness transformation

2011-02-09 Thread Simon Peyton-Jones
- | From: glasgow-haskell-users-boun...@haskell.org [mailto:glasgow-haskell- | users-boun...@haskell.org] On Behalf Of Akio Takano | Sent: 07 February 2011 04:10 | To: glasgow-haskell-users@haskell.org | Subject: Dictionaries and full laziness transformation | | Hi, | | I'm using GHC 7.0.1. I found

Re: Dictionaries and full laziness transformation

2011-02-09 Thread Maciej Wos
7.27s ( 7.28s elapsed) %GC time 36.1% (36.0% elapsed) Alloc rate4,905,159,063 bytes per MUT second Productivity 63.8% of total user, 63.8% of total elapsed while compiling with -O2 and -fno-full-laziness or -O0 reverts memory usage back to constant: ./enumSequence-main +RTS -s 1

Dictionaries and full laziness transformation

2011-02-06 Thread Akio Takano
Hi, I'm using GHC 7.0.1. I found that recursive overloaded functions tend to leak memory when compiled with full-laziness optimization on. Here is a simple case. -- TestSub.hs {-# LANGUAGE BangPatterns #-} module TestSub where {-# NOINLINE factorial #-} factorial :: (Num

Re: [Haskell-cafe] Eta-expansion and existentials (or: types destroy my laziness)

2010-10-24 Thread Henning Thielemann
Max Bolingbroke schrieb: Let's start with a simple example of an existential data type: data Stream a = forall s. Stream s (s - Maybe (a, s)) I use quite the same data type for my signal processing applications: http://code.haskell.org/synthesizer/core/src/Synthesizer/State/Signal.hs You

Re: [Haskell-cafe] Re: Eta-expansion and existentials (or: types destroy my laziness)

2010-10-22 Thread Max Bolingbroke
On 19 October 2010 19:01, Dan Doel dan.d...@gmail.com wrote: However, this argument is a bit circular, since that eliminator could be defined to behave similarly to an irrefutable match. Right. Or, put another way, eta expansion of a dictionary-holding existential would result in a value

Re: [Haskell-cafe] Re: Eta-expansion and existentials (or: types destroy my laziness)

2010-10-22 Thread Dan Doel
On Friday 22 October 2010 5:48:28 am Max Bolingbroke wrote: I think evaluating dictionaries strictly is more of a want to have rather than actually implemented. In particular, GHC supports building value-recursive dictionaries - and making dictionary arguments strict indiscriminately would

Re: [Haskell-cafe] Re: Eta-expansion and existentials (or: types destroy my laziness)

2010-10-22 Thread Max Bolingbroke
On 22 October 2010 12:03, Dan Doel dan.d...@gmail.com wrote:  data Mu f = In { out :: f (Mu f) }  instance Show (f (Mu f)) = Show (Mu f) where    show = show . out Is that an example of a value recursive dictionary? Assuming the Show (f (Mu f)) instance uses the (Mu f) one, AFAIK this

[Haskell-cafe] Eta-expansion and existentials (or: types destroy my laziness)

2010-10-19 Thread oleg
Max Bolingbroke wrote: Let's start with a simple example of an existential data type: data Stream a = forall s. Stream s (s - Maybe (a, s)) ones :: Stream Int ones = cons 1 ones Unfortunately, 'ones' is just _|_! The reason is that cons is strict in its second argument. The problem I

[Haskell-cafe] Re: Eta-expansion and existentials (or: types destroy my laziness)

2010-10-19 Thread Max Bolingbroke
Hi Oleg, Thanks for your reply! Really? Here are two 'cons' that seem to satisfy all the criteria Thanks - your definitions are similar to Roman's suggestion. Unfortunately my criteria 3) is not quite what I actually wanted - I really wanted something GHC-optimisable - (so non-recursive

Re: [Haskell-cafe] Re: Eta-expansion and existentials (or: types destroy my laziness)

2010-10-19 Thread Dan Doel
On Tuesday 19 October 2010 6:16:16 am Max Bolingbroke wrote: Thanks - your definitions are similar to Roman's suggestion. Unfortunately my criteria 3) is not quite what I actually wanted - I really wanted something GHC-optimisable - (so non-recursive definitions are a necessary but not

Re: [Haskell-cafe] Eta-expansion and existentials (or: types destroy my laziness)

2010-10-17 Thread Roman Leshchinskiy
On 16/10/2010, at 12:36, Max Bolingbroke wrote: On 16 October 2010 12:16, Roman Leshchinskiy r...@cse.unsw.edu.au wrote: eta :: Stream a - Stream a eta s = Stream s next where next (Stream s next') = case next' s of Just (x,s') - Just (x,Stream s' next')

[Haskell-cafe] Eta-expansion and existentials (or: types destroy my laziness)

2010-10-16 Thread Max Bolingbroke
Hi Cafe, I've run across a problem with my use of existential data types, whereby programs using them are forced to become too strict, and I'm looking for possible solutions to the problem. I'm going to explain what I mean by using a literate Haskell program. First, the preliminaries: {-#

Re: [Haskell-cafe] Eta-expansion and existentials (or: types destroy my laziness)

2010-10-16 Thread Roman Leshchinskiy
On 16/10/2010, at 12:00, Max Bolingbroke wrote: Hi Cafe, I've run across a problem with my use of existential data types, whereby programs using them are forced to become too strict, and I'm looking for possible solutions to the problem. I'm going to explain what I mean by using a

Re: [Haskell-cafe] Eta-expansion and existentials (or: types destroy my laziness)

2010-10-16 Thread Max Bolingbroke
On 16 October 2010 12:16, Roman Leshchinskiy r...@cse.unsw.edu.au wrote: eta :: Stream a - Stream a eta s = Stream s next   where     next (Stream s next') = case next' s of                               Just (x,s') - Just (x,Stream s' next')                               Nothing     -

[Haskell-cafe] Re: Laziness bug in Data.List.intersperse (was: ANNOUNCE: text 0.8.0.0, fast Unicode text support)

2010-09-04 Thread Bryan O'Sullivan
On Wed, Sep 1, 2010 at 1:00 PM, Daniel Fischer daniel.is.fisc...@web.dewrote: I'm not keen on subscribing to libraries@ to follow the official proposal process, any takers? I'll take it up. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] Laziness bug in Data.List.intersperse (was: ANNOUNCE: text 0.8.0.0, fast Unicode text support)

2010-09-01 Thread Daniel Fischer
On Wednesday 01 September 2010 21:29:47, Daniel Fischer wrote: that's where you definitely get a space leak, because intersperse             :: a - [a] - [a] intersperse _   []      = [] intersperse _   [x]     = [x] intersperse sep (x:xs)  = x : sep : intersperse sep xs isn't lazy enough.

Re: [Haskell-cafe] Re: Laziness question

2010-08-04 Thread Nicolas Pouillard
On Tue, 03 Aug 2010 16:36:33 +0200, Janis Voigtländer j...@informatik.uni-bonn.de wrote: Nicolas Pouillard schrieb: - If there is no class instance for function types, then those problems go away, of course. But it is doubtful whether that would be a viable solution. Quite a few programs

Re: [Haskell-cafe] Re: Laziness question

2010-08-04 Thread Janis Voigtländer
Nicolas Pouillard schrieb: Actually I think we can keep the old generic seq, but cutting its full polymorphism: seq :: Typeable a = a - b - b I guess I don't know enough about Typeable to appreciate that. Basically the Typeable constraints tells that we dynamically know the identity of the

Re: [Haskell-cafe] Re: Laziness question

2010-08-04 Thread Nicolas Pouillard
On Wed, 04 Aug 2010 15:41:54 +0200, Janis Voigtländer j...@informatik.uni-bonn.de wrote: Nicolas Pouillard schrieb: Actually I think we can keep the old generic seq, but cutting its full polymorphism: seq :: Typeable a = a - b - b I guess I don't know enough about Typeable to

Re: [Haskell-cafe] Re: Laziness question

2010-08-04 Thread Janis Voigtländer
Nicolas Pouillard schrieb: However the rule is still the same when using an unsafe function you are on your own. Clearer? Almost. What I am missing is whether or not you would then consider your genericSeq (which is applicable to functions) one of those unsafe functions or not. Ciao, Janis.

Re: [Haskell-cafe] Re: Laziness question

2010-08-04 Thread Nicolas Pouillard
On Wed, 04 Aug 2010 17:27:01 +0200, Janis Voigtländer j...@informatik.uni-bonn.de wrote: Nicolas Pouillard schrieb: However the rule is still the same when using an unsafe function you are on your own. Clearer? Almost. What I am missing is whether or not you would then consider your

Re: [Haskell-cafe] Re: Laziness question

2010-08-04 Thread Janis Voigtländer
Nicolas Pouillard schrieb: On Wed, 04 Aug 2010 17:27:01 +0200, Janis Voigtländer j...@informatik.uni-bonn.de wrote: Nicolas Pouillard schrieb: However the rule is still the same when using an unsafe function you are on your own. Clearer? Almost. What I am missing is whether or not you would

Re: [Haskell-cafe] Re: Laziness question

2010-08-04 Thread Nicolas Pouillard
On Wed, 04 Aug 2010 17:47:12 +0200, Janis Voigtländer j...@informatik.uni-bonn.de wrote: Nicolas Pouillard schrieb: On Wed, 04 Aug 2010 17:27:01 +0200, Janis Voigtländer j...@informatik.uni-bonn.de wrote: Nicolas Pouillard schrieb: However the rule is still the same when using an unsafe

Re: [Haskell-cafe] Re: Laziness question

2010-08-04 Thread Janis Voigtländer
Nicolas Pouillard schrieb: On Wed, 04 Aug 2010 17:47:12 +0200, Janis Voigtländer j...@informatik.uni-bonn.de wrote: Nicolas Pouillard schrieb: On Wed, 04 Aug 2010 17:27:01 +0200, Janis Voigtländer j...@informatik.uni-bonn.de wrote: Nicolas Pouillard schrieb: However the rule is still the

Re: [Haskell-cafe] Re: Laziness question

2010-08-04 Thread Nicolas Pouillard
On Wed, 04 Aug 2010 18:04:13 +0200, Janis Voigtländer j...@informatik.uni-bonn.de wrote: Nicolas Pouillard schrieb: On Wed, 04 Aug 2010 17:47:12 +0200, Janis Voigtländer j...@informatik.uni-bonn.de wrote: Nicolas Pouillard schrieb: On Wed, 04 Aug 2010 17:27:01 +0200, Janis Voigtländer

Re: [Haskell-cafe] Re: Laziness question

2010-08-04 Thread Janis Voigtländer
Nicolas Pouillard schrieb: Right let's make it more explicit, I actually just wrote a Control.Seq module and a test file: module Control.Seq where genericSeq :: Typeable a = a - b - b genericSeq = Prelude.seq class Seq a where seq :: a - b - b instance (Typeable a,

Re: [Haskell-cafe] Re: Laziness question

2010-08-03 Thread Nicolas Pouillard
On Mon, 02 Aug 2010 17:41:02 +0200, Janis Voigtländer j...@informatik.uni-bonn.de wrote: Hi, I am late to reply in this thread, but as I see Stefan has already made what (also from my view) are the main points: - Putting seq in a type class makes type signatures more verbose, which one

Re: [Haskell-cafe] Re: Laziness question

2010-08-03 Thread Stefan Holdermans
Nicolas, OK, I better understand now where we disagree. You want to see in the type whether or not the free theorem apply, I want them to always apply when no call to unsafe function is made. Implementing your suggestion would make me feel uncomfortable. Turning seq into an unsafe operations

Re: [Haskell-cafe] Re: Laziness question

2010-08-03 Thread Janis Voigtländer
Nicolas Pouillard schrieb: - If there is no class instance for function types, then those problems go away, of course. But it is doubtful whether that would be a viable solution. Quite a few programs would be rejected as a consequence. (Say, you want to use the strict version of foldl. That will

Re: [Haskell-cafe] Re: Laziness question

2010-08-03 Thread Janis Voigtländer
Hi again, Maybe I should add that, maybe disappointingly, I do not even have a strong opinion about whether seq should be in Haskell or not, and in what form. Let me quote the last paragraph of an extended version of our paper referred to earlier: Finally, a natural question is whether or not

Re: [Haskell-cafe] Re: Laziness question

2010-08-03 Thread Nicolas Pouillard
On Tue, 3 Aug 2010 16:24:54 +0200, Stefan Holdermans ste...@vectorfabrics.com wrote: Nicolas, OK, I better understand now where we disagree. You want to see in the type whether or not the free theorem apply, I want them to always apply when no call to unsafe function is made.

Re: [Haskell-cafe] Re: Laziness question

2010-08-03 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 8/3/10 10:24 , Stefan Holdermans wrote: Implementing your suggestion would make me feel uncomfortable. Turning seq into an unsafe operations effectively places it outside the language, like unsafePerformIO isn't really part of the language (in

Re: [Haskell-cafe] Laziness question

2010-08-02 Thread Stefan Holdermans
Nicolas, Luke, SH More importantly, the type-class approach is flawed [...]. It assumes SH that all seq-related constraints can be read off from type variables, SH which is in fact not the case. LP Could you provide an example (or a specific example or explanation in LP the paper) of what you

[Haskell-cafe] Re: Laziness question

2010-08-02 Thread Janis Voigtländer
Hi, I am late to reply in this thread, but as I see Stefan has already made what (also from my view) are the main points: - Putting seq in a type class makes type signatures more verbose, which one may consider okay or not. In the past (and, as it seems, again in every iteration of the language

Re: [Haskell-cafe] Re: Laziness question

2010-08-02 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 8/2/10 11:41 , Janis Voigtländer wrote: alright that we don't know more about where (==) is used. But for a function of type f :: Eval (a - Int) = (a - Int) - (a - Int) - Int, in connection with trying to find out whether uses of seq are

Re: [Haskell-cafe] Re: Laziness question

2010-08-02 Thread Stefan Holdermans
Brandon, Hm. Seems to me that (with TypeFamilies and FlexibleContexts) h :: (x ~ y, Eval (y - Int)) = (x - Int) - (y - Int) - Int should do that, but ghci is telling me it isn't (substituting Eq for Eval for the nonce): Prelude let h :: (x ~ y, Eq (y - Int)) = (x - Int) - (y - Int) -

Re: [Haskell-cafe] Re: Laziness question

2010-08-02 Thread Stefan Holdermans
Brandon, h :: (x ~ y, Eval (y - Int)) = (x - Int) - (y - Int) - Int But actually if you push the constraint inward, into the type so to say, you actually get quite close to Janis' and David's solution. Sorry, I was thinking out loud there. I meant the Eval constraint, not the equality

Re: [Haskell-cafe] Re: Laziness question

2010-08-02 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 8/2/10 17:18 , Stefan Holdermans wrote: Brandon, h :: (x ~ y, Eval (y - Int)) = (x - Int) - (y - Int) - Int But actually if you push the constraint inward, into the type so to say, you actually get quite close to Janis' and David's

Re: [Haskell-cafe] Re: Laziness question

2010-08-02 Thread Stefan Holdermans
Brandon, Sorry, I was thinking out loud there. I meant the Eval constraint, not the equality constraint. But, right now, I guess my comment only makes sense to me, so let's pretend I kept quiet. ;-) The point of this discussion is that the Eval constraint needs to be on one of the

Re: [Haskell-cafe] Laziness question

2010-08-01 Thread Ivan Lazar Miljenovic
Brandon S Allbery KF8NH allb...@ece.cmu.edu writes: Exactly. (I was being cagey because the first response was cagey, possibly suspecting a homework question although it seems like an odd time for it.) Why is it an odd time for it? Here in Australia (and presumably other countries in the

Re: [Haskell-cafe] Laziness question

2010-08-01 Thread Nicolas Pouillard
On Sat, 31 Jul 2010 17:30:54 -0400, Brandon S Allbery KF8NH allb...@ece.cmu.edu wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 7/31/10 16:58 , wren ng thornton wrote: Brandon S Allbery KF8NH wrote: michael rice wrote: Are you saying: [ head x ] - [ *thunk* ] and

Re: [Haskell-cafe] Laziness question

2010-08-01 Thread Stefan Holdermans
Nicolas, I would deeply in favor of renaming seq to unsafeSeq, and introduce a type class to reintroduce seq in a disciplined way. There is a well-documented [1] trade-off here: Often, calls to seq are introduced late in a developing cycle; typically after you have discovered a space leak

Re: [Haskell-cafe] Laziness question

2010-08-01 Thread Luke Palmer
On Sun, Aug 1, 2010 at 2:53 AM, Stefan Holdermans ste...@vectorfabrics.com wrote: Nicolas, I would deeply in favor of renaming seq to unsafeSeq, and introduce a type class to reintroduce seq in a disciplined way. There is a well-documented [1] trade-off here:  Often, calls to seq are

Re: [Haskell-cafe] Laziness question

2010-08-01 Thread Nicolas Pouillard
On Sun, 1 Aug 2010 10:53:24 +0200, Stefan Holdermans ste...@vectorfabrics.com wrote: Nicolas, I would deeply in favor of renaming seq to unsafeSeq, and introduce a type class to reintroduce seq in a disciplined way. There is a well-documented [1] trade-off here: Often, calls to seq are

Re: [Haskell-cafe] Laziness question

2010-08-01 Thread Felipe Lessa
On Sun, Aug 1, 2010 at 11:29 AM, Nicolas Pouillard nicolas.pouill...@gmail.com wrote: Finally maybe we can simply forbidden the forcing of function (as we do with Eq). The few cases where it does matter will rescue to unsafeSeqFunction. What's the problem with class Eval a where seq :: a

Re: [Haskell-cafe] Laziness question

2010-08-01 Thread Dan Doel
On Sunday 01 August 2010 10:52:48 am Felipe Lessa wrote: On Sun, Aug 1, 2010 at 11:29 AM, Nicolas Pouillard nicolas.pouill...@gmail.com wrote: Finally maybe we can simply forbidden the forcing of function (as we do with Eq). The few cases where it does matter will rescue to

[Haskell-cafe] Laziness question

2010-07-31 Thread michael rice
From: http://en.wikibooks.org/wiki/Haskell/Laziness Given two functions of one parameter, f and g, we say f is stricter than g if f x evaluates x to a deeper level than g x Exercises    1. Which is the stricter function? f x = length [head x] g x = length (tail x) Prelude let f x = length

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread Henning Thielemann
michael rice schrieb: So, g is stricter than f? Wouldn't both functions need to evaluate x to the same level, *thunk* : *thunk* to insure listhood? No. :-) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread Ben Millwood
On Sat, Jul 31, 2010 at 4:56 PM, michael rice nowg...@yahoo.com wrote: From: http://en.wikibooks.org/wiki/Haskell/Laziness Given two functions of one parameter, f and g, we say f is stricter than g if f x evaluates x to a deeper level than g x Exercises    1. Which is the stricter

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread michael rice
@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe Notice the two different kinds of brackets being used in f versus g :) --- On Sat, 7/31/10, Ben Millwood hask...@benmachine.co.uk wrote: From: Ben Millwood hask...@benmachine.co.uk Subject: Re: [Haskell-cafe] Laziness question To: michael

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread Brandon S Allbery KF8NH
the [] and (). But since both still have eval x to *thunk* : *thunk*, g evaluates to a deeper level? The whole point of laziness is that f *doesn't* have to eval x. - -- brandon s. allbery [linux,solaris,freebsd,perl] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread Ben Millwood
On Sat, Jul 31, 2010 at 5:59 PM, michael rice nowg...@yahoo.com wrote: OK, in f, *length* already knows it's argument is a list. In g, *length* doesn't know what's inside the parens, extra evaluation there. So g is already ahead before we get to what's inside the [] and (). According to the

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread Albert Y. C. Lai
On 10-07-31 01:30 PM, Brandon S Allbery KF8NH wrote: On 7/31/10 12:59 , michael rice wrote: But since both still have eval x to *thunk* : *thunk*, g evaluates to a deeper level? The whole point of laziness is that f *doesn't* have to eval x. To elaborate, in computer-friendly syntax: f x

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread michael rice
]  -  [ *thunk* ]   and   length [ *thunk* ] -  1, independent of what *thunk* is, even head [], i.e., *thunk* never needs be evaluated? Michael --- On Sat, 7/31/10, Ben Millwood hask...@benmachine.co.uk wrote: From: Ben Millwood hask...@benmachine.co.uk Subject: Re: [Haskell-cafe] Laziness

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 7/31/10 14:24 , michael rice wrote: Are you saying: [ head x ] - [ *thunk* ] and length [ *thunk* ] - 1, independent of what *thunk* is, even head [], i.e., *thunk* never needs be evaluated? Exactly. (I was being cagey because the

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread Tillmann Rendel
michael rice wrote: f x = length [head x] g x = length (tail x) Wouldn't both functions need to evaluate x to the same level, *thunk* : *thunk* to insure listhood? There is no need to insure listhood at run time, since Haskell is statically typed. Tillmann

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread michael rice
Subtle stuff. Thanks, everyone, for your patience. You've been VERY helpful. Great list! Michael --- On Sat, 7/31/10, Brandon S Allbery KF8NH allb...@ece.cmu.edu wrote: From: Brandon S Allbery KF8NH allb...@ece.cmu.edu Subject: Re: [Haskell-cafe] Laziness question To: haskell-cafe@haskell.org

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread wren ng thornton
Brandon S Allbery KF8NH wrote: michael rice wrote: Are you saying: [ head x ] - [ *thunk* ] and length [ *thunk* ] - 1, independent of what *thunk* is, even head [], i.e., *thunk* never needs be evaluated? Exactly. (I was being cagey because the first response was cagey, possibly

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 7/31/10 16:58 , wren ng thornton wrote: Brandon S Allbery KF8NH wrote: michael rice wrote: Are you saying: [ head x ] - [ *thunk* ] and length [ *thunk* ] - 1, independent of what *thunk* is, even head [], i.e., *thunk* never needs be

Re: [GHC] #3944: Asynchronous exceptions and laziness bugs (with fixes) in Control.Concurrent.QSem/QSemN

2010-07-09 Thread GHC
#3944: Asynchronous exceptions and laziness bugs (with fixes) in Control.Concurrent.QSem/QSemN -+-- Reporter: basvandijk | Owner: simonmar Type: bug | Status: closed

Re: laziness in `length'

2010-06-15 Thread Denys Rtveliashvili
Hi Daniel, Thank you very much for the explanation of this issue. While I understand the parts about rewrite rules and the big thunk, it is still not clear why it is the way it is. Please could you explain which Nums are not strict? The ones I am aware about are all strict. Also, why doesn't

Re: laziness in `length'

2010-06-15 Thread Daniel Fischer
min _ Zero = Zero min (Succ m) (Succ n) = Succ (min m n) max Zero n = n max m Zero = m max (Succ m) (Succ n) = Succ (max m n) instance Num Peano where Zero + n = n (Succ m) + n = Succ (m + n) -- omitted other methods due to laziness (mine, not Haskell's) fromInteger n

Re: laziness in `length'

2010-06-15 Thread Roman Beslik
On 14.06.10 17:25, Serge D. Mechveliani wrote: lng [1 .. n] = lng (1 : (list 2 n)) = 1 + (lng $ list 2 n) = 1 + (lng (2: (list 3 n))) = 1 + 1 + (lng $ list 3 n) = {- !!! -} 2 + (lng (3: (list 4 n))) -- because this + is of Integer = 2 + 1 + (lng $ list 4 n) = {- !!! -} 3 + (lng $

laziness in `length'

2010-06-14 Thread Serge D. Mechveliani
Dear people and GHC team, I have a naive question about the compiler and library of ghc-6.12.3. Consider the program import List (genericLength) main = putStr $ shows (genericLength [1 .. n]) \n where n = -- 10^6, 10^7, 10^8 ... (1) When it is compiled under -O,

Re: laziness in `length'

2010-06-14 Thread Daniel Fischer
On Monday 14 June 2010 16:25:06, Serge D. Mechveliani wrote: Dear people and GHC team, I have a naive question about the compiler and library of ghc-6.12.3. Consider the program import List (genericLength) main = putStr $ shows (genericLength [1 .. n]) \n where n =

Re: [GHC] #3944: Asynchronous exceptions and laziness bugs (with fixes) in Control.Concurrent.QSem/QSemN

2010-05-05 Thread GHC
#3944: Asynchronous exceptions and laziness bugs (with fixes) in Control.Concurrent.QSem/QSemN -+-- Reporter: basvandijk|Owner: simonmar Type: bug | Status: patch

  1   2   3   4   >