Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6919623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:00:52+00:00 2026-05-27T10:00:52+00:00

I am having problem in entering multi-line commands in ghci. The following 2-line code

  • 0

I am having problem in entering multi-line commands in ghci.

The following 2-line code works from a file:

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

But when I enter in ghci, I get an error:

<interactive>:1:1: error:
    Variable not in scope: addTwo :: Int -> Int -> Int

I also tried putting the code inside :{ ... :}, but they are also not working for this example, because this is just appending the lines into one line, which should not be the case.

I am using WinGHCi, version 2011.2.0.1

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:00:52+00:00Added an answer on May 27, 2026 at 10:00 am

    Most of the time, you can rely on type inference to work out a signature for you. In your example, the following is sufficient:

    Prelude> let addTwo x y = x + y
    

    If you really want a definition with a type signature, or your definition spans over multiple lines, you can do this in ghci:

    Prelude> :{
    Prelude| let addTwo :: Int -> Int -> Int
    Prelude|     addTwo x y = x + y 
    Prelude| :}
    Prelude> addTwo 4 7
    11
    

    Note that you can also squeeze this onto one line:

    Prelude> let addTwo :: Int -> Int -> Int ; addTwo x y = x + y
    

    You can find out more about interacting with ghci on the Interactive evaluation at the prompt section of the documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem with hover on images. When entering the site the hover-state
I'm having problem with datagrid view. I have attached an image with the code
I am having problem with drawing multiple lines during repaint. The code is as
I'm having a problem with my Facebook competition where users are entering multiple times.
I'm having a problem calling an outside application from a compiled ocaml application, pdflatex.
I'm having the following problem with a JFileChooser: I create a save dialog and
I am having a problem with Scrapy, for some reason it is not entering
I am having a problem connecting to MS SQL 2005 from PHP. I am
I'm having a problem breaking out of this while loop in my code. If
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.