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
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
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
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
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]
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
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
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
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.
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
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
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
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
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
14 matches
Mail list logo