1

I've installed Leksah 0.12.1.3 on Xubuntu 13.10 from terminal.

sudo apt-get install leksah

Opened leksah, created new workspace and package. Main.hs is created by default with 'Hello world' program.

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

Now, if I try to run package, or write anything in editor, in lower-right window
========== 127 ==========================
appears.

augustss
  • 22,884
  • 5
  • 56
  • 93
edgecrusher
  • 143
  • 6
  • Do you have the `CPP` extension enabled? Also, it's much easier to set up your tests in your .cabal file instead of using language pragmas. There are much better ways to do it. At the very least try defining `main = exeMain` directly. Also, if it doesn't compile with GHC, it won't compile with leksah. Make sure it isn't a code problem before assuming its an editor problem. – bheklilr Jan 10 '14 at 14:33

3 Answers3

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.

jamshidh
  • 12,002
  • 17
  • 31
1

Problem was in my naive assumption that 'apt-get install leksah' will install all needed packages. However, that's not correct.

After leksah installation you'll need:

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

After that, as jamshidh mentioned, you need to click package->cofigure.

Now build brakes with (for program posted in question, which is leksah autogenerated default):

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

But I managed to build much simpler version:

module Main (
  main
) where
main = putStrLn "Hello World"
edgecrusher
  • 143
  • 6
-1

The problem with the default hello world is the following line:

putStrLn (hello "World")   

It's simply that the left quote is not in the correct place. Change that to

putStrLn ("hello World")   

and it should work.

Shiva Saurabh
  • 1,281
  • 2
  • 25
  • 47
Kinch
  • 21
  • 3