1

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

sudo apt-get install leksah

打开 leksah,创建新的工作区和包。Main.hs 默认使用“Hello world”程序创建。

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 =================== =======
出现。

4

3 回答 3

2

This happens to me a lot.... I don't know what the cause is, but (at least in my case) I know I can fix the problem by just using the command line. I just "cd" into the directory with the package (the one with the *.cabal file), and type

cabal configure
cabal build

after this is done, Leksah works properly. Clearly it is a Leksah bug, but it is easy to work around.

于 2014-01-10T17:57:20.107 回答
1

问题在于我天真的假设“apt-get install leksah”将安装所有需要的软件包。但是,这是不正确的。

安装 leksah 后,您需要:

apt-get install cabal-install
apt-get install ghc
cabal update

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

现在构建刹车(对于发布的程序,这是 leksah 自动生成的默认值):

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

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

module Main (
  main
) where
main = putStrLn "Hello World"
于 2014-01-10T22:09:59.853 回答
-1

默认 hello world 的问题在于以下行:

putStrLn (hello "World")   

只是左引号不在正确的位置。将其更改为

putStrLn ("hello World")   

它应该可以工作。

于 2014-03-05T06:08:00.317 回答