factorial :: Integer -> Integer
factorial n = product [1..n]
The following is fine:
let factorial n = product [1..n]
I do not see how to add type declarations in interactive shell.
factorial :: Integer -> Integer
factorial n = product [1..n]
The following is fine:
let factorial n = product [1..n]
I do not see how to add type declarations in interactive shell.
If you want to specify the type signature yourself you can do this in ghci using semicolons, i.e.:
let factorial :: Integer -> Integer; factorial n = product [1..n]
Next to the multi-line settings explained here, you can use this instead if you don't want to write semicolons.
λ> :{
λ> | let factorial :: Integer -> Integer
λ> | factorial n = product [1..n]
λ> :}
λ> :t factorial
factorial :: Integer -> Integer