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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:48:37+00:00 2026-06-13T11:48:37+00:00

Here is my code: func :: Integer -> String func i = LoadC R

  • 0

Here is my code:

func :: Integer -> String
func i = "LoadC R" ++ i ++ "\n"

But I got the error:

Couldn’t match expected type `[Char]’ with actual type `Integer’

How do I convert i to char?

  • 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-06-13T11:48:38+00:00Added an answer on June 13, 2026 at 11:48 am

    Use show to turn a number into a string:

    func :: Integer -> String
    func i = "LoadC R" ++ show i ++ "\n"
    

    show works on lots of things (but not all).
    To actually print this, you need to do

    main = putStr (func 5)
    

    or if you’re using ghci (which I would recommend you use a lot while you write your code, testing everything as soon as you’ve written it), you can just write

    putStr (func 5)
    

    and it will work. (I’ll explain why below.)

    If you use putStrLn instead of putStr it puts an extra newline at the end.
    If you want a new line in what you’re printing, put \n in it wherever you like.

    func2 :: Integer -> String
    func2 i = "\nLoadC \nR\n" ++ show i ++ "\n"
    

    has lots of newlines in it.

    Why does putStr turn \n into newlines? Well, putStr and putStrLn have type String -> IO () meaning they turn the String they’re given into an IO program that puts it on the screen. In ghci, if you give it something of type IO (), it’ll do it. If you give it something of another type it’ll show it and then putStr that. This means that if you type

    "Hello\nMum"
    

    it has the same effect as

    putStrLn (show "Hello\nMum")
    

    whereas if you wanted the \n to be a newline, you’d need to do

    putStrLn "Hello\nMum"
    

    to stop ghci from showing it before putting it on the screen. (If you find yourself doing a lot of putStr (show x), there’s a shortcut: print x.)

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

Sidebar

Related Questions

[QueryInterceptor(Somethings)] public Expression<Func<Something, bool>> OnSomethings() { // Code here } I had a view
I want to create a dynamic Expression<Func<T,Y>> . Here is the code which works
Ok the error is showing up somewhere in this here code if($error==false) { $query
here is code for regular expression matching #include<iostream> #include<stdio.h> #include<string.h> using namespace std; int
here the code what is the actual role of timer,,other thing is which if(saving)
Here's my code: bool func(const MY_STRUCT *const ptr, some_struct *x, int y) { printf(IN:
I just browsed through C# in Depth and stumbled upon the following code: Func<string>
a piece of code here jmp_buf mark; int Sub_Func() { int be_modify, jmpret; be_modify
The script is on jsfiddle here : CODE What it does at the moment
Here is code my jqgrid editing through form. $(#DataEnergy).jqGrid('navGrid', '#pagergrid', {}, //options {editdata: {

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.