Re: [Haskell-cafe] let vs. where

2007-11-16 Thread Henning Thielemann
On Fri, 16 Nov 2007, jeff p wrote: A function is an expression whose type is an arrow; e.g. Int - Int. The type of taxRate is (Fractional t) = t. I had this misunderstanding too, when starting with Haskell. In other languages there are functions with zero, one or more arguments. In contrast

Re: [Haskell-cafe] let vs. where

2007-11-16 Thread Arnar Birgisson
On Nov 16, 2007 12:26 AM, Lennart Augustsson [EMAIL PROTECTED] wrote: On Nov 14, 2007 1:05 AM, Robin Green [EMAIL PROTECTED] wrote: On Tue, 13 Nov 2007 13:51:13 -0800 Dan Piponi [EMAIL PROTECTED] wrote: Up until yesterday I had presumed that guards only applied to functions. But I

Re: [Haskell-cafe] let vs. where

2007-11-15 Thread Henning Thielemann
On Tue, 13 Nov 2007, Dan Piponi wrote: On Nov 13, 2007 1:24 PM, Ryan Ingram [EMAIL PROTECTED] wrote: I tend to prefer where, but I think that guards function declarations are more readable than giant if-thens and case constructs. Up until yesterday I had presumed that guards only applied

Re[2]: [Haskell-cafe] let vs. where

2007-11-15 Thread Bulat Ziganshin
Hello Henning, Thursday, November 15, 2007, 2:31:07 PM, you wrote: Btw. I would write here min 1 (max (-1) x) or even better define a function for such clipping, since it is needed quite often. min 1 . max (-1) is pretty standard, although i renamed them: atMax 1 . atLeast (-1) --

Re[2]: [Haskell-cafe] let vs. where

2007-11-15 Thread Henning Thielemann
On Thu, 15 Nov 2007, Bulat Ziganshin wrote: Hello Henning, Thursday, November 15, 2007, 2:31:07 PM, you wrote: Btw. I would write here min 1 (max (-1) x) or even better define a function for such clipping, since it is needed quite often. min 1 . max (-1) is pretty standard,

Re: [Haskell-cafe] let vs. where

2007-11-15 Thread hjgtuyl
On Thu, 15 Nov 2007 12:31:07 +0100, Henning Thielemann [EMAIL PROTECTED] wrote: On Tue, 13 Nov 2007, Dan Piponi wrote: On Nov 13, 2007 1:24 PM, Ryan Ingram [EMAIL PROTECTED] wrote: I tend to prefer where, but I think that guards function declarations are more readable than giant if-thens

Re: [Haskell-cafe] let vs. where

2007-11-15 Thread Arnar Birgisson
On Nov 16, 2007 12:35 AM, Arnar Birgisson [EMAIL PROTECTED] wrote: [1] I'm terribly sorry, that was meant to be: [1] http://www.onlamp.com/pub/a/onlamp/2007/07/12/introduction-to-haskell-pure-functions.html sorry, Arnar ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] let vs. where

2007-11-15 Thread Lennart Augustsson
No, Haskell functions take exactly one argument. On Nov 14, 2007 1:05 AM, Robin Green [EMAIL PROTECTED] wrote: On Tue, 13 Nov 2007 13:51:13 -0800 Dan Piponi [EMAIL PROTECTED] wrote: Up until yesterday I had presumed that guards only applied to functions. But I was poking about in the

Re: [Haskell-cafe] let vs. where

2007-11-14 Thread Neil Mitchell
Hi Chris, this could be captured nicely in a where clause: exp = (fst blah, snd blah) where blah = gg 1000 But a let would have to be placed in both elements of the tuple exp = (let blah = g 1000 in fst blah, let blah = g 1000 in snd blah) Why not: exp = let blah = g 1000 in

Re: [Haskell-cafe] let vs. where

2007-11-14 Thread C.M.Brown
Hi David, A let clause would work fine here: someFunction ls a b c = let listLen = length ls someAuxFunction x y = ... listLen ... someOtherFunction x y = ... listLen ... in ... listLen

Re: [Haskell-cafe] let vs. where

2007-11-14 Thread C.M.Brown
Hi Neil, Why not: exp = let blah = g 1000 in (fst blah, snd blah) Yes, fair enough. Where's always get desugared to let's, so where's are never more efficient. Interesting. I'm thinking a where-to-let refactoring and its converse may make useful routine refactorings for HaRe.

[Haskell-cafe] let vs. where

2007-11-13 Thread John Lato
Hello, I know there are several important differences between let-expressions and where-clauses regarding scoping and the restriction of where to a top-level definition. However, frequently I write code in which either one would be allowed, and I was wondering if there were any guidelines or

