I have recently started programming and have to learn abit about Haskell. I was told that we need to define types of the function. I have a simple function that works out the factorial of numbers, but when I add a definition type above the functions fails to load properly in winGHCi. We are told to just write the function in notepad and save it as .hs and open in Haskell. This is the function:

function :: Int -> Int factorial n = factorialWorker n 1 where factorialWorker n res | n > 1 = factorialWorker (n - 1) (res * n) | otherwise = res

It works fine without the first line. Have I just not wrote the definition type in correctly or should I just leave it out altogether? The error code I get is

test.hs:1:1: The type signature for `function' lacks an accompanying binding

I really appreciate anyone that can help me out

Thanks