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>