[Haskell-cafe] Re: let vs. where
This actually clears up something that's been bothering me for some time. I've never really like syntax of types for functions with multiple arguments. Using the same token, -, to separate both arguments and the result seems very poor, because when reading a type you don't know if the value after that token is another argument or the final result without going further ahead. However, knowing that a function takes exactly one argument makes the syntax seem much more expressive for me. From: Henning Thielemann [EMAIL PROTECTED] ... In contrast to that, Haskell functions have exactly one argument and one result, which I find is a nice thing. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: let vs. where
John Lato wrote: This actually clears up something that's been bothering me for some time. I've never really like syntax of types for functions with multiple arguments. Using the same token, -, to separate both arguments and the result seems very poor, because when reading a type you don't know if the value after that token is another argument or the final result without going further ahead. However, knowing that a function takes exactly one argument makes the syntax seem much more expressive for me. Right. This is because - doesn't separate arguments from each other. It separates the one and only argument from the one and only result: a - b - c - d Has one argument of type 'a' and returns one result, of type 'b - c - d' The syntax is therefore consistent and uniform if a bit surprising at first glance. It turns out that we can usefully think of this as having three arguments and one result, but it doesn't really. It has one argument and one result. (It's just the result itself takes arguments!) Jules ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: let vs. where
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 wondering if there were any guidelines or preferences for one structure over the other. Currently my choice is guided by aesthetics more than anything else ( I prefer the look and ordering of a where clause). Is there anything else I should consider? What do veteran Haskell programmers prefer? I prefer the expression style. And I also like to order my definitions in a file bottom-up (basics first). But it may be more didactic to do it all top-down. Imports should be placed at the bottom of the file then, too. My cent, Christian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: let vs. where
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 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 'a' clearly isn't a function. Seems like a nice readable format to use. Probably everyone except me already knew this already though. -- Dan I recalled having used this trick in the regex-tdfa regular expression matching engine. There is an option for single-line vs multi-line matching that changes whether ^ and $ get tested against '\n'. By using this trick I was able to decide which matching to use once and that decision gets cached: matchHere regexIn offsetIn prevIn inputIn = ans where ans = if subCapture then runHerePure else noCap where subCapture = captureGroups (regex_execOptions regexIn) (1=rangeSize (bounds (regex_groups regexIn))) [...snip...] -- Select which style of ^ $ tests are performed. test | multiline (regex_compOptions regexIn) = test_multiline | otherwise = test_singleline where test_multiline Test_BOL _off prev _input = prev == '\n' test_multiline Test_EOL _off _prev input = case input of [] - True (next:_) - next == '\n' test_singleline Test_BOL off _prev _input = off == 0 test_singleline Test_EOL _off _prev input = null input -- Chris ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe