Learn You a Haskell

So I decided to actually sit down and Learn Me a Haskell.

Worked through the first few sections. Kind of what I knew already except I think I’m getting a glimmer of why Currying / Partial Application is a good idea, at least in that it’s a very concise way of making higher-order functions on the fly.

Eg. :
Haskell

f x y = x * y
g = f 5

Python

def f(y) :
    return (lambda x : x * y)
g = f(5)

Haskell is certainly a lot more concise. And in Python you need to explicitly decide you want to make a function which makes multiplying functions. f only has that role. In Haskell f can be both a 2 argument multiply function AND a higher-order function factory.

Clever!


Posted

in

by

Tags: