Re: [Haskell-cafe] Question on concurrency

2010-09-14 Thread Arnaud Bailly
Probably did not test enough. Sorry for the noise. arnaud On Tue, Sep 14, 2010 at 12:18 PM, Neil Brown nc...@kent.ac.uk wrote: On 14/09/10 07:45, Arnaud Bailly wrote: What surprised me is that I would expect the behaviour of the two functions to be different:  - in doRunMvnInIO, I would

[Haskell-cafe] Simple Parsec example, question

2010-09-14 Thread Peter Schmitz
Simple Parsec example, question I am learning Parsec and have been studying some great reference and tutorial sites I have found (much thanks to the authors), including: http://legacy.cs.uu.nl/daan/download/parsec/parsec.html#UserGuide http://legacy.cs.uu.nl/daan/download/parsec/parsec.html

Re: [Haskell-cafe] Simple Parsec example, question

2010-09-14 Thread Antoine Latter
Hi Peter, On Tue, Sep 14, 2010 at 8:23 PM, Peter Schmitz ps.hask...@gmail.com wrote: Simple Parsec example, question I am learning Parsec and have been studying some great reference and tutorial sites I have found (much thanks to the authors), including: http://legacy.cs.uu.nl/daan/download

[Haskell-cafe] Small question on concurrency

2010-09-12 Thread Arnaud Bailly
Hello Haskellers, Having been pretty much impressed by Don Stewart's Practical Haskell (http://donsbot.wordpress.com/2010/08/17/practical-haskell/), I started to write a Haskell script to run maven jobs (yes, I know...). In the course of undertaking this fantastic endeavour, I started to use the

Re: [Haskell-cafe] Quick Question for QuickCheck2

2010-08-31 Thread Lyndon Maydwell
there is an even stranger problem. I'm side-tracking slightly from the original question here, but nevertheless... GHC gives the following output: --- GHCi, version 6.12.3: http://www.haskell.org/ghc/  :? for help command line: cannot satisfy -package QuickCheck-2.1.1.1:    QuickCheck-2.1.1.1

Re: [Haskell-cafe] Quick Question for QuickCheck2

2010-08-31 Thread Ivan Lazar Miljenovic
On 31 August 2010 20:38, Lyndon Maydwell maydw...@gmail.com wrote: ghc-pkg check doesn't list any broken dependencies. You sure this is with the same user? ghci is unlikely to complain about broken libraries if ghc-pkg check doesn't... -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com

Re: [Haskell-cafe] Quick Question for QuickCheck2

2010-08-31 Thread Lyndon Maydwell
Yep. Definitely the same user. On Tue, Aug 31, 2010 at 7:35 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 31 August 2010 20:38, Lyndon Maydwell maydw...@gmail.com wrote: ghc-pkg check doesn't list any broken dependencies. You sure this is with the same user?  ghci is unlikely

Re: [Haskell-cafe] Quick Question for QuickCheck2

2010-08-31 Thread Sebastian Höhn
Do you have ~/.cabal/bin/ in your PATH? - Sebastian Am 31.08.2010 um 15:57 schrieb Lyndon Maydwell: Yep. Definitely the same user. On Tue, Aug 31, 2010 at 7:35 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 31 August 2010 20:38, Lyndon Maydwell maydw...@gmail.com wrote:

Re: [Haskell-cafe] Quick Question for QuickCheck2

2010-08-31 Thread Lyndon Maydwell
Yep :) Is there a batch of information that might be useful? I can send any relevant files, aliases, versions, etc at once to help if you like. On Wed, Sep 1, 2010 at 12:35 AM, Sebastian Höhn sebastian.ho...@iig.uni-freiburg.de wrote: Do you have ~/.cabal/bin/ in your PATH? - Sebastian Am

Re: [Haskell-cafe] Quick Question for QuickCheck2

2010-08-31 Thread Ivan Lazar Miljenovic
Do you have ~/.cabal/bin or $HOME/.cabal/bin ? The latter is preferable as some issues arise with the former... On 1 September 2010 03:29, Lyndon Maydwell maydw...@gmail.com wrote: Yep :) Is there a batch of information that might be useful? I can send any relevant files, aliases, versions,

Re: [Haskell-cafe] Quick Question for QuickCheck2

