首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Leksah默认hello world在安装Xubuntu 13.10后无法工作

Leksah默认hello world在安装Xubuntu 13.10后无法工作
EN

Stack Overflow用户
提问于 2014-01-10 21:28:47
回答 3查看 633关注 0票数 1

我已经从终端在Xubuntu 13.10上安装了Leksah 0.12.1.3。

代码语言:javascript
复制
sudo apt-get install leksah

打开leksah,创建新的工作区和包。默认情况下,使用'Hello world‘程序创建Main.hs。

代码语言:javascript
复制
module Main (
    main
) where

import Control.Monad (unless)
import Data.List (stripPrefix)
import System.Exit (exitFailure)
import Test.QuickCheck.All (quickCheckAll)

-- Simple function to create a hello message.
hello s = "Hello " ++ s

-- Tell QuickCheck that if you strip "Hello " from the start of
-- hello s you will be left with s (for any s).
prop_hello s = stripPrefix "Hello " (hello s) == Just s

-- Hello World
exeMain = do
    putStrLn (hello "World")   

-- Entry point for unit tests.
testMain = do
    allPass <- $quickCheckAll -- Run QuickCheck on all prop_ functions
    unless allPass exitFailure

-- This is a clunky, but portable, way to use the same Main module file
-- for both an application and for unit tests.
-- MAIN_FUNCTION is preprocessor macro set to exeMain or testMain.
-- That way we can use the same file for both an application and for tests.
#ifndef MAIN_FUNCTION
#define MAIN_FUNCTION exeMain
#endif
main = MAIN_FUNCTION

现在,如果我试图在右下角的窗口中运行包,或者在编辑器中编写任何东西

========== 127 ==========================

就会出现。

EN

回答 3

Stack Overflow用户

发布于 2014-01-11 01:57:20

这种事经常发生在我身上...我不知道原因是什么,但(至少在我的情况下)我知道我可以通过使用命令行来解决这个问题。我只需"cd“进入包含该软件包的目录(包含*.cabal文件的那个目录),然后输入

代码语言:javascript
复制
cabal configure
cabal build

完成此操作后,Leksah将正常工作。显然,这是一个Leksah错误,但它很容易解决。

票数 2
EN

Stack Overflow用户

发布于 2014-01-11 06:10:00

问题出在我天真地假设'apt-get install leksah‘会安装所有需要的包。然而,这是不正确的。

在安装leksah之后,您将需要:

代码语言:javascript
复制
apt-get install cabal-install
apt-get install ghc
cabal update

之后,正如jamshidh所提到的,您需要单击package->cofigure。

现在使用以下命令构建刹车(对于正在发布的程序,这是leksah自动生成的默认值):

代码语言:javascript
复制
Couldn't match type `IO' with `[]'
Expected type: String
  Actual type: IO ()
In the first argument of `putStrLn', namely `testMain'
In the expression: putStrLn testMain
In an equation for `main': main = putStrLn testMain

但我设法构建了简单得多的版本:

代码语言:javascript
复制
module Main (
  main
) where
main = putStrLn "Hello World"
票数 1
EN

Stack Overflow用户

发布于 2014-03-05 14:08:00

默认hello world的问题是下面这行:

代码语言:javascript
复制
putStrLn (hello "World")   

这只是因为左引号没有放在正确的位置。将其更改为

代码语言:javascript
复制
putStrLn ("hello World")   

它应该是有效的。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21045586

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档