Skip to content

Instantly share code, notes, and snippets.

@lucassmagal
Created March 17, 2013 16:57
Show Gist options
  • Save lucassmagal/5182446 to your computer and use it in GitHub Desktop.
Save lucassmagal/5182446 to your computer and use it in GitHub Desktop.
Int -> Int -> Int
add a b = a + b
Para explicar, vamos trocar os 3 Int por X, Y, e Z, onde a:X, b:Y e c:a+b
X -> Y -> Z
quer dizer que a função recebe dois parâmetros, X e Y, e retorna Z.
Como em Haskell todas as funções são curryied, a expressão acima também quer
dizer que "add" recebe um parâmetro X e retorna *outra função*, que recebe Y
e então retorna Z. Aumentando um pouco, uma assinatura de função qualquer:
Int -> Int -> [Char] -> Int
foo a b c = d
# recebe 3 argumentos, 2 Int e uma string (String == [Char]) e retorna um Int
# "foo 2" retorna uma função, digamos, foo', que tem a seguinte assinatura
Int -> [Char] -> Int
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment