[Haskell-cafe] Re: Elevator pitch for Haskell.

2007-09-06 Thread Niko Korhonen
Paul Johnson wrote: For software developers who need to produce highly reliable software at minimum cost, Haskell is a pure functional programming language that reduces line count by 75% through reusable higher order functions and detects latent defects with its powerful static type system.

Re: [Haskell-cafe] Mutable but boxed arrays?

2007-09-06 Thread Ketil Malde
On Wed, 2007-09-05 at 20:37 +0200, Henning Thielemann wrote: Can someone explain me, why there are arrays with mutable but boxed elements? I, on the other hand, have always wondered why the strict arrays are called unboxed, rather than, well, strict? Strictness seems to be their observable

Re: [Haskell-cafe] Re: Elevator pitch for Haskell.

2007-09-06 Thread Ketil Malde
On Wed, 2007-09-05 at 09:54 -0700, Simon Michael wrote: I agree actually. That picture, while very cool, won't help Haskell marketing one bit. :) Avoid success at all costs, remember? Lisp's made with alien technology is much more inviting: http://www.lisperati.com/logo.html . True.

Re: [Haskell-cafe] ANNOUNCE: xmonad 0.3

2007-09-06 Thread Joachim Breitner
Hi, Am Donnerstag, den 06.09.2007, 08:24 +0400 schrieb Max Vasin: 2007/9/5, Peter Verswyvelen [EMAIL PROTECTED]: If so, would it be possible to integrate this into GTK2HS so it works as a docking manager inside an application? First of all, gtk is a cross platform toolkit and gtk2hs is just

RE: [Haskell-cafe] Typeclasses and implicit parameters

2007-09-06 Thread Simon Peyton-Jones
| -- Hugs allows this. GHC rejects it on the grounds that a is unused | -- on the right-hand side of the (=). I think this is arguably a bug | -- in GHC. | f3 :: (Show a, ?foo :: a) = String | f3 = show ?foo Hugs is right here. GHC 6.8 accepts this too, and has done for some time; there's

RE: [Haskell-cafe] Typeclasses and implicit parameters

2007-09-06 Thread ajb
G'day all. Quoting Simon Peyton-Jones [EMAIL PROTECTED]: | -- GHC rejects this. Hugs compiles it, but I can't call it as | -- let ?foo = Hello in show Foo | -- | -- Is there a good reason to disallow this? | data Foo = Foo | | instance (?foo :: String) = Show Foo where | showsPrec _ Foo =

[Haskell-cafe] Re: Mutable but boxed arrays?

2007-09-06 Thread Simon Marlow
Ketil Malde wrote: On Wed, 2007-09-05 at 20:37 +0200, Henning Thielemann wrote: Can someone explain me, why there are arrays with mutable but boxed elements? I, on the other hand, have always wondered why the strict arrays are called unboxed, rather than, well, strict? Strictness seems to be

Re: [Haskell-cafe] Re: Mutable but boxed arrays?

2007-09-06 Thread Josef Svenningsson
On 9/6/07, Simon Marlow [EMAIL PROTECTED] wrote: Ketil Malde wrote: I, on the other hand, have always wondered why the strict arrays are called unboxed, rather than, well, strict? Strictness seems to be their observable property, while unboxing is just an (admittedly important)

Re: [Haskell-cafe] numeric types

