Re: [Haskell-cafe] constant functions

2006-12-29 Thread ajb
G'day all. Quoting Matthew Brecknell [EMAIL PROTECTED]: Yes. Function application (-) is right-associative in a type expression. What about a value expression? f a b === (f a) b Looks like an inconsistency? Not if you think about it. :-) And if you don't want to think about it, this

Re: [Haskell-cafe] constant functions

2006-12-29 Thread Tomasz Zielonka
On Fri, Dec 29, 2006 at 03:36:45AM -0500, [EMAIL PROTECTED] wrote: And if you don't want to think about it, this should make everything clear: f :: A - (B - (C - D)) f a :: B - (C - D) (f a) b :: C - D ((f a) b) c :: d Nice illustration. It's as if the letters jumped over

Re: [Haskell-cafe] constant functions

2006-12-29 Thread David House
On 29/12/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: And if you don't want to think about it, this should make everything clear: My additions displayed below: f :: A - B - C - D f :: A - (B - (C - D)) By right-associativity of f. f a :: B - (C - D) (f a) b :: C - D ((f

[Haskell-cafe] constant functions

2006-12-27 Thread michael rice
I'm trying to learn Haskell and translating some Lisp functions as exercises. How would I write a Haskell function named ALWAYS that behaves like this: one = always 1 bozo = always clown map one [2,3,4,5,6] [1,1,1,1,1] one 62 1 map bozo [2,3,4,5,6] [clown,clown ,clown, clown, clown] bozo

Re: [Haskell-cafe] constant functions

2006-12-27 Thread Bryan Burgers
I'm trying to learn Haskell and translating some Lisp functions as exercises. How would I write a Haskell function named ALWAYS that behaves like this: one = always 1 bozo = always clown map one [2,3,4,5,6] [1,1,1,1,1] one 62 1 map bozo [2,3,4,5,6] [clown,clown ,clown, clown, clown]

Re: [Haskell-cafe] constant functions

2006-12-27 Thread Donald Bruce Stewart
nowgate: I'm trying to learn Haskell and translating some Lisp functions as exercises. How would I write a Haskell function named ALWAYS that behaves like this: one = always 1 bozo = always clown map one [2,3,4,5,6] [1,1,1,1,1] one 62 1 map bozo [2,3,4,5,6] [clown,clown

Re: [Haskell-cafe] constant functions

2006-12-27 Thread Matthew Brecknell
This is what I've been trying: always :: (a - a) - a - a always x = (\y - x) Your function implementation is correct, but the type is wrong. Try this: always :: a - b - a Or, just use the function const, from the Prelude. :-) The type system can be very handy when learning Haskell. If you

Re: [Haskell-cafe] constant functions

2006-12-27 Thread michael rice
Thanks! I figured I was close. Didn't even know const was available. I put together a compliment functions earlier complement :: (a - Bool) - a - Bool complement p x = not (p x) By the signature, the first argument is a function (predicate) which when given a value returns a Bool? And the

Re: [Haskell-cafe] constant functions

2006-12-27 Thread michael rice
Thanks Brian. I think these signatures are starting to make sense. And I didn't know _ (don't care) could be used like that. I'm liking Haskell more and more. Michael --- Bryan Burgers [EMAIL PROTECTED] wrote: I'm trying to learn Haskell and translating some Lisp functions as exercises.

Re: [Haskell-cafe] constant functions

2006-12-27 Thread Donald Bruce Stewart
nowgate: Thanks! I figured I was close. Didn't even know const was available. I put together a compliment functions earlier complement :: (a - Bool) - a - Bool complement p x = not (p x) By the signature, the first argument is a function (predicate) which when given a value returns

Re: [Haskell-cafe] constant functions

2006-12-27 Thread michael rice
Hi Donald, I think you misunderstood what I was asking. There's not two cases. Maybe I'm not saying it sufficiently well but the function ALWAYS just returns a function that always returns the original argument to ALWAYS no matter what else you give the resulting function. when one is define as

Re: [Haskell-cafe] constant functions

2006-12-27 Thread Donald Bruce Stewart
nowgate: Hi Donald, I think you misunderstood what I was asking. There's not two cases. Maybe I'm not saying it sufficiently well but the function ALWAYS just returns a function that always returns the original argument to ALWAYS no matter what else you give the resulting function. when

Re: [Haskell-cafe] constant functions

2006-12-27 Thread Brandon S. Allbery KF8NH
On Dec 27, 2006, at 22:55 , michael rice wrote: By similar reasoning the always function would seem to have a signature a - (b - a) where the first argument is just a value and the return value is a function that when given a possibly different value just returns the value originally given

Re: [Haskell-cafe] constant functions

2006-12-27 Thread Matthew Brecknell
complement :: (a - Bool) - a - Bool complement p x = not (p x) By the signature, the first argument is a function (predicate) which when given a value returns a Bool? And the second argument is just a value? And the function returns a Bool? Indeed. In the type expression, the lower-case