[Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread oleg
Donald Bruce Stewart wrote: So all this talk of locating head [] and fromJust failures got me thinking: Couldn't we just use rewrite rules to rewrite *transparently* all uses of fromJust to safeFromJust, tagging the call site with a location? I'm sorry for shifting the topic:

[Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Donald Bruce Stewart
oleg: Donald Bruce Stewart wrote: So all this talk of locating head [] and fromJust failures got me thinking: Couldn't we just use rewrite rules to rewrite *transparently* all uses of fromJust to safeFromJust, tagging the call site with a location? I'm sorry for

RE: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Simon Peyton-Jones
| The fromJust and `head of empty list' errors are totally equivalent to | the dereferencing of zero pointer in C++ or NullPointerException in | Java. It pains me to see that exactly the same problem arises in | Haskell -- keeping in mind that already in C++ and Java one may | exterminate

Re: [Haskell-cafe] Debugging partial functions by the rules

2006-11-15 Thread Neil Mitchell
Hi I have always been wondering why error shouldn't always return a call stack from the occurrance of fromJust up to the function I typed into ghci (or up to main, for that matter). yhi-stack (as yet unreleased) does exactly this, without requiring you to recompile your code even. hat-stack

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Neil Mitchell
Hi Yes, these techniques are fairly well known now, and hopefully some of the more experienced Haskellers are using them (I certainly use the non-empty list tricks). Any anyone with more than 6 months Haskell knows to avoid fromJust. I'm not, I use fromJust all the time. Ditto for head, init,

RE: [Haskell-cafe] Debugging partial functions by the rules

2006-11-15 Thread Simon Peyton-Jones
| I have always been wondering why error shouldn't always return a call | stack from the occurrance of fromJust up to the function I typed into | ghci (or up to main, for that matter). | | I guess this is because the call tree is rewritten extensively before | being evaluated, and the output

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Lennart Augustsson
Should Haskell also provide unrestricted side effects, setjmp/ longjmp, missile launching functions, etc? After all, people who don't want to use them can just avoid them. :) On Nov 15, 2006, at 05:07 , Neil Mitchell wrote: Hi Yes, these techniques are fairly well known now, and

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Ross Paterson
On Wed, Nov 15, 2006 at 09:04:01AM +, Simon Peyton-Jones wrote: I don't agree. My programs have invariants that I can't always express in a way that the type system can understand. E.g. I know that a variable is in scope, so searching for it in an environment can't fail: head [ v

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Neil Mitchell
Hi Should Haskell also provide unrestricted side effects, setjmp/ longjmp, missile launching functions, etc? After all, people who don't want to use them can just avoid them. :) Fair point. But if you eliminate incomplete cases, and the error function, you'd probably need to increase the

[Haskell-cafe] Re: [Haskell] I18N, external strings

2006-11-15 Thread Bulat Ziganshin
Hello Johannes, Wednesday, November 15, 2006, 10:36:10 AM, you wrote: What methods and tools are there for i18n of Haskell programs? In Haskell, I see at least two problems: a) reading the file is in IO if you need utf8 and other encodings support, you can use Streams lib: h - openFile

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Udo Stenzel
Donald Bruce Stewart wrote: So how do we help out the beginners, other than warning about fromJust, and providing a useful error message as we can, for when they just go ahead and use head anyway? Kill head and tail right now and provide a safe equivalent? Either uncons :: [a] - Maybe

Re[2]: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Bulat Ziganshin
Hello Lennart, Wednesday, November 15, 2006, 3:37:34 PM, you wrote: Should Haskell also provide unrestricted side effects, setjmp/ longjmp, missile launching functions, etc? After all, people who don't want to use them can just avoid them. :) these are documented in tackling the awkward

[Haskell-cafe] Re: Haskell custom search engine

2006-11-15 Thread Alberto G. Corona
By the way, Ihave developped the coreof asearch engine completely in Haskell. It can index arbitrary objects (including files, of course) has definitions for filters, with predefined filters for plain text, HTML/XML and ageneral filter for Haskell data types It has basic search capabilities: it

Re: [Haskell-cafe] the case of the 100-fold program speedup

2006-11-15 Thread Henning Thielemann
On Tue, 14 Nov 2006, Seth Gordon wrote: It took me a week to figure out the right algorithm for combining these two procedures and write some almost-working code that implemented it. It took a co-worker of mine another few days to find the bugs that had eluded me. Were these bugs of the

[Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Jón Fairbairn
Simon Peyton-Jones [EMAIL PROTECTED] writes: | The problem I see is that head/fromJust errors are usually |caused by *beginner* Haskellers, who don't know the |techniques for statically avoiding them. I don't agree. My programs have invariants that I can't always express in a way that the

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Neil Mitchell
Hi Haskell is great for equational reasoning. blah the_v_in_scope blah where (the_v_in_scope:_) = [ v | (n,v) - env, n==target ] This piece of code isn't. If you used head then you could trivially inline the_v_in_scope, this way is a lot harder. You might spot a pointfree pattern and lift

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Ketil Malde
Lennart Augustsson [EMAIL PROTECTED] writes: Should Haskell also provide unrestricted side effects, setjmp/ longjmp, missile launching functions, etc? After all, people who don't want to use them can just avoid them. :) Yes. It is indeed a common problem that programs have unintended

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Robert Dockins
On Nov 15, 2006, at 9:48 AM, Jón Fairbairn wrote: Simon Peyton-Jones [EMAIL PROTECTED] writes: | The problem I see is that head/fromJust errors are usually |caused by *beginner* Haskellers, who don't know the |techniques for statically avoiding them. I don't agree. My programs have

[Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Jón Fairbairn
Neil Mitchell [EMAIL PROTECTED] writes: Hi Haskell is great for equational reasoning. blah the_v_in_scope blah where (the_v_in_scope:_) = [ v | (n,v) - env, n==target ] This piece of code isn't. Strange. It's semantically the same, isn't it? Indeed, the definition of head gets you

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Justin Bailey
On 11/15/06, Donald Bruce Stewart [EMAIL PROTECTED] wrote: Yes, these techniques are fairly well known now, and hopefully some ofthe more experienced Haskellers are using them (I certainly use thenon-empty list tricks). Any anyone with more than 6 months Haskell knows to avoid fromJust.The problem

Re: [Haskell-cafe] Haskell Debugging

2006-11-15 Thread Ross Paterson
On Mon, Nov 13, 2006 at 04:32:34PM +0100, Valentin Gjorgjioski wrote: import Hugs.Observe ex8 :: [Float] ex8 = (observe after reverse ) reverse [10.0,7.0,3.0,0.0,4.0] gives me ex8 [4.0,0.0,3.0,7.0,10.0] Observations after reverse { \ ($-990871 : $-990888 : $-990905 :

[Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Jón Fairbairn
Robert Dockins [EMAIL PROTECTED] writes: On Nov 15, 2006, at 9:48 AM, Jón Fairbairn wrote: But instead of “blah (head [ v | (n,v) - env, n==target ]) blah”, you could write blah the_v_in_scope blah where (the_v_in_scope:_) = [ v | (n,v) - env, n==target ] Or how about ??

Re: [Haskell-cafe] Haskell Debugging

2006-11-15 Thread Valentin Gjorgjioski
On 15.11.2006 17:38 Ross Paterson wrote: On Mon, Nov 13, 2006 at 04:32:34PM +0100, Valentin Gjorgjioski wrote: import Hugs.Observe ex8 :: [Float] ex8 = (observe after reverse ) reverse [10.0,7.0,3.0,0.0,4.0] gives me ex8 [4.0,0.0,3.0,7.0,10.0] Observations

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Jacques Carette
Robert Dockins wrote: Or how about ?? lookupVarible target env = case [ v | (n,v) - env, n==target ] of (x:_) - x _ - assert False $ BUG: Unexpected variable out of scope ++(show target)++ in environment ++(show env) Other have pointed out that, in the CURRENT Haskell

Re: [Haskell-cafe] the case of the 100-fold program speedup

2006-11-15 Thread Seth Gordon
As Lily Tomlin would say, neVERmind. Simon P-J asked me, in email, whether the deforestation was the thing that actually made the program faster or whether it was just the thing that made me think about how to solve the problem. I realized that my fast program had *another* difference from the

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread John Hughes
From: Robert Dockins [EMAIL PROTECTED] It seems to me that every possible use of a partial function has some (possibly imagined) program invariant that prevents it from failing. Otherwise it is downright wrong. 'head', 'fromJust' and friends don't do anything to put that invariant in

[Haskell-cafe] type keeping rounding, typeable (and a difficulty)

2006-11-15 Thread isto
Hi, I've been trying to compile the following function (rounding to a desired degree): roundDec :: (Num a, Typeable a) = Int - a - a roundDec d a = let t = show (typeOf a) in case t of Double - roundDDec d a Complex Double - roundCDec d a

Re: [Haskell-cafe] type keeping rounding, typeable (and a difficulty)

2006-11-15 Thread Greg Buchholz
isto wrote: ] I've been trying to compile the following function ] (rounding to a desired degree): ] ] roundDec :: (Num a, Typeable a) = Int - a - a ] roundDec d a = ] let t = show (typeOf a) ] in case t of ] Double - roundDDec d a ] Complex Double -

[Haskell-cafe] Re: Re: Debugging partial functions by the rules

2006-11-15 Thread Benjamin Franksen
John Hughes wrote: From: Robert Dockins [EMAIL PROTECTED] It seems to me that every possible use of a partial function has some (possibly imagined) program invariant that prevents it from failing. Otherwise it is downright wrong. 'head', 'fromJust' and friends don't do anything to put that

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Robert Dockins
On Wednesday 15 November 2006 15:53, John Hughes wrote: From: Robert Dockins [EMAIL PROTECTED] It seems to me that every possible use of a partial function has some (possibly imagined) program invariant that prevents it from failing. Otherwise it is downright wrong. 'head', 'fromJust'

Re: [Haskell-cafe] submenu doesn't seem to work properly in wxhaskell

2006-11-15 Thread Eric Y. Kow
Hi, Let's transfer this to wxhaskell-users. I've attached your example as a small .lhs file and makefile. For Debian Linux, uncomment the -lwx_gtk2u_gl-2.6 line or otherwise, modify to taste. The following code doesn't seem to work properly. Either the main entry (m1/mp1) or it's sub menu

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Jan-Willem Maessen
On Nov 15, 2006, at 3:21 AM, [EMAIL PROTECTED] wrote: Donald Bruce Stewart wrote: So all this talk of locating head [] and fromJust failures got me thinking: Couldn't we just use rewrite rules to rewrite *transparently* all uses of fromJust to safeFromJust, tagging the call site

Re: [Haskell-cafe] submenu doesn't seem to work properly in wxhaskell

2006-11-15 Thread Eric Y. Kow
On Wed, Nov 15, 2006 at 23:10:44 +0100, Eric Y. Kow wrote: I've attached your example as a small .lhs file and makefile. For Debian Linux, uncomment the -lwx_gtk2u_gl-2.6 line or otherwise, modify to taste. Here are the files, really attached this time. -- Eric Kow

Re: [Haskell-cafe] forall and a parse error

2006-11-15 Thread Remi Turk
Probably unrelated, but this thread is what triggered it for me. There is a minor bug in showing impredicative types without -fglasgow-exts: *hope I got that right* Prelude let x = [] :: [forall a. a] interactive:1:23: Warning: Accepting non-standard infix type constructor `.'

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread Claus Reinke
This isn't a trivial point. We know that error handling code is a major part of software cost--it can even dominate the cost of the correct case code (by a large factor). Erlang's program for the correct case strategy, coupled with good fault tolerance mechanisms, is one reason for its

Re: [Haskell-cafe] Debugging partial functions by the rules

2006-11-15 Thread Claus Reinke
Couldn't we just use rewrite rules to rewrite *transparently* all uses of fromJust to safeFromJust, tagging the call site with a location? .. Looks good! But that is deceiving: the assert was expanded before the rule fired, and refers to the rewrite rule source line (line 19), not the

[Haskell-cafe] RE: Debugging partial functions by the rules

2006-11-15 Thread Simon Peyton-Jones
| Looks good! But that is deceiving: the assert was expanded before the rule | fired, and refers to the rewrite rule source line (line 19), not the fromJust | call site (line 12). Now if we could just have the 'assert' token inserted | into the AST before it was expanded, we'd be home and dry.

[Haskell-cafe] help with threadDelay

2006-11-15 Thread Neil Davies
Hi, I'm using GHC 6.6 (debian/etch) - and having some fun with threadDelay. When compiled without the -threaded compiler argument it behaves as documented - waits at least the interval - for example: Tgt/Actual = 0.00/0.036174s, diff = 0.036174s Tgt/Actual = 0.01/0.049385s, diff =

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread oleg
It must be stressed that the advocated technique for avoiding partial function errors requires *NO* research advances, *NO* dependent types, *NO* annotations, and *NO* tools. Everything is possible in Haskell as it is -- actually, even in Haskell98. As a matter of fact, exactly the same approach

[Haskell-cafe] Newbie; Can't Install Hat From Source

2006-11-15 Thread Aditya Siram
Hi all, I have been trying to install Hat for the last couple of days but GHC does not recognize it as a package. I compiled 2.05 from source, but at the 'make install' step I see this error message: **Begin Output** ./configure --install Configuring for hat... [ 2.05 ] Starting with earlier

Re: [Haskell-cafe] Re: Debugging partial functions by the rules

2006-11-15 Thread oleg
Jan-Willem Maessen wrote: In addition, we have this rather nice assembly of functions which work on ordinary lists. Sadly, rewriting them all to also work on NonEmptyList or MySpecialInvariantList is a nontrivial task. That's an excellent question. Indeed, let us assume we have a