Re: Haskell conventions (was: RE: how to write a simple cat)

1999-06-15 Thread Jan de Wit
On Fri, 11 Jun 1999, Erik Meijer wrote: Personally I find the convention of using `a', `b', and `c' for type variables to be a poor one. I much prefer using `t' (if there's only one) or `t1', `t2', ... (if there's more than one). I find that for me this makes it much easier to

RE: Haskell conventions (was: RE: how to write a simple cat)

1999-06-11 Thread Frank A. Christoph
Jonathan King wrote: transformListElems :: (elem - elem') - List elem - List elem' transformListElems transform Nil = Nil transformListElems transform (Cons elem elemRest) = Cons (transform elem) (transformListElems transform elemRest) Well, the second version does more than

Re: Haskell conventions (was: RE: how to write a simple cat)

1999-06-11 Thread Keith Wansbrough
Jonathan King writes: So, the name of a type is always at least a full word, as are the names of specific functions. But type variables are almost always single characters, and distinct from the names of any type. Conventionally, they are also usually "a", "b", and "c", although "m" is for

Re: how to write a simple cat

1999-06-11 Thread Friedrich Dominicus
I disagree, small scripts spend most of the time doing I/O if I don't understand how to do that I'm not able to even write the most simple things. This is eg. true for my cat ... I disagree. You need to know more about Functional Programming (and also the Haskell type system and its IO

Re: Haskell conventions (was: RE: how to write a simple cat)

1999-06-11 Thread Craig Dickson
Jan Skibinski [EMAIL PROTECTED] wrote: But there are some stylistic camps, such as Eiffel's, that prefer names with underscores rather than Hungarian notation - claiming exactly the same reason: better readability. :-) I don't see that underscores serve readability in the same way as

Re: Haskell conventions (was: RE: how to write a simple cat)

1999-06-11 Thread Christian Sievers
So, the name of a type is always at least a full word, as are the names of specific functions. But type variables are almost always single characters, and distinct from the names of any type. Conventionally, they are also usually "a", "b", and "c", although "m" is for monad. Conventionally

Re: Haskell conventions (was: RE: how to write a simple cat)

1999-06-11 Thread Jan Skibinski
On Fri, 11 Jun 1999, Craig Dickson wrote: I don't see that underscores serve readability in the same way as Hungarian notation purports to (unless the Eiffel people claim that underscores somehow convey type information?), so I don't see a conflict here. One could easily use both, e.g.

Re: Haskell conventions (was: RE: how to write a simple cat)

1999-06-11 Thread Jan Skibinski
I think this kind of thing is valuable... Hungarian notation [1] serves the same purpose in Windows C / C++ programming. It *is* valuable having canonical variable names for most situations; it reduces the intellectual load on the (human) reader of the code... you don't have to check

Re: how to write a simple cat

1999-06-10 Thread Rainer Joswig
At 16:37 Uhr +0200 09.06.1999, Friedrich Dominicus wrote: I think exercise with the purely functional, non-I/O core (and perhaps interact like someone else suggested) teaches you the mode of thinking in purely functional languages. That thinking can also help you understand the way I/O

Re: how to write a simple cat

1999-06-10 Thread Fergus Henderson
On 09-Jun-1999, Friedrich Dominicus [EMAIL PROTECTED] wrote: What's a HOF? HOF is an acronym for Higher-Order Function. -- Fergus Henderson [EMAIL PROTECTED] | "I have always known that the pursuit WWW: http://www.cs.mu.oz.au/~fjh | of excellence is a lethal habit" PGP: finger [EMAIL

RE: how to write a simple cat

1999-06-10 Thread Frank A. Christoph
What is difficult is that by using some predefined function, one can express very much in very small code. I believe Haskell is even more expressive than most OO languages with comparable libraries (perhaps except Smalltalk, as that has also a very compact syntax). I havn't

Re: how to write a simple cat

1999-06-10 Thread Lars Lundgren
On Wed, 9 Jun 1999, Friedrich Dominicus wrote: [snip] What's a HOF? A Higher Order Function, the key to code reuse and abstraction. that first splits something up to a list using splitFn (or with the generalization I mentioned, to a monad), then maps a function over that list (namely

RE: how to write a simple cat

1999-06-10 Thread CC700110
] Subject: Re: how to write a simple cat At 16:37 Uhr +0200 09.06.1999, Friedrich Dominicus wrote: I think exercise with the purely functional, non-I/O core (and perhaps interact like someone else suggested) teaches you the mode of thinking in purely functional languages

Haskell conventions (was: RE: how to write a simple cat)

1999-06-10 Thread Jonathan King
Well, the cat has been skinned and boned, but I think I see a shread of meat or two that hasn't been picked over yet... On Thu, 10 Jun 1999, Frank A. Christoph wrote: [some attributions missing...I hope you know who you are] [big snip, about the fact that Haskell programs can be quite brief]

Re: how to write a simple cat

1999-06-09 Thread Hannah Schroeter
Hello! On Fri, Jun 04, 1999 at 12:18:31PM +0200, Friedrich Dominicus wrote: [...] splitFilterMap unSplitFn afterMap filterPredicate beforeMap splitFn = unSplitFn . map afterMap . filter filterPredicate . map beforeMap . splitFn [...] sorry this looks morre terrible to me than all

Re: how to write a simple cat

1999-06-09 Thread Hannah Schroeter
Hello! On Wed, Jun 02, 1999 at 01:29:12AM -0700, Simon Peyton-Jones wrote: [...] - Would people actually add stuff? I'm a bit skeptical, but it would be great to have my skepticism proved unfounded. I think, Friedrich and those who helped him could have posted their questions and

Re: how to write a simple cat

1999-06-09 Thread Friedrich Dominicus
Hannah Schroeter wrote: Hello! On Fri, Jun 04, 1999 at 12:29:45PM +0200, Friedrich Dominicus wrote: [...] What is difficult is that by using some predefined function, one can express very much in very small code. I believe Haskell is even more expressive than most OO languages

Re: how to write a simple cat

1999-06-09 Thread Hannah Schroeter
Hello! On Fri, Jun 04, 1999 at 12:29:45PM +0200, Friedrich Dominicus wrote: [...] What is difficult is that by using some predefined function, one can express very much in very small code. I believe Haskell is even more expressive than most OO languages with comparable libraries

Re: how to write a simple cat

1999-06-07 Thread Christoph Lueth
Hans Aberg [EMAIL PROTECTED] writes: Exactly how is this connection between the lambda calculus and category theory described? -- That is, one would expect to know that if one has a category of some sort, it is equivalent to the lambda calculus, or something like that. There is a very

Re: how to write a simple cat

1999-06-05 Thread Friedrich Dominicus
Lennart Augustsson wrote: Friedrich Dominicus wrote: That might be good advice but I/O is one of the most essential things and I have to know how to use it proper for writing small skripts. Actually, you can do a lot without learning about I/O. The function `interact' converts a

Re: how to write a simple cat

1999-06-04 Thread Hannah Schroeter
Hello! On Wed, Jun 02, 1999 at 08:12:04AM +0200, Friedrich Dominicus wrote: [...] this seems to to the thing I would like it to do. I now have to check if the given fn is valid and raise an error if not so I do think I'll make it;-) No you don't have to check fn. readFile checks and throws

Re: how to write a simple cat

1999-06-04 Thread Friedrich Dominicus
Then split it up like you'd do in an OO language. I think, FP also is good for writing small functions that do one thing well, and then composing them in various ways (as you see, composing functions (and perhaps also values) in Haskell is possible in very many various ways :-) ). In the

Re: how to write a simple cat

1999-06-04 Thread Mariano Suarez-Alvarez
On Thu, 3 Jun 1999, Hans Aberg wrote: A ``category with + and ^ '' is called cartesian closed aditive category, cf MacLane, Category Theory for the Working Mathematician Is this a suggestion or a theorem? A definition. -- m

Re: how to write a simple cat

1999-06-04 Thread Hans Aberg
At 14:18 +0200 1999/06/04, Mariano Suarez-Alvarez wrote: A ``category with + and ^ '' is called cartesian closed aditive category, cf MacLane, Category Theory for the Working Mathematician Is this a suggestion or a theorem? A definition. I did not see the connection between the + and ^ of

Re: how to write a simple cat

1999-06-04 Thread Lennart Augustsson
Friedrich Dominicus wrote: That might be good advice but I/O is one of the most essential things and I have to know how to use it proper for writing small skripts. Actually, you can do a lot without learning about I/O. The function `interact' converts a `String-String' function into an IO

Re: how to write a simple cat

1999-06-04 Thread Friedrich Dominicus
So after I read in a chunk form that file into one large String, lines splits that line on a '\n' position. The lines li are filtered and l is one line a String-List which is added to fl all the filterd lines are then put back into on large String. Uff. Is that nearly correct? Yes,

Re: how to write a simple cat

1999-06-03 Thread Hannah Schroeter
Hello, Friedrich. On Tue, Jun 01, 1999 at 04:04:42PM +0200, Friedrich Dominicus wrote: [...] longerThan :: String {- filename -} - Int {- length limit -} - IO () longerThan fn lenlim = do content - readFile fn let li = lines content fl = filter (\l - length l lenlim)

Re: how to write a simple cat

1999-06-03 Thread Hans Aberg
At 20:08 +0200 1999/06/03, Mariano Suarez-Alvarez wrote: A ``category with + and ^ '' is called cartesian closed aditive category, cf MacLane, Category Theory for the Working Mathematician Is this a suggestion or a theorem? Hans Aberg * Email: Hans Aberg mailto:[EMAIL

Re: how to write a simple cat

1999-06-03 Thread Mariano Suarez-Alvarez
On Wed, 2 Jun 1999, Hans Aberg wrote: But it can be a spin-off for thoughts: A category is essentially an object with I and *, and a functor is a map preserving those. So what about the two other operations, + and ^ ?. A ``category with + and ^ '' is called cartesian closed aditive category,

RE: how to write a simple cat

1999-06-02 Thread Frank A. Christoph
Do you want to drive me away from learning Haskell? Who the hell can try to write such functions? Is readabilty not a concern in Haskell? I would have to agree, Sven does seem to be working hard to drive a beginner away from Haskell. But he is illustrating an important coding

RE: how to write a simple cat

1999-06-02 Thread Simon Peyton-Jones
I know, we all have something else to do than to take on extra responsibilities. But if someone could donate an access to a fast web server (mine is just too slow) then we could go along Wiki-Wiki Web Server concepts (http://c2.com:8080/WikiWikiWeb) and have

RE: how to write a simple cat

1999-06-02 Thread Peter Hancock
"Hans" == Hans Aberg [EMAIL PROTECTED] writes: One reason flip(.) might be given a symbol similar to multiplication and flip($) a symbol similar to exponentiation is that on the Church integer functionals, these two operations are just the multiplication and exponentiation

RE: how to write a simple cat

1999-06-02 Thread Hans Aberg
At 12:44 +0100 1999/06/02, Peter Hancock wrote: One reason flip(.) might be given a symbol similar to multiplication and flip($) a symbol similar to exponentiation is that on the Church integer functionals, these two operations are just the multiplication and exponentiation of

RE: how to write a simple cat

1999-06-02 Thread Jan Skibinski
haskell.org is the obvious place. I'm sure John Peterson would be happy to add stuff to the site. Community-generated FAQ pages sound great, but - Some (standard? readily-available?) technology is needed to allow people to add stuff without intervention from the site organiser.

Re: how to write a simple cat

1999-06-02 Thread Sven Panne
Hans Aberg wrote: [...] Then together with the identity I, +, * and ^ can be written out to be a primitive set for the lambda theory. That is, all lambda expressions can be generated from these symbols. Impressive! %-) Hmmm, I just thought about the possible directions of this discussion if

Re: how to write a simple cat

1999-06-02 Thread Friedrich Dominicus
At first, thanks to all of you about this nice insight into FP used programmers. It was really a suprise to me to see that that what Sven wrote seems to be easily understood. I would really like to see such code-snippets to found on a central site what about www.haskell.org ? I reread my book

RE: how to write a simple cat

1999-06-02 Thread trb
Simon Peyton-Jones writes: Community-generated FAQ pages sound great, but - Some (standard? readily-available?) technology is needed to allow people to add stuff without intervention from the site organiser. The Wiki-Wiki-Web stuff indeed looks like a real possibility. I didn't

RE: how to write a simple cat

1999-06-02 Thread Hans Aberg
At 11:57 +0900 1999/06/02, Frank A. Christoph wrote: I just wish a standard operator is chosen for a) flip (.) and b) flip ($) instead of having everyone make up their own. I don't really care what it is. I truthfully like . for flip (.) and # for flip ($) but I can easily change. The

Re: how to write a simple cat

1999-06-02 Thread Laszlo Nemeth
Hans Aberg wrote: But it can be a spin-off for thoughts: A category is essentially an object with I and *, and a functor is a map preserving those. So what about the two other operations, + and ^ ?. I somehow managed to delete Hans's earlier post in which he gives the definitions for + and

Re: how to write a simple cat

1999-06-02 Thread Hans Aberg
At 16:46 +0200 1999/06/02, Sven Panne wrote: [...] Then together with the identity I, +, * and ^ can be written out to be a primitive set for the lambda theory. That is, all lambda expressions can be generated from these symbols. Impressive! %-) Hmmm, I just thought about the possible

