Created
March 17, 2013 16:57
-
-
Save lucassmagal/5182446 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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