creating functions in haskell
Creating Functions in Haskell
To create functions in Haskell, you can follow the syntax:
functionName :: Type1 -> Type2 -> ... -> TypeN -> ReturnType
functionName arg1 arg2 ... argN = functionBody
Here's an example of a simple function that adds two numbers:
add :: Int -> Int -> Int
add x y = x + y
In this example, the function add
takes two arguments of type Int
and returns an Int
. The function body is x + y
, which adds the two arguments together.
You can define functions with multiple arguments by separating them with spaces. The function body can be any valid Haskell expression.
Let me know if you need further assistance!