【发布时间】:2012-08-07 00:50:54
【问题描述】:
我可以在 respondPalindromes.hs 文件中的终端中运行下面的代码,但在 emacs 中测试失败。
respondPalindromes = unlines 。 map (\xs -> if isPalindrome xs then "palindrome" else "not a palindrome") 。线路
其中 isPalindrome xs = xs == 反向 xs
main = 交互响应回文
以下是终端详情:
optimight@optimight:~$ cat words.txt | runhaskell respondPalindromes.hs
不是回文
回文
回文
回文
以下是 Emacs haskell 模式的详细信息:
*Main> :load "/home/optimight/respondPalindromes.hs"
[1 of 1] 编译 Main(/home/optimight/respondPalindromes.hs,解释)
好的,已加载模块:Main.
*主要> :!猫话.txt | ./respondPalindromes.hs
/bin/sh: 1: ./respondPalindromes.hs: 权限被拒绝
*主要> :!猫话.txt | ./respond回文
/bin/sh: 1: ./respondPalindromes: 未找到
*主>
根据 Dietrich Epp 的回答进行编辑:
*Main> !: cat words.txt | runhaskell respondPalindromes.hs
:12:1: 解析输入错误 `!:'*Main> cat words.txt | runhaskell respondPalindromes.hs
:13:15: 输入 `|' 解析错误
*主>
【问题讨论】:
-
在您的编辑中,您使用了
runhaskell,但切换了!和:。我认为应该是:! cat words.txt | runhaskell respondPalindromes.hs,而不是!: cat words.txt | runhaskell respondPalindromes.hs。 -
如果你想在没有
runhaskell的情况下也能运行./respondPalindromes.hs,添加一个shebang行;也就是说,将行#!/usr/bin/env runhaskell添加为文件的第一行。
标签: haskell emacs haskell-platform haskell-mode