Re: [Haskell-cafe] instance of String illegal

2006-09-29 Thread Stefan Holdermans
Adam, class Foo a where mkFoo :: a - String instance Foo String where mkFoo x = x In addition to making use of language extensions or wrapper types, you could go with the following workaround in just plain Haskell 98: import List class MkFoo a where mkFoo :: a -

RE: [Haskell-cafe] Optimizing a title matcher

2006-09-29 Thread Bayley, Alistair
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bulat Ziganshin Sent: 28 September 2006 17:29 To: Lyle Kopnicky now i will work on edit-distance algorithm. i'm have an idea of checking the real distance between chars - as on my keyboard, so for example sprry can be

[Haskell-cafe] Re: Haskell DLL crashes Excel

2006-09-29 Thread Cyril Schmidt
A few people recently asked how to pass a string between a Haskell DLL and Excel. I attach the proof-of-concept code that I wrote a while ago; it demonstrates passing a string from Excel to Haskell and the other way. Most of the C++ code is taken from code examples at http://msdn.microsoft.com

Re: [Haskell-cafe] Computing lazy and strict list operations at the same time

2006-09-29 Thread Brandon Moore
Andrew Pimlott wrote: This is a follow-up to a thread from June-July[1]. The question was how to write the function initlast :: [a] - ([a], a) initlast xs = (init xs, last xs) so that it can be consumed in fixed space: main = print $ case initlast [0..10] of

[Haskell-cafe] existential types (was Re: Optimization problem)

2006-09-29 Thread Ross Paterson
On Thu, Sep 28, 2006 at 03:22:25PM +0100, Simon Peyton-Jones wrote: | Does anything go wrong with irrefutable patterns for existential types? Try giving the translation into System F. I'm a bit puzzled about this. A declaration data Foo = forall a. MkFoo a (a - Bool) is equivalent

Re: [Haskell-cafe] Re: A better syntax for qualified operators?

