joesan
joesan

Reputation: 15345

Haskell Beginner Error with GHCi

I'm on my Mac trying out Haskell and to my surprise, when I defined a function, I got an error:

Prelude System.IO> :set prompt "ghci> "
ghci> addMe :: Int -> Int -> Int

<interactive>:11:1: error:
    Variable not in scope: addMe :: Int -> Int -> Int
ghci>

How can I define functions on the ghci?

Upvotes: 2

Views: 408

Answers (1)

Aerron
Aerron

Reputation: 330

If you want to add a type signature to a definition in GHCi, you can specify it by using multiline input through :set +m or :{ ... :}, as described in the GHC Users Guide, or by using semicolons, as in:

mulme x y = [x*y| x /= 0, y/= 0]; mulme :: Int -> Int -> [Int]

Upvotes: 2

Related Questions