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 7628259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:34:16+00:00 2026-05-31T05:34:16+00:00

This function allows the user to input a list of strings. The function takes

  • 0

This function allows the user to input a list of strings. The function takes the length and allows the user to input length-1 more lines. Then each line is checked to ensure it is the same length as the original line. The code:

readme :: IO [Line]
readme = do
 line <- readLn
 let count = length line
 lines <- replicateM (count-1) $ do 
  line <- readLn
  if length line /= count 
  then fail "too long or too short"
  else return line 
 return $ line : lines

Line is of type String.

When I try to run the function and input.. say [“12″,”13”] I get the following: * Exception: user error (Prelude.readIO: no parse) and I can’t figure out why, any ideas?

  • 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-31T05:34:16+00:00Added an answer on May 31, 2026 at 5:34 am

    It’s because you are trying to read something with the wrong type.

    You say that Line is a String aka. [Char]. However, the input you are typing is of the format ["12", "13"] which looks like it should have type [Line], aka. [String] or [[Char]].

    You need to explain what a Line is actually supposed to be. If you want a Line to be a string, then why are you entering lists of strings at the terminal? Something is wrong with your logic in this case.

    If you want a method for inputting square matrices, you can let type Line = [Int] instead, and use one of these formats:

    -- What you type at the terminal:
    1 -2 3
    4 5 6
    6 7 8
    
    -- How to read it in your program:
    line <- (map read . words) `fmap` getLine
    
    -- What you type at the terminal:
    [1, -2, 3]
    [4, 5, 6]
    [6, 7, 8]
    
    -- How to read it in your program:
    line <- readLn
    

    If you really want to input lines, so that type Line = [Char], and that each number in the input list becomes a unicode character, meaning that when you enter [97, 98, 99] on the terminal, you get the string "abc":

    -- What you type at the terminal:
    [97, 98, 99]
    [100, 101, 102]
    [103, 104, 105]
    
    -- How to read it in your program:
    line <- (map toEnum) `fmap` readLn
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

def sortProfiles(p): return sorted(p, key=itemgetter('first_name')) I have a list with dictionaries. This function allows
I have a jQuery function that allows a user to create a list of
I'm trying to implement a function which allows the user to input some type
I've got a phone number input field, which allows a user to add a
I have a TextArea that allows user input. I also have TextInput that the
Is there an API function call for this board that would allow me to
This function appears to be a way to access all sorts of system values.
This function declaration gives me errors: ostream& operator<<(ostream& os, hand& obj); The errors are:
This function is written in ActionScirpt. What kind of decryption this is? Is there
This function of mine keeps on failing an autograder, I am trying to figure

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.