2006-09-29 Thread Brian Hulley
Benjamin Franksen wrote: Brian Hulley wrote: ith = Data.Array.IArray.(!) Sorry, but I can't see the problem here. Why can't the editor offer the operator as '!' in the list of options, and if the user selects it insert both '(' and ')' at the right places (i.e. before the module name

RE: [Haskell-cafe] existential types (was Re: Optimization problem)

2006-09-29 Thread Simon Peyton-Jones
I must be missing your point. Newtype is just type isomorphism; a new name for an existing type. But there is not existing type exists x. T(x). So it's not surprising that newtype doesn't support existentials. I've lost track of this thread. Can you re-state the question? I'm strongly

Re: [Haskell-cafe] existential types (was Re: Optimization problem)

2006-09-29 Thread Ross Paterson
On Fri, Sep 29, 2006 at 11:19:26AM +0100, Simon Peyton-Jones wrote: I must be missing your point. Newtype is just type isomorphism; a new name for an existing type. But there is not existing type exists x. T(x). So it's not surprising that newtype doesn't support existentials. And yet

[Haskell-cafe] irrefutable patterns for existential types / GADTs

2006-09-29 Thread apfelmus
Ross Paterson wrote: The story so far: apfelmus: why are there no irrefutable patterns for GADTs? Conor: because you could use them to write unsafeCoerce Ross: how about irrefutable patterns (or newtypes) for existential types? Simon: Try giving the translation into System F + (existential)

Re: [Haskell-cafe] irrefutable patterns for existential types / GADTs

2006-09-29 Thread Conor McBride
[EMAIL PROTECTED] wrote: Ross Paterson wrote: The story so far: apfelmus: why are there no irrefutable patterns for GADTs? Conor: because you could use them to write unsafeCoerce Ross: how about irrefutable patterns (or newtypes) for existential types? Simon: Try giving the translation into

Re: [Haskell-cafe] Is Haskell a 5GL?

2006-09-29 Thread Robert Dockins
On Sep 28, 2006, at 8:47 PM, David Curran wrote: Sorry if this comes across as the rant it is. If you are interested in doing useful stuff rather then navel gazing please stop here. Where are compute languages going? I think multi core, distributed, fault tolerant. So you would end up with a

Re: [Haskell-cafe] Is Haskell a 5GL?

2006-09-29 Thread David Curran
After some thought on your replies I have realised that I was completely wrong. 1. Software needs to be concurrent Haskell is doing more towards this goal then any other language I know of 2. Software should be provably correct. Haskell is doing more towards this goal then any other language I

[Haskell-cafe] Greetings...

2006-09-29 Thread Seth Gordon
I've finally gotten enough round tuits to learn Haskell, and now that I've done some of the exercises from _The Haskell School of Expression_ and I finally (think I) understand what a monad is, the language is making a lot more sense to me (although my code is not always making so much sense to

[Haskell-cafe] How can I redirect stdout?

2006-09-29 Thread Matthew Bromberg
I'm reposting this in it's own new thread since I think it involves a general issue beyond exporting Haskell DLLs. I am having some problems with GHCs stdout when a Haskell program is called from a windows program. As I noted earlier I am calling some Haskell code from C as a bridge to

Re: Re: [Haskell-cafe] Is Haskell a 5GL?

2006-09-29 Thread Nicolas Frisby
snip Call me elitist if you want, but I don't want anyone who refuses or is unable to learn calculus to be, eg, a civil engineer. He don't have to be an expert in real analysis, but if he don't understand the basics, I don't want him building any bridges that I'm going to be driving on!

Re: Re: [Haskell-cafe] Is Haskell a 5GL?

2006-09-29 Thread Gene A
Nicolas Frisby said: {} The fact of the matter is it's a rare case when a programmer's lack of mathematical background threatens lives. If my GUI crashes, I'm angry but not injured. Programmers make a living without the math background because the vast majority of employers don't seek

[Haskell-cafe] smallest double eps

2006-09-29 Thread Tamas K Papp
Hi, Is there a built-in constant in Haskell (or, if it is compiler-specific, in ghc) that gives the smallest positive floating point number x such that 1+x /= x? Some languages refer to that as double.eps or similar. I need it for numeric algorithms. Thanks, Tamas

Re: [Haskell-cafe] smallest double eps

2006-09-29 Thread Joachim Breitner
Hi, Am Freitag, den 29.09.2006, 19:30 -0400 schrieb Tamas K Papp: the smallest positive floating point number x such that 1+x /= x? That would be the smallest positive number, woudn't it? Do you mean the smalles postive number x with 1+x /= 1? Greetings, Joachim -- Joachim Breitner

Re: [Haskell-cafe] smallest double eps

2006-09-29 Thread Tamas K Papp
On Sat, Sep 30, 2006 at 12:20:16AM +, Joachim Breitner wrote: Hi, Am Freitag, den 29.09.2006, 19:30 -0400 schrieb Tamas K Papp: the smallest positive floating point number x such that 1+x /= x? That would be the smallest positive number, woudn't it? Do you mean the smalles postive

Re: [Haskell-cafe] smallest double eps

2006-09-29 Thread Lennart Augustsson
Haskell doesn't provide such a value, but you could easily compute it from from the values given in the RealFloat class. It tells you the base, number of digits in mantissa, etc. As for using such an eps in a convergence test I'd be very careful. How do you know that your iteration

Re: [Haskell-cafe] smallest double eps

2006-09-29 Thread Tamas K Papp
On Fri, Sep 29, 2006 at 09:26:27PM -0400, Lennart Augustsson wrote: As for using such an eps in a convergence test I'd be very careful. How do you know that your iteration doesn't make the value bounce back and forth with more than eps? Hi Lennart, Thanks for the answer, I will try it.

Re: [Haskell-cafe] Is Haskell a 5GL?

2006-09-29 Thread Tamas K Papp
On Mon, Sep 25, 2006 at 03:27:32PM +0200, Henning Thielemann wrote: Hi Henning, Actually, laziness allows me to formulate algorithms that look more like the specification of the problem than the solution. E.g., I can formulate the solution of a differential equation in terms of a power series

Re: [Haskell-cafe] smallest double eps

2006-09-29 Thread Chad Scherrer
Tamas, You might want to read Joachim's post more carefully - he's trying to help you, and I think he makes a good point. -Chad Am Freitag, den 29.09.2006, 19:30 -0400 schrieb Tamas K Papp: the smallest positive floating point number x such that 1+x /= x? That would be the smallest

Re: [Haskell-cafe] smallest double eps

2006-09-29 Thread Tamas K Papp
On Fri, Sep 29, 2006 at 06:53:35PM -0700, Chad Scherrer wrote: Tamas, You might want to read Joachim's post more carefully - he's trying to help you, and I think he makes a good point. Chad, If his point is that there is no smallest positive number, then I think I understand it, thanks. I