This is the next question of this . I think I misunderstood which type is for Haskell, so hopefully a better question is posed:
I want to have a function that can be called with exactly two arguments. These arguments must be of different types. For example, one is a string and the other is an integer.
Consider this application:
combine "100" 500 -- results in 100500
combine 100 "500" -- results in 100500
combine 100 500 -- raises an exception
combine "100" "500" -- raises an exception
It is not difficult to write a specific implementation; for me, however, the problem is to give this function the correct signature.
I would also be interested to know if there is a more general solution (that is, it does not require specifying specific types, but only prescribes that the types be different. So, for example, you could use this function to “capture” the input data for other functions if they can be fixed by rearranging the arguments.
Thank!
EDIT:
below is an inaccurate copy of what I expected from her in Erlang ... well, I hope this makes sense, as it should be very similar ...
combine([String], Int)->
io:fwrite("~s~w~n", [[String], Int]);
combine(Int, [String])->
combine([String], Int).
user797257
source
share