2010-08-31 Thread Lyndon Maydwell
$HOME/.cabal/bin On Wed, Sep 1, 2010 at 10:55 AM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: Do you have ~/.cabal/bin or $HOME/.cabal/bin ?  The latter is preferable as some issues arise with the former... On 1 September 2010 03:29, Lyndon Maydwell maydw...@gmail.com wrote: Yep

[Haskell-cafe] Quick Question for QuickCheck2

2010-08-30 Thread Sebastian Höhn
Hello, perhaps I am just blind or is it a difficult issue: I would like to generate Char values in a given Range for QuickCheck2. There is this simple example from the haskell book: instance Arbitrary Char where arbitrary = elements (['A'..'Z'] ++ ['a' .. 'z'] ++ ~...@#$%^*()) This does not

Re: [Haskell-cafe] Quick Question for QuickCheck2

2010-08-30 Thread austin seipp
You can create a wrapper with a newtype and then define an instance for that. newtype Char2 = Char2 Char instance Arbitrary Char2 where arbitrary = ... You'll have to do some wrapping and unwrapping when calling your properties to get/set the underlying Char, but this is probably the easiest

Re: [Haskell-cafe] Quick Question for QuickCheck2

2010-08-30 Thread John Millikin
Define a custom element generator, which has characters with your desired values: myRange :: Gen Char myRange = elements (['A'..'Z'] ++ ['a' .. 'z'] ++ ~...@#$%^*()) You can use forAll to run tests with a specific generator: forAll myRange $ \c - chr (ord c) == c On Mon, Aug 30, 2010 at

Re: [Haskell-cafe] Quick Question for QuickCheck2

2010-08-30 Thread Lyndon Maydwell
I'm just trying these examples, and I can't figure out how to import quickcheck2 rather than quickcheck1. I've looked around but I can't seem to find any information on this. How do I do it? Thanks! On Mon, Aug 30, 2010 at 11:56 PM, John Millikin jmilli...@gmail.com wrote: Define a custom

Re: [Haskell-cafe] Quick Question for QuickCheck2

2010-08-30 Thread John Millikin
Update your cabal package list, and then install QuickCheck. Optionally, you can use a version specifier: cabal update cabal install 'QuickCheck = 2' This should make QuickCheck 2 the default in GHCI. If it doesn't, you may need to specify the version: ghci -package QuickCheck-2.2

Re: [Haskell-cafe] Quick Question for QuickCheck2

2010-08-30 Thread Lyndon Maydwell
Thanks! This makes perfect sense, but as I just discovered using ghci -v there is an even stranger problem. I'm side-tracking slightly from the original question here, but nevertheless... GHC gives the following output: --- GHCi, version 6.12.3: http://www.haskell.org/ghc/ :? for help command

Re: [Haskell-cafe] Quick Question for QuickCheck2

2010-08-30 Thread Ivan Lazar Miljenovic
On 31 August 2010 03:18, Lyndon Maydwell maydw...@gmail.com wrote: Thanks! This makes perfect sense, but as I just discovered using ghci -v there is an even stranger problem. I'm side-tracking slightly from the original question here, but nevertheless... GHC gives the following output

Re: [Haskell-cafe] Question about memory usage

2010-08-18 Thread John van Groningen
Sebastian Fischer wrote: BTW, what sort of memory usage are we talking about here? I was referring to the memory usage of this program import System.Environment import Data.Numbers.Fibonacci main :: IO () main = do n - (read . head) `fmap` getArgs (fib n ::

Re: [Haskell-cafe] Question about memory usage

2010-08-18 Thread Sebastian Fischer
Hi John, You could try: [...] It allocates less and has a smaller maximum residency: (ghc 6.12.2,windows 7 64) 292,381,520 bytes allocated in the heap 13,020,308 bytes maximum residency (8 sample(s)) 99 MB total memory in use (9 MB lost due to fragmentation) MUT

Re: [Haskell-cafe] Question about memory usage

2010-08-18 Thread John van Groningen
Sebastian Fischer wrote: .. Interesting. It uses the same amount of memory but is faster probably because it allocates less. But I prefer programs for people to read over programs for computers to execute and I have a hard time to verify that your algorithm computes According to:

Re: [Haskell-cafe] Question about memory usage

2010-08-18 Thread Daniel Fischer
On Tuesday 17 August 2010 17:33:15, Sebastian Fischer wrote: BTW, what sort of memory usage are we talking about here? ./calcfib 1 +RTS -s 451,876,020 bytes allocated in the heap 10,376 bytes copied during GC 19,530,184 bytes maximum

Re: [Haskell-cafe] Question about memory usage

2010-08-17 Thread Roel van Dijk
On Tue, Aug 17, 2010 at 3:53 AM, Richard O'Keefe o...@cs.otago.ac.nz wrote: On Aug 17, 2010, at 12:37 AM, Roel van Dijk wrote: phi = (1 + sqrt 5) / 2 fib n = ((phi ** n) - (1 - phi) ** n) / sqrt 5 The use of (**) should make the complexity at least O(n). Please correct me if I'm wrong (or

Re: [Haskell-cafe] Question about memory usage

2010-08-17 Thread Sebastian Fischer
On Aug 17, 2010, at 12:33 AM, Jason Dagit wrote: So next I would use heap profiling to find out where and what type of data the calculation is using. I did. I would do heap profiling and look at the types. All retained data is of type ARR_WORDS. Retainer profiling shows that the

Re: [Haskell-cafe] Question about memory usage

2010-08-17 Thread Sebastian Fischer
On Aug 17, 2010, at 8:39 AM, Roel van Dijk wrote: That is an interesting trick. So there exists an algorithm that calculates Fibonacci numbers in O(log n) time. This is what my program does. But it's only O(long n) if you assume multiplication is constant time (which it is not for large

Re: [Haskell-cafe] Question about memory usage

2010-08-17 Thread Ivan Lazar Miljenovic
Sebastian Fischer s...@informatik.uni-kiel.de writes: On Aug 17, 2010, at 8:39 AM, Roel van Dijk wrote: That is an interesting trick. So there exists an algorithm that calculates Fibonacci numbers in O(log n) time. This is what my program does. But it's only O(long n) [snip] Are you

Re: [Haskell-cafe] Question about memory usage

2010-08-17 Thread Daniel Fischer
On Tuesday 17 August 2010 08:59:29, Sebastian Fischer wrote: I wonder whether the numbers in a single step of the computation occupy all the memory or whether old numbers are retained although they shouldn't be. BTW, what sort of memory usage are we talking about here? I have now tried your

Re: [Haskell-cafe] Question about memory usage

2010-08-17 Thread Sebastian Fischer
BTW, what sort of memory usage are we talking about here? I was referring to the memory usage of this program import System.Environment import Data.Numbers.Fibonacci main :: IO () main = do n - (read . head) `fmap` getArgs (fib n :: Integer) `seq` return ()

Re: [Haskell-cafe] Question about memory usage

2010-08-17 Thread Jacques Carette
Daniel Fischer wrote: On Aug 16, 2010, at 6:03 PM, Jacques Carette wrote: Any sequence of numbers given by a linear recurrence equation with constant coefficients can be computed quickly using asymptotically efficient matrix operations. In fact, the code to do this can be derived

Re: [Haskell-cafe] Question about memory usage

2010-08-17 Thread Richard O'Keefe
On Aug 17, 2010, at 6:39 PM, Roel van Dijk wrote: Using x**n = exp(n*log(x)) and floating point arithmetic, the whole thing can be done in O(1) time, and the price of some inaccuracy. It will calculate a subset of the Fibonacci numbers in O(1) time. Thinking about it I think you can easily

[Haskell] Fwd: [Haskell-cafe] Question about memory usage

2010-08-16 Thread Alberto G. Corona
It is not repeated because fiblist is pure and has no arguments. Otherwise it would be repeated. 2010/8/14 Tako Schotanus t...@codejive.org I was reading this article: http://scienceblogs.com/goodmath/2009/11/writing_basic_functions_in_has.php And came to the part where it shows:

Re: [Haskell-cafe] xemacs newbie question - haskell mode

2010-08-16 Thread Roel van Dijk
Note the following line from the haskell-mode project page: If it works on XEmacs, consider yourself lucky. [1] Regards, Roel 1 - http://projects.haskell.org/haskellmode-emacs/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Question about memory usage

2010-08-16 Thread Roel van Dijk
On Sat, Aug 14, 2010 at 5:41 PM, Andrew Coppin andrewcop...@btinternet.com wrote: (Then again, the Fibonacci numbers can be computed in O(1) time, and nobody ever needs Fibonacci numbers in the first place, so this is obviously example code.) A bit off-topic, but I don't think there exists a

Re: [Haskell-cafe] Question about memory usage

2010-08-16 Thread Daniel Fischer
On Monday 16 August 2010 14:37:34, Roel van Dijk wrote: On Sat, Aug 14, 2010 at 5:41 PM, Andrew Coppin andrewcop...@btinternet.com wrote: (Then again, the Fibonacci numbers can be computed in O(1) time, and nobody ever needs Fibonacci numbers in the first place, so this is obviously

Re: [Haskell-cafe] Question about memory usage

2010-08-16 Thread Sebastian Fischer
[continuing off topic] On Aug 16, 2010, at 3:13 PM, Daniel Fischer wrote: You can calculate the n-th Fibonacci number in O(log n) steps using Integer arithmetic to get correct results. Yes, I was delighted when I saw this for the frist time. It works be computing /1 1\^n \1 0/

Re: [Haskell-cafe] Question about memory usage

2010-08-16 Thread Sebastian Fischer
[CC-ing café again] On Aug 16, 2010, at 5:52 PM, Daniel Fischer wrote: I am a bit concerned about the memory usage. Of your implementation of the matrix power algorithm? Yes. Making the fields of Matrix strict should help: data Matrix a = Matrix !a !a !a Making all fields strict

Re: [Haskell-cafe] Question about memory usage

2010-08-16 Thread Jacques Carette
Since we're off-topic... Any sequence of numbers given by a linear recurrence equation with constant coefficients can be computed quickly using asymptotically efficient matrix operations. In fact, the code to do this can be derived automatically from the recurrence itself. Here is what you

Re: [Haskell-cafe] Question about memory usage

2010-08-16 Thread Andrew Coppin
Roel van Dijk wrote: On Sat, Aug 14, 2010 at 5:41 PM, Andrew Coppin andrewcop...@btinternet.com wrote: (Then again, the Fibonacci numbers can be computed in O(1) time, and nobody ever needs Fibonacci numbers in the first place, so this is obviously example code.) A bit off-topic, but

Re: [Haskell-cafe] Question about memory usage

2010-08-16 Thread Antoine Latter
On Mon, Aug 16, 2010 at 1:37 PM, Andrew Coppin andrewcop...@btinternet.com wrote: This neatly leads us back to my second assertion: In all my years of computer programming, I've never seen one single program that actually *needs* the Fibonacci numbers in the first place (let alone in

Re: [Haskell-cafe] Question about memory usage

2010-08-16 Thread Jason Dagit
On Mon, Aug 16, 2010 at 9:00 AM, Sebastian Fischer s...@informatik.uni-kiel.de wrote: [CC-ing café again] On Aug 16, 2010, at 5:52 PM, Daniel Fischer wrote: I am a bit concerned about the memory usage. Of your implementation of the matrix power algorithm? Yes. Making the fields

Re: [Haskell-cafe] Question about memory usage

2010-08-16 Thread Daniel Peebles
There's a Fibonacci Heap: http://en.wikipedia.org/wiki/Fibonacci_heap Not sure what else though :) On Mon, Aug 16, 2010 at 11:14 PM, Antoine Latter aslat...@gmail.com wrote: On Mon, Aug 16, 2010 at 1:37 PM, Andrew Coppin andrewcop...@btinternet.com wrote: This neatly leads us back to my

Re: [Haskell-cafe] Question about memory usage

2010-08-16 Thread Richard O'Keefe
On Aug 17, 2010, at 12:37 AM, Roel van Dijk wrote: phi = (1 + sqrt 5) / 2 fib n = ((phi ** n) - (1 - phi) ** n) / sqrt 5 The use of (**) should make the complexity at least O(n). Please correct me if I'm wrong (or sloppy). Using the classic x**0 = 1 x**1 = x

[Haskell-cafe] xemacs newbie question - haskell mode

2010-08-15 Thread rgowka1
HI - I have been struggling to get the Xemacs recognize hs file. I have installed the Haskell-mode.. However I keep getting the message File mode specification error: (wrong-number-of-arguments require 3).. How do I go about fixing this?? Many thanks

[Haskell-cafe] Question about memory usage

2010-08-14 Thread Tako Schotanus
I was reading this article: http://scienceblogs.com/goodmath/2009/11/writing_basic_functions_in_has.php And came to the part where it shows: fiblist = 0 : 1 : (zipWith (+) fiblist (tail fiblist)) Very interesting stuff for somebody who comes from an imperative world of course. But then I

Re: [Haskell-cafe] Question about memory usage

2010-08-14 Thread Andrew Coppin
Tako Schotanus wrote: fiblist = 0 : 1 : (zipWith (+) fiblist (tail fiblist)) Very interesting stuff for somebody who comes from an imperative world of course. Oh yes, that old chestnut. There's a page on the wiki somewhere with a whole collection of these cryptic one-liners - Pascal's

Re: [Haskell-cafe] Question about memory usage

2010-08-14 Thread Christopher Lane Hinson
On Sat, 14 Aug 2010, Tako Schotanus wrote: I was reading this article: http://scienceblogs.com/goodmath/2009/11/writing_basic_functions_in_has.php And came to the part where it shows: fiblist = 0 : 1 : (zipWith (+) fiblist (tail fiblist)) But then I read that Once it's been referenced,

Re: [Haskell-cafe] Question about memory usage

2010-08-14 Thread Daniel Peebles
In the example above, fiblist is a global variable, so the answer to when does it get freed? would be never. (I believe it's called a CAF leak.) Is that actually true? I've heard lots of references to this, but I'm not sure it is true. Sure, it's harder for it to get collected when everyone

Re: [Haskell-cafe] Question about memory usage

2010-08-14 Thread Tako Schotanus
First of all, thanks to the people who responded :) On Sat, Aug 14, 2010 at 17:49, Christopher Lane Hinson l...@downstairspeople.org wrote: On Sat, 14 Aug 2010, Tako Schotanus wrote: I was reading this article: http://scienceblogs.com/goodmath/2009/11/writing_basic_functions_in_has.php

[Haskell-cafe] Question about rpc design

2010-08-06 Thread lysgaard
://old.nabble.com/Question-about-rpc-design-tp29356441p29356441.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Question about rpc design

2010-08-06 Thread Vladimir Zlatanov
snip Is this way of sending messages already known? Does it have a name? And if not, how hard do you think it would be to hack some rpc library to implement this? I think you are describing telescopic routing. Of sorts. The easiest way to achieve your goal is by making the communications

[Haskell-cafe] ANN: Elerea 2.x.x + question about AOP in Haskell

2010-08-05 Thread Patai Gergely
question. There are three main variants of the library: a basic one and two others that extend it in some way. The extensions are orthogonal -- on the level of denotational semantics they could be represented as monad transformers (at least I strongly believe so, but I haven't verified yet

Re: [Haskell-cafe] design question: decision tree from Programming Collective Intelligence

2010-08-04 Thread S. Doaitse Swierstra
I have added the permutation parsers from uulib to uu-parsinglib: http://hackage.haskell.org/packages/archive/uu-parsinglib/2.5.1.1/doc/html/Text-ParserCombinators-UU-Perms.html, where you find reference to the paper Doaitse On 22 jun 2010, at 09:24, Stephen Tetley wrote: Hello Maybe

Re: [Haskell-cafe] Re: Laziness question

2010-08-04 Thread Nicolas Pouillard
function is made. Well, the question is what you mean by no call to unsafe function is made. Where? In the function under consideration, from whose type the free theorem is derived? Are you sure that this is enough? Maybe that function f does not contain a call to unsafeSeq, but it has

Re: [Haskell-cafe] Re: Laziness question

2010-08-04 Thread Janis Voigtländer
the point of a free theorem, isn't it: that I only need to look at the type of the function to derive some property about it. I want them to always apply when no call to unsafe function is made. Well, the question is what you mean by no call to unsafe function is made. Where? In the function under

Re: [Haskell-cafe] Re: Laziness question

2010-08-04 Thread Nicolas Pouillard
need to look at the type of the function to derive some property about it. I want them to always apply when no call to unsafe function is made. Well, the question is what you mean by no call to unsafe function is made. Where? In the function under consideration, from whose type the free

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
if putting seq in a type class, problems with parametricity do not simply vanish. The question is what instances there will be for that class. (For example, if there is not instance at all, then no seq-related problems of *any* nature can exist...) - The Haskell 1.3 solution was to, among others

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
of the function to derive some property about it. I want them to always apply when no call to unsafe function is made. Well, the question is what you mean by no call to unsafe function is made. Where? In the function under consideration, from whose type the free theorem is derived? Are you sure

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

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
development process since then) the majority of the language design decision makers have considered this verbosity non-okay enough, so that they decided to have a fully polymorhpic seq. - Even if putting seq in a type class, problems with parametricity do not simply vanish. The question is what

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

[Haskell-cafe] Reverse unification question

2010-08-02 Thread Martijn van Steenbergen
Dear café, Given: instance Category C y :: forall r. C r (A - r) I am looking for the types of x and z such that: x . y :: forall r. C r r y . z :: forall r. C r r Can you help me find such types? I suspect only one of them exists. Less importantly, at least to me at this moment: how do I

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] Reverse unification question

2010-08-02 Thread Ryan Ingram
there's no y.z that fulfills that requirement. Lets rewrite in a System-F-style language with data types: Given read (/\) as forall, \\ as big lambda, and @ as type-level application which eliminates big-lambda. data Category (~) = CategoryDict { id :: (/\a. a ~ a) , (.) :: (/\a b c.

Re: [Haskell-cafe] Reverse unification question

2010-08-02 Thread Felipe Lessa
On Mon, Aug 2, 2010 at 7:37 PM, Ryan Ingram ryani.s...@gmail.com wrote: there's no y.z that fulfills that requirement.  Lets rewrite in a System-F-style language with data types: [...] So clearly x0 has type (C (A - r) r) However, our input is parametric in r, which is mentioned in x0's type,

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

Re: [Haskell-cafe] Laziness question

2010-08-01 Thread Nicolas Pouillard
* ] 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 suspecting a homework question although it seems like an odd time for it.) length not only does

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] Constructor question

2010-07-31 Thread michael rice
From: Data.Complex data (RealFloat a) = Complex a = !a :+ !a What's the purpose of the exclamation marks? Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Constructor question

2010-07-31 Thread Ivan Lazar Miljenovic
michael rice nowg...@yahoo.com writes: From: Data.Complex data (RealFloat a) = Complex a = !a :+ !a What's the purpose of the exclamation marks? Forcing; it means that the values are evaluated (up to WHNF) before the Complex value is constructed:

Re: [Haskell-cafe] Constructor question

2010-07-31 Thread michael rice
Thanks, Ivan. I may be back later, after I read http://en.wikibooks.org/wiki/Haskell/Laziness Michael --- On Sat, 7/31/10, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: From: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com Subject: Re: [Haskell-cafe] Constructor question To: michael

Re: [Haskell-cafe] Constructor question

2010-07-31 Thread Ben Millwood
On Sat, Jul 31, 2010 at 2:32 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: Forcing; it means that the values are evaluated (up to WHNF) before the Complex value is constructed: http://www.haskell.org/ghc/docs/6.12.1/html/users_guide/bang-patterns.html Actually, this isn't a

Re: [Haskell-cafe] Constructor question

2010-07-31 Thread Ivan Lazar Miljenovic
Ben Millwood hask...@benmachine.co.uk writes: On Sat, Jul 31, 2010 at 2:32 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: Forcing; it means that the values are evaluated (up to WHNF) before the Complex value is constructed:

Re: [Haskell-cafe] Constructor question

2010-07-31 Thread michael rice
Miljenovic ivan.miljeno...@gmail.com wrote: From: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com Subject: Re: [Haskell-cafe] Constructor question To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Saturday, July 31, 2010, 9:32 AM michael rice nowg...@yahoo.com writes: From

Re: [Haskell-cafe] Constructor question

2010-07-31 Thread michael rice
Ok, got ! and WHNF. Thanks, Michael --- On Sat, 7/31/10, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: From: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com Subject: Re: [Haskell-cafe] Constructor question To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Saturday

[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
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 7/31/10 12:59 , michael rice 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 ().

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread Ben Millwood
to the types, we already know both are lists. The question is, of course, what kind of list. But since both still have eval x to *thunk* : *thunk*,  g evaluates to a deeper level? Michael I think this question is being quite sneaky. The use of head and tail is pretty much irrelevant. Try

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
question To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Saturday, July 31, 2010, 1:47 PM 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

<    3   4   5   6   7   8   9   10   11   12   >