Has an error occurred while entering a function type in GHCi?
$ ghci
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
Prelude> function3 :: Int -> [Int]
<interactive>:1:1: error:
Variable not in scope: function3 :: Int -> [Int]
Prelude>
If so, you should use multiple lines of input
Prelude> :{
Prelude| function3 :: Int -> [Int]
Prelude| function3 x = [a | a <- [1..x], mod a x == 0]
Prelude| :}
And noted ,beforemod
Alternatively, to improve your workflow, you can save your code in a file and upload to GHCi using : download
$ cat tmp/functions.hs
function3 :: Int -> [Int]
function3 x = [a | a <- [1..x], mod a x == 0]
$ ghci
GHCi, version 8.0.1: http://www.haskell.org/ghc/ :? for help
Prelude> :l tmp/functions.hs
[1 of 1] Compiling Main ( tmp/functions.hs, interpreted )
Ok, modules loaded: Main.
*Main> :t function3
function3 :: Int -> [Int]
*Main>
source
share