Re: how to write a simple cat

1999-06-01 Thread Friedrich Dominicus
Hannah Schroeter wrote: Hello! On Mon, May 31, 1999 at 06:01:31PM +0200, Friedrich Dominicus wrote: Hannah Schroeter wrote: Hello! On Fri, May 28, 1999 at 08:00:27AM +0200, Friedrich Dominicus wrote: I wrote before with my trouble understanding hugsIsEOF. But I don't have

Re: how to write a simple cat

1999-06-01 Thread Hannah Schroeter
Hello! On Tue, Jun 01, 1999 at 06:58:32AM +0200, Friedrich Dominicus wrote: [...] I want to do the following, read a file line by line and finding out which line is longer than x-chars. I want to print out which lines are so long. I think that can just be done line-wise. Thanks for you

Re: how to write a simple cat

1999-06-01 Thread Sven Panne
Hannah Schroeter wrote: [...] So, still no need to fuzz with file handles :-) ... and no need to fuzz with intermediate names, either. :-) If you define an operator for reversed function composition (.|) = flip (.) and read it like a pipe in *nix, you get a one-liner: longerThan fn

Re: how to write a simple cat

1999-06-01 Thread Friedrich Dominicus
Hannah Schroeter wrote: Hello! On Tue, Jun 01, 1999 at 06:58:32AM +0200, Friedrich Dominicus wrote: [...] I want to do the following, read a file line by line and finding out which line is longer than x-chars. I want to print out which lines are so long. I think that can just be

