Title here
Summary here
Haskell has built-in support for multiple return values through tuples. This feature is often used in idiomatic Haskell, for example to return both result and error values from a function.
To run the program, save it as multiple-return-values.hs
and use runhaskell
:
In Haskell, tuples are used to return multiple values from a function. Pattern matching is used to destructure these tuples and assign values to variables. The wildcard pattern _
is used to ignore values you don’t need, similar to the blank identifier in other languages.
Accepting a variable number of arguments is another feature available in Haskell; we’ll look at this concept next.