Re:The Day Python Embarassed Imperative Programming
by masklinn on Monday February 27, 2012 @09:04AM
(#3638970)
> Okay, so what does this mean? I thought it was `f x -> x * x` is a function definition, right? Or am I completely mistaken here?
In this case, it's a type signature for a curried function. So
a -> m b
is a function taking a value of type `a` and returning a value of type `m b`. In C# you would write:
Function<A, M<B>>
so `m a -> (a -> m b) -> m b` is a function taking a value of type `m a` and a function with signature `a -> m b` and returning a function of type `m b`. Translating to C# again,
Function< M<A>, Function<A, M<B>>, M<B> >
> Or am I completely mistaken here?
Pretty much yeah. In haskell, a function is either a top-level binding:
someFunction arg = doSomething arg
or an anonymous function which is introduced by the character `\` (because `\` looks like `λ`, kind-of):
\arg -> doSomething arg
In the expression you quoted, there is no function name, these are all types. The function name in this case is `(>>=)`
In this case, it's a type signature for a curried function. So
is a function taking a value of type `a` and returning a value of type `m b`. In C# you would write: so `m a -> (a -> m b) -> m b` is a function taking a value of type `m a` and a function with signature `a -> m b` and returning a function of type `m b`. Translating to C# again, > Or am I completely mistaken here?Pretty much yeah. In haskell, a function is either a top-level binding:
or an anonymous function which is introduced by the character `\` (because `\` looks like `λ`, kind-of): In the expression you quoted, there is no function name, these are all types. The function name in this case is `(>>=)`