Re: [Haskell-cafe] let vs. where

2007-11-13 Thread Sebastian Sylvan
On Nov 13, 2007 6:56 PM, John Lato [EMAIL PROTECTED] wrote: Hello, I know there are several important differences between let-expressions and where-clauses regarding scoping and the restriction of where to a top-level definition. However, frequently I write code in which either one would be

Re: [Haskell-cafe] let vs. where

2007-11-13 Thread Justin Bailey
On Nov 13, 2007 10:56 AM, John Lato [EMAIL PROTECTED] wrote: I know there are several important differences between let-expressions and where-clauses regarding scoping and the restriction of where to a top-level definition. However, frequently I write code in which One place I find it useful

Re: [Haskell-cafe] let vs. where

2007-11-13 Thread Henning Thielemann
On Tue, 13 Nov 2007, John Lato wrote: Hello, I know there are several important differences between let-expressions and where-clauses regarding scoping and the restriction of where to a top-level definition. However, frequently I write code in which either one would be allowed, and I was

Re: [Haskell-cafe] let vs. where

2007-11-13 Thread Neil Mitchell
Hi This depends on whether you are an expression style or declaration style programmer. http://www.haskell.org/haskellwiki/Declaration_vs._expression_style http://www.haskell.org/haskellwiki/Let_vs._Where Reading the let vs where page I'm left with the strong impression that I should use

Re: [Haskell-cafe] let vs. where

2007-11-13 Thread John Lato
I'd like to thank Henning for pointing out the wiki page, which describes one consequence I hadn't considered. I knew I couldn't have been the first person to have this question, but I somehow missed it before. I agree with Neil, though, that it doesn't seem very neutral. On Nov 13, 2007 1:58

Re: [Haskell-cafe] let vs. where

2007-11-13 Thread Henning Thielemann
On Tue, 13 Nov 2007, John Lato wrote: I'd like to thank Henning for pointing out the wiki page, which describes one consequence I hadn't considered. I knew I couldn't have been the first person to have this question, but I somehow missed it before. I agree with Neil, though, that it

Re: [Haskell-cafe] let vs. where

2007-11-13 Thread Neil Mitchell
Hi Maybe it would be enough to represent the example where problem more fairly on its own terms. The non-working example has us writing f = State $ \ x - y where y = ... x ... I just don't think this example is representative of the typical decisions in the trade-off. There are

Re: [Haskell-cafe] let vs. where

2007-11-13 Thread Thomas Schilling
On Tue, 2007-11-13 at 13:08 -0800, Donn Cave wrote: On Tue, 13 Nov 2007, Neil Mitchell wrote: This depends on whether you are an expression style or declaration style programmer. http://www.haskell.org/haskellwiki/Declaration_vs._expression_style

Re: [Haskell-cafe] let vs. where

2007-11-13 Thread Ryan Ingram
I tend to prefer where, but I think that guards function declarations are more readable than giant if-thens and case constructs. where can scope over multiple guards, and guards can access things declared in a where clause, both of which are important features: f xs | len 2 = y | len ==

Re: [Haskell-cafe] let vs. where

2007-11-13 Thread Dan Piponi
On Nov 13, 2007 1:24 PM, Ryan Ingram [EMAIL PROTECTED] wrote: I tend to prefer where, but I think that guards function declarations are more readable than giant if-thens and case constructs. Up until yesterday I had presumed that guards only applied to functions. But I was poking about in the

Re: [Haskell-cafe] let vs. where

2007-11-13 Thread David Roundy
On Tue, Nov 13, 2007 at 11:41:20AM -0800, Justin Bailey wrote: On Nov 13, 2007 10:56 AM, John Lato [EMAIL PROTECTED] wrote: I know there are several important differences between let-expressions and where-clauses regarding scoping and the restriction of where to a top-level definition.

Re: [Haskell-cafe] let vs. where

2007-11-13 Thread Robin Green
On Tue, 13 Nov 2007 13:51:13 -0800 Dan Piponi [EMAIL PROTECTED] wrote: Up until yesterday I had presumed that guards only applied to functions. But I was poking about in the Random module and discovered that you can write things like a | x 1 = 1 | x -1 = -1 | otherwise = x where

Re: [Haskell-cafe] let vs. where

2007-11-13 Thread Derek Elkins
On Tue, 2007-11-13 at 13:51 -0800, Dan Piponi wrote: On Nov 13, 2007 1:24 PM, Ryan Ingram [EMAIL PROTECTED] wrote: I tend to prefer where, but I think that guards function declarations are more readable than giant if-thens and case constructs. Up until yesterday I had presumed that guards