Reputation: 31
Suppose that the function gets as its input two variables of different types (e.g. one variable is int in the language of C, and one variable is char in the language of C) and returns one variable that is in Int
.
If this function is coded as Haskell or lambda calculus code, how would the function's type be?
So suppose that the function has type Int -> (Char -> Char) -> Int
. What would this mean? Would this mean that it receives int variable as input and runs function of (Char -> Char)
and outputs Int
variable?
Upvotes: 0
Views: 258
Reputation: 3273
A type of Int -> (Char -> Char) -> Int
would mean the function accepts an Int
and a function of type Char -> Char
as input, and outputs an Int
.
The function doesn't have to actually use its inputs per se. For example,
meetoosFunction :: Int -> (Char -> Char) -> Int
meetoosFunction _ _ = 42
*Main Data.Char> meetoosFunction 1 toUpper
42
Upvotes: 6