2007-09-06 Thread Henning Thielemann
On Wed, 5 Sep 2007, Thomas Hartman wrote: I think you want something like this {-# OPTIONS -fglasgow-exts #-} Why glasgow-exts? You may also want to read and extend the discussion generic number type vs. distinct numeric types http://www.haskell.org/haskellwiki/Generic_number_type

[Haskell-cafe] turning an imperative loop to Haskell

2007-09-06 Thread Axel Gerstenberger
Hi all, I am completely stuck with a problem involving a loop construct from imperative programming, that I want to translate to Haskell code. The problem goes as follows: Based on a value u_n, I can calculate a new value u_{n+1} with a function f(u). u_n was calculated from u_{n-1} and so on

Re: [Haskell-cafe] Mutable but boxed arrays?

2007-09-06 Thread Henning Thielemann
On Wed, 5 Sep 2007, Jonathan Cast wrote: On Wed, 2007-09-05 at 20:37 +0200, Henning Thielemann wrote: Can someone explain me, why there are arrays with mutable but boxed elements? I thought that boxing is only needed for lazy evaluation. However if I access an element of an array that is the

Re: [Haskell-cafe] turning an imperative loop to Haskell

2007-09-06 Thread Henning Thielemann
On Thu, 6 Sep 2007, Axel Gerstenberger wrote: module Main where import System.IO import Text.Printf main :: IO () main = do let all_results1 = take 2 $ step [1] --print $ length all_results1 -- BTW: if not commented out, -- all values of

Re: [Haskell-cafe] turning an imperative loop to Haskell

2007-09-06 Thread Dougal Stanton
On 06/09/07, Axel Gerstenberger [EMAIL PROTECTED] wrote: module Main where import System.IO import Text.Printf main :: IO () main = do let all_results1 = take 2 $ step [1] --print $ length all_results1 -- BTW: if not commented out, --

[Haskell-cafe] Re: Mutable but boxed arrays?

2007-09-06 Thread apfelmus
Henning Thielemann wrote: I'll see, if I understand it. do writeArray arr 0 2 x - readArray arr 0 writeArray arr 0 (x+x) If 'arr' is an STArray, the 'arr' will contain the unevaluated expression 2+2 as zeroth element and with type STUArray it will contain the evaluated 4 ?

[Haskell-cafe] Re: turning an imperative loop to Haskell

2007-09-06 Thread apfelmus
Dougal Stanton wrote: To create an infinite list where each f(u) depends on the previous u, with a single seed value, use 'iterate': main = mapM_ (uncurry (printf %d %f\n)) (zip [1..50] (iterate f 3)) How about main = sequence_ $ zipWith (printf %d %f\n) [1..50] (iterate f 3) Regards,

Re: [Haskell-cafe] Re: [Haskell] (no subject)

2007-09-06 Thread Thomas Hartman
I think at some intermediate stage that flag helped me compile, but in the final version it's unnecessary. my bad. Thomas Hartman [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] 09/05/2007 06:29 PM To [EMAIL PROTECTED] cc [EMAIL PROTECTED], haskell-cafe@haskell.org, Tomi Owens [EMAIL

Re: [Haskell-cafe] turning an imperative loop to Haskell

2007-09-06 Thread Axel Gerstenberger
Thanks to all of you. The suggestions work like a charm. Very nice. I still need to digest the advices, but have already one further question: How would I compute the new value based on the 2 (or even more) last values instead of only the last one? [ 2, 3 , f 3 2, f((f 3 2) 3), f ( f((f 3 2)

Re: [Haskell-cafe] Typeclasses and implicit parameters

2007-09-06 Thread Stefan O'Rear
On Thu, Sep 06, 2007 at 06:49:21AM -0400, [EMAIL PROTECTED] wrote: For completeness, here's the final solution, courtesy of int-e (whose real name I don't know; sorry), which is much more elegant than I Bertram Felgenhauer bindString :: (forall s. StringAsType s = Mark s a) - String - a

Re: [Haskell-cafe] turning an imperative loop to Haskell

2007-09-06 Thread Jules Bean
Axel Gerstenberger wrote: Thanks to all of you. The suggestions work like a charm. Very nice. I still need to digest the advices, but have already one further question: How would I compute the new value based on the 2 (or even more) last values instead of only the last one? [ 2, 3 , f 3 2,

Re: [Haskell-cafe] turning an imperative loop to Haskell

2007-09-06 Thread Sebastian Sylvan
On 06/09/07, Axel Gerstenberger [EMAIL PROTECTED] wrote: Thanks to all of you. The suggestions work like a charm. Very nice. I still need to digest the advices, but have already one further question: How would I compute the new value based on the 2 (or even more) last values instead of only

Re: [Haskell-cafe] turning an imperative loop to Haskell

2007-09-06 Thread Dougal Stanton
On 06/09/07, Axel Gerstenberger [EMAIL PROTECTED] wrote: however,I don't get it this to work. Is it possible to see the definition of the iterate function? The online help just shows it's usage... The Haskell 98 report includes source for the standard prelude. Check 'em out...

[Haskell-cafe] Re: Typeclasses and implicit parameters

2007-09-06 Thread Chung-chieh Shan
[EMAIL PROTECTED] wrote in article [EMAIL PROTECTED] in gmane.comp.lang.haskell.cafe: That higher-rank type makes all the difference. Yes. You can even do this portably, using nothing unsafe, with Dylan Thurston's technique: Oleg Kiselyov and Chung-chieh Shan. 2004. Functional pearl: Implicit

Re: [Haskell-cafe] turning an imperative loop to Haskell

2007-09-06 Thread Rodrigo Queiro
When you get to more than two arguments, it will probably be nicer to do something like this: fibs = map (\(a,b) - a) $ iterate (\(a,b) - (b, a+b)) (0,1) or fibs = unfoldr (\(a,b) - Just (a, (b, a+b))) (0,1) -- this uses unfoldr to get rid of the map This is essentially a translation of the

Re: [Haskell-cafe] turning an imperative loop to Haskell

2007-09-06 Thread Dougal Stanton
On 06/09/07, Sebastian Sylvan [EMAIL PROTECTED] wrote: foo = 2 : 3 : zipWith f (drop 1 foo) foo There's also zipWith3 etc. for functions with more arguments. I think this is called taking a good thing too far, but cool too: f1 u = u + 1 f2 u v = u + v f3 u v w = u + v + w -- functions

Re: [Haskell-cafe] turning an imperative loop to Haskell

2007-09-06 Thread Henning Thielemann
On Thu, 6 Sep 2007, Axel Gerstenberger wrote: Thanks to all of you. The suggestions work like a charm. Very nice. I still need to digest the advices, but have already one further question: How would I compute the new value based on the 2 (or even more) last values instead of only the last

[Haskell-cafe] Learning advice

2007-09-06 Thread Chris Saunders
I wish to learn Haskell. I purchased a book - An Introduction to Functional Programming Systems Using Haskell but I think this might be too outdated. I'm using GHC and it seems that some of the functions used in the book are no longer a part of Haskell. I'm looking for advice on books or

Re: [Haskell-cafe] Learning advice

2007-09-06 Thread Tom Harper
No, that book is not outdated. Can you give an example of what's not working for you? On 9/6/07, Chris Saunders [EMAIL PROTECTED] wrote: I wish to learn Haskell. I purchased a book – An Introduction to Functional Programming Systems Using Haskell but I think this might be too outdated.

Re: [Haskell-cafe] turning an imperative loop to Haskell

2007-09-06 Thread Dan Piponi
On 9/6/07, Dougal Stanton [EMAIL PROTECTED] wrote: On 06/09/07, Sebastian Sylvan [EMAIL PROTECTED] wrote: [2,3,4,9,16,29,54,99,182,335] -- what's this? Two times this: http://www.research.att.com/~njas/sequences/A000213 plus this: http://www.research.att.com/~njas/sequences/A001590 plus two

Re: [Haskell-cafe] Mutable but boxed arrays?

2007-09-06 Thread Isaac Dupree
Ketil Malde wrote: On Wed, 2007-09-05 at 20:37 +0200, Henning Thielemann wrote: Can someone explain me, why there are arrays with mutable but boxed elements? I, on the other hand, have always wondered why the strict arrays are called unboxed, rather than, well, strict? Strictness seems to be

Re[2]: [Haskell-cafe] Mutable but boxed arrays?

2007-09-06 Thread Bulat Ziganshin
Hello Isaac, Thursday, September 6, 2007, 9:41:34 PM, you wrote: Unboxing is, unfortunately, observable: it is not so easy to make a strict array of SomeArbitraryAlgebraicDataType, because it's not in class Storable. parallel arrays in GHC is just about it -- Best regards, Bulat

Re: [Haskell-cafe] Learning advice

2007-09-06 Thread Brent Yorgey
On 9/6/07, Chris Saunders [EMAIL PROTECTED] wrote: So far I'm finding Haskell difficult – I may be too thick. Once upon a time there was a young man who wanted to be a race car driver. He bought an old, junky car with a souped-up engine (after all, that's what all his friends were using). It

Re: [Haskell-cafe] Re: Elevator pitch for Haskell.

2007-09-06 Thread Dan Weston
Perhaps your (admittedly young) colleague had other reasons to inquire... It turns out that (in the US at least) the lambda symbol is one of the symbols of gay pride since the 1970's: http://en.wikipedia.org/wiki/LGBT_symbol#Lambda If you google lambda gay you will find many more

Re: [Haskell-cafe] Learn Prolog...

2007-09-06 Thread Lennart Augustsson
Because you can play very clever tricks with DFS to make it efficient, time and space. On 9/5/07, Stefan O'Rear [EMAIL PROTECTED] wrote: On Wed, Sep 05, 2007 at 01:21:52PM +1000, Thomas Conway wrote: but to interpret this as a *program* you have to consider how it will be executed. In

Re: [Haskell-cafe] Re: turning an imperative loop to Haskell

2007-09-06 Thread Stefan O'Rear
On Thu, Sep 06, 2007 at 03:42:50PM +0200, apfelmus wrote: Dougal Stanton wrote: To create an infinite list where each f(u) depends on the previous u, with a single seed value, use 'iterate': main = mapM_ (uncurry (printf %d %f\n)) (zip [1..50] (iterate f 3)) How about main = sequence_ $

Re: [Haskell-cafe] Re: wanted: HAppS example combining state and io

2007-09-06 Thread Thomas Hartman
Thanks Martin, that really helped. After many days reading the source, I'm still trying to grok HAppS. Meanwhile, here is a patch that adds examples to HAppS/Examples/HTTP1.hs for combining state and io, based on your advice. see especiallly the handler stateioH accepts an arbitrary state

Re: [Haskell-cafe] ANNOUNCE: xmonad 0.3

2007-09-06 Thread Dan Piponi
On 9/5/07, Max Vasin [EMAIL PROTECTED] wrote: 2007/9/5, Peter Verswyvelen [EMAIL PROTECTED]: Looks really nice, but if I understand it correctly it is specific for X, so does not work on Windows? This kind of programs is impossible in Windows. Of cause you can use X server for Windows and

Re: [Haskell-cafe] Learning advice

2007-09-06 Thread Tom Harper
Don't bang your head against a wall too long. Like Brent said, #haskell is quite a good resource. There's always (and I mean ALWAYS) a group of people online at any given time that can answer your questions. On 9/6/07, Chris Saunders [EMAIL PROTECTED] wrote: Thanks to all that responded (I

[Haskell-cafe] Speed of character reading in Haskell

2007-09-06 Thread ok
I'm writing a tokeniser for a legacy programming language in Haskell. I started with the obvious main = getContents = print . tokenise where tokenise maps its way down a list of characters. This is very simple, very pleasant, and worked like a charm. However, the language has an INCLUDE

[Haskell-cafe] Help understanding type error

2007-09-06 Thread Levi Stephen
Hi, I'm after some help understanding either what I'm doing wrong, or why this error occurs. I have a data type: data T a = forall b. (Show b) = T b a and I want to use/extract 'b' from this. extShow (T b _) = b This gives the following compilation error: extest.hs:5:0: Inferred

Re: [Haskell-cafe] Help understanding type error

2007-09-06 Thread Matthew Brecknell
Levi Stephen: I have a data type: data T a = forall b. (Show b) = T b a and I want to use/extract 'b' from this. You can't. (Well, I believe you can if you have prior knowledge of the actual type of the existentially wrapped b, and you're willing to use an unsafe coerce, but I've never

Re: [Haskell-cafe] Help understanding type error

2007-09-06 Thread Stuart Cook
On 9/7/07, Levi Stephen [EMAIL PROTECTED] wrote: I'm after some help understanding either what I'm doing wrong, or why this error occurs. I have a data type: data T a = forall b. (Show b) = T b a I should first point out that by mentioning b only on the RHS, you've defined an

RE: [Haskell-cafe] Learning advice

2007-09-06 Thread Chris Saunders
Thanks to all that responded (I enjoyed very much the story). From the response below I think my thickness is showing too much and I'll try a little harder on my own first. Thanks again, Chris Saunders -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of

Re: [Haskell-cafe] ANNOUNCE: xmonad 0.3

2007-09-06 Thread Max Vasin
2007/9/7, Dan Piponi [EMAIL PROTECTED]: That depends on your definition of this kind. I meant window manager. I.e. a porgram which manages window size, placement, focus, decorations, etc. http://en.wikipedia.org/wiki/LiteStep This is a shell (a replacement for explorer), not a window manager.