Re: how to write a simple cat

1999-06-01 Thread S. Alexander Jacobson
It would be nice if the prelude defined more general functions like: splitStr c s = left:case right of [] - []; otherwise - splitStr c (tail right) where (left,right)=span (/=c) s joinStr c l = case l of []- []; otherwise - foldl1 (\x y-x++c:y) l The implementation of lines and unlines

Re: how to write a simple cat

1999-06-01 Thread Sven Panne
Friedrich Dominicus wrote: [...] How can I combine the output with a line-number can I put that into the filter? Or do I have to found another solution? Don't fear! Mr. One-Liner comes to the rescue:;-) longerThan fn lenlim = readFile fn = lines .| filter (length .| (lenlim)) .| zip

Re: how to write a simple cat

1999-06-01 Thread Kevin Atkinson
Keith Wansbrough wrote: Sven Panne wrote: Don't fear! Mr. One-Liner comes to the rescue:;-) longerThan fn lenlim = readFile fn = lines .| filter (length .| (lenlim)) .| zip [1..] .| map (\(n,l) - shows n ") " ++ l) .| unlines .| putStr Friedrich wrote: Do you want to

Re: how to write a simple cat

1999-06-01 Thread Lars Henrik Mathiesen
Date: Tue, 01 Jun 1999 17:32:22 +0200 From: Sven Panne [EMAIL PROTECTED] Don't fear! Mr. One-Liner comes to the rescue:;-) longerThan fn lenlim = readFile fn = lines .| filter (length .| (lenlim)) .| zip [1..] .| map (\(n,l) - shows n ") " ++ l) .| unlines .| putStr Are you sure

