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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:21:13+00:00 2026-06-09T03:21:13+00:00

I am able to run the code below in terminal which is in respondPalindromes.hs

  • 0

I am able to run the code below in terminal which is in respondPalindromes.hs file but failing to test the same in emacs.

respondPalindromes = unlines . map (\xs -> if isPalindrome xs then “palindrome” else “not a palindrome”) . lines
where isPalindrome xs = xs == reverse xs
main = interact respondPalindromes

Below is the terminal details:

optimight@optimight:~$ cat words.txt | runhaskell respondPalindromes.hs
not a palindrome
palindrome
palindrome
palindrome

Below is the Emacs haskell-mode details:

*Main> :load “/home/optimight/respondPalindromes.hs”
[1 of 1] Compiling Main ( /home/optimight/respondPalindromes.hs, interpreted )
Ok, modules loaded: Main.
*Main> :! cat words.txt | ./respondPalindromes.hs
/bin/sh: 1: ./respondPalindromes.hs: Permission denied
*Main> :! cat words.txt | ./respondPalindromes
/bin/sh: 1: ./respondPalindromes: not found
*Main>

Edit after Dietrich Epp’s answer:

*Main> !: cat words.txt | runhaskell respondPalindromes.hs
:12:1: parse error on input `!:’

*Main> cat words.txt | runhaskell respondPalindromes.hs
:13:15: parse error on input `|’
*Main>

  • 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-09T03:21:15+00:00Added an answer on June 9, 2026 at 3:21 am

    In the regular terminal window, you run this command:

    cat words.txt | runhaskell respondPalindromes.hs
    

    But in the Haskell window, you run the following shell command:

    cat words.txt | ./respondPalindromes.hs
    

    Why run a different command, if the first one works fine?

    These are just ordinary shell commands. If you haven’t set up respondPalindromes.hs as an executable, then it won’t run as an executable, you have to use runhaskell in order to execute it.

    Furthermore, if you run the program this way (by executing a shell command from inside the Haskell interactive shell), there’s no point to using a fancy Haskell shell. You might as well be using an ordinary shell.

    Instead, you may want to avoid the shell altogether, such as:

    readFile "words.txt" >>= respondPalindromes >>= putStr
    

    The >>= operator in Haskell is kind of like the | pipe in the shell.

    Summary: The :! command executes an ordinary shell command, it doesn’t have anything to do with Haskell.

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

Sidebar

Related Questions

I would like to be able to run a nose test script which accepts
I have some code below which will not run due to me not being
Just wondering, in my opinion the code below is able to run a second
(Please see the code Code below) I am able to run it on Tomcat
Sorry for the lengthy code below, my code is able to execute and run
I have been working on information extraction and was able to run standAloneAnnie.java http://gate.ac.uk/wiki/code-repository/src/sheffield/examples/StandAloneAnnie.java
I was able to successfully run an RF model using some R code I
I want to be able to run Junit tests from the command line, but
I need to be able to run an Oracle query which goes to insert
I'm trying to run the code below to insert a whole lot of records

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.