Help with the SUMA function in Haskell ghci

-1

Use ghci in notepad ++

I have the following function:

suma :: (Integer, Integer) -> (Integer)
suma (x,y) = x + y

Running this on the console:

*Main> suma (3,5)

I get the following error:

<interactive>:6:1: error:
    * Variable not in scope: suma :: (Integer, Integer) -> t
    * Perhaps you meant 'sum' (imported from Prelude)
    
asked by Oren Diaz 31.10.2017 в 00:04
source

2 answers

0

I found my own mistake. Maybe someone will serve you.

At first I had written the% SUMAR termination wrong and I saved that error. You have to recompile after rewriting the function. First in the console you have to put :r and then re-invoke the function with their respective parameters sumar (3,5)

    
answered by 31.10.2017 в 00:27
0

The haskell parameters do not have that syntax, when writing sum (x, y) it will work but you are really passing a tuple. The correct syntax in this case would be:

suma :: Int -> Int -> Int
suma x y = x + y

As you can see, in haskell every meter is separated by spaces, also when calling the serious function:

suma 2 2 
    
answered by 23.12.2017 в 08:20