Re: how to write a simple cat

1999-06-01 Thread Lennart Augustsson
Keith Wansbrough wrote: Sven Panne wrote: Don't fear! Mr. One-Liner comes to the rescue:;-) longerThan fn lenlim = readFile fn = lines .| filter (length .| (lenlim)) .| zip [1..] .| map (\(n,l) - shows n ") " ++ l) .| unlines .| putStr Friedrich wrote: Do you want to

Re: how to write a simple cat

1999-06-01 Thread Jan Skibinski
On Tue, 1 Jun 1999, Sven Panne wrote: Friedrich Dominicus wrote: [...] How can I combine the output with a line-number can I put that into the filter? Or do I have to found another solution? Don't fear! Mr. One-Liner comes to the rescue:;-) How about initiating Haskell

Re: how to write a simple cat

1999-06-01 Thread Keith Wansbrough
Sven Panne wrote: Don't fear! Mr. One-Liner comes to the rescue:;-) longerThan fn lenlim = readFile fn = lines .| filter (length .| (lenlim)) .| zip [1..] .| map (\(n,l) - shows n ") " ++ l) .| unlines .| putStr Friedrich wrote: Do you want to drive me away from learning

Re: how to write a simple cat

1999-05-31 Thread Friedrich Dominicus
Hannah Schroeter wrote: Hello! On Fri, May 28, 1999 at 08:00:27AM +0200, Friedrich Dominicus wrote: I wrote before with my trouble understanding hugsIsEOF. But I don't have found a clean way just to write a cat. Can s.o give me a hand? import System(getArgs) file2stdout :: String {-

Re: how to write a simple cat

1999-05-31 Thread Hannah Schroeter
Hello! On Mon, May 31, 1999 at 06:01:31PM +0200, Friedrich Dominicus wrote: Hannah Schroeter wrote: Hello! On Fri, May 28, 1999 at 08:00:27AM +0200, Friedrich Dominicus wrote: I wrote before with my trouble understanding hugsIsEOF. But I don't have found a clean way just to write a

Re: how to write a simple cat

1999-05-28 Thread David Overton
On Fri, May 28, 1999 at 04:00:27PM EST, Friedrich Dominicus wrote: I wrote before with my trouble understanding hugsIsEOF. But I don't have found a clean way just to write a cat. Can s.o give me a hand? Hi, You shouldn't need to use hugsIsEOF. Here's one possible implementation of a

Re: how to write a simple cat

1999-05-28 Thread Keith Wansbrough
module Main ( main ) where import IO import System main :: IO () main = do args - getArgs s - case args of []- getContents [inF] - readFile inF _ - fail "Sorry, only 0 or 1 args implemented" putStr s --KW 8-) -- :