Skip to content
Browse files

Add leksah-welcome package

  • Loading branch information...
1 parent a268d96 commit a4f9b3bfda8bf539919341a7578c251de81a6452 @hamishmack hamishmack committed Mar 12, 2012
View
6 data/leksah-welcome/Setup.lhs
@@ -0,0 +1,6 @@
+#!/usr/bin/runhaskell
+> module Main where
+> import Distribution.Simple
+> main :: IO ()
+> main = defaultMain
+
View
26 data/leksah-welcome/leksah-welcome.cabal
@@ -0,0 +1,26 @@
+name: leksah-welcome
+version: 0.12.0.3
+cabal-version: >=1.2
+build-type: Simple
+license: AllRightsReserved
+license-file: ""
+description:
+ .
+ .
+ .
+ .
+data-dir: ""
+
+executable leksah-welcome
+ build-depends: QuickCheck -any, base -any
+ main-is: Main.hs
+ buildable: True
+ hs-source-dirs: src
+
+test-suite test-leksah-welcome
+ build-depends: QuickCheck -any, base -any
+ type: exitcode-stdio-1.0
+ main-is: Main.hs
+ buildable: True
+ cpp-options: -DMAIN_FUNCTION=testMain
+ hs-source-dirs: src
View
75 data/leksah-welcome/src/Main.hs
@@ -0,0 +1,75 @@
+{-# LANGUAGE CPP, TemplateHaskell #-}
+-- Welcome to Leksah. This is a quick sample package for you to
+-- try things out with. We hope it will be useful for those new
+-- to Haskell or just new to Leksah.
+
+-- If you are new to haskell then here are some great sites to visit
+-- http://learnyouahaskell.com/
+-- http://tryhaskell.org/
+-- http://book.realworldhaskell.org/
+
+-- To build this package use
+-- * Just make a change while background build is activated
+-- * Ctrl+B (OS X Command+B)
+-- * Package -> Build
+
+-- When you are ready to create your own workspace and package.
+-- * Package -> New
+-- * When asked for a root folder for your package select a new folder
+-- with the desired name of your package
+
+-- This is the "Main" module and it exports a "main" function
+module Main (
+ main
+) where
+
+-- Next we are importing some things from other modules.
+-- Leksah can normally addd these imports for you, just
+-- press Ctrl+R (OS X Command+R)
+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
+
+-- QuickCheck is a great tool for writing tests.
+-- The following tells QuickCheck that if you strip "Hello "
+-- from the start of hello s you will be left with s (for any s).
+-- QuickCheck will create the test data needed to run this test.
+prop_hello s = stripPrefix "Hello " (hello s) == Just s
+
+-- exeMain : Executable Entry Point
+-- --------------------------------
+-- Here is the entry point for the leksah-welcome executable
+--
+-- To run it
+-- * Select Leksah menu item Package -> Run (or the cogs on the toolbar)
+-- * Select "exeMain" and press Ctrl+Enter to run them in ghci
+-- * Run "leksah-wellcome" from the command line
+exeMain = do
+ putStrLn (hello "World")
+
+-- testMain : Unit Testing Entry Point
+-- -----------------------------------
+-- This is the main function uses by the cabal test
+--
+-- To run these tests
+-- * Select Leksah menu item Package -> Test
+-- * Select the tick icon on the Leksa toolbar (to enable "cabal test" during builds)
+-- * Select "testMain" and press Ctrl+Enter to run them in ghci
+-- * Run "cabal test" from the command line in the package directory
+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
+
View
13 leksah.cabal
@@ -29,6 +29,9 @@ data-files: LICENSE
data/main.lksht
data/module.lksht
data/welcome.txt
+ data/leksah-welcome/Setup.lhs
+ data/leksah-welcome/leksah-welcome.cabal
+ data/leksah-welcome/src/Main.hs
language-specs/haskell.lang
language-specs/haskell-literate.lang
@@ -79,6 +82,10 @@ flag dyre
Default: True
Description: Experimental Yi support
+flag threaded
+ default: False
+ description: Build with support for multithreaded execution
+
library
if os(windows)
build-depends: Win32 >=2.2.0.0 && <2.3
@@ -100,6 +107,9 @@ library
build-depends: dyre >= 0.8.3 && <0.9
cpp-options: -DLEKSAH_WITH_YI_DYRE
+ if flag(threaded)
+ ghc-options: -threaded
+
hs-source-dirs: src
extensions: CPP
@@ -169,6 +179,9 @@ Executable leksah
if impl(ghc < 7.0) && flag(yi) && flag(dyre)
build-depends: dyre >= 0.8.3 && <0.9
+ if flag(threaded)
+ ghc-options: -threaded
+
if impl(ghc < 7.0)
hs-source-dirs: src, main
build-depends: Cabal >=1.6.0.1 && <1.15, base >=4.0.0.0 && <4.6, binary >=0.5.0.0 && <0.6,
View
31 src/IDE/Leksah.hs
@@ -55,7 +55,9 @@ import Graphics.UI.Editor.Composite (filesEditor, maybeEditor)
import Graphics.UI.Editor.Simple
(enumEditor, stringEditor)
import IDE.Metainfo.Provider (initInfo)
-import IDE.Workspaces (workspaceOpenThis, backgroundMake)
+import IDE.Workspaces
+ (workspaceAddPackage', workspaceTryQuiet, workspaceNewHere,
+ workspaceOpenThis, backgroundMake)
import IDE.Utils.GUIUtils
import Network (withSocketsDo)
import Control.Exception
@@ -67,13 +69,16 @@ import System.Log.Logger
(getLevel, getRootLogger, debugM, updateGlobalLogger,
rootLoggerName, setLevel)
import Data.List (stripPrefix)
-import System.Directory (doesFileExist)
+import System.Directory
+ (doesDirectoryExist, copyFile, createDirectoryIfMissing,
+ getHomeDirectory, doesFileExist)
import System.FilePath (dropExtension, splitExtension, (</>))
import qualified Data.Enumerator as E
import qualified Data.Enumerator.List as EL
import Data.Enumerator (($$))
import Control.Monad (when, unless, liftM)
import Control.Monad.IO.Class (MonadIO(..))
+import Control.Applicative ((<$>))
-- --------------------------------------------------------------------
-- Command line options
@@ -323,9 +328,25 @@ startMainWindow yiControl sessionFP mbWorkspaceFP sourceFPs startupPrefs isFirst
OSX.applicationReady osxApp
- when isFirstStart $ do
- welcomePath <- getConfigFilePathForLoad "welcome.txt" Nothing dataDir
- reflectIDE (fileOpenThis welcomePath) ideR
+ configDir <- getConfigDir
+ let welcomePath = configDir</>"leksah-welcome"
+ welcomeExists <- doesDirectoryExist welcomePath
+ unless welcomeExists $ do
+ let welcomeSource = dataDir</>"data"</>"leksah-welcome"
+ welcomeCabal = welcomePath</>"leksah-welcome.cabal"
+ welcomeMain = welcomePath</>"src"</>"Main.hs"
+ createDirectoryIfMissing True $ welcomePath</>"src"
+ copyFile (welcomeSource</>"Setup.lhs") (welcomePath</>"Setup.lhs")
+ copyFile (welcomeSource</>"leksah-welcome.cabal") (welcomeCabal)
+ copyFile (welcomeSource</>"src"</>"Main.hs") (welcomeMain)
+ defaultWorkspace <- liftIO $ (</> "leksah.lkshw") <$> getHomeDirectory
+ defaultExists <- liftIO $ doesFileExist defaultWorkspace
+ reflectIDE (do
+ if defaultExists
+ then workspaceOpenThis False (Just defaultWorkspace)
+ else workspaceNewHere defaultWorkspace
+ workspaceTryQuiet $ workspaceAddPackage' welcomeCabal
+ fileOpenThis welcomeMain) ideR
reflectIDE (initInfo (modifyIDE_ (\ide -> ide{currentState = IsRunning}))) ideR
timeoutAddFull (do
reflectIDE (do
View
2 src/IDE/Workspaces.hs
@@ -27,6 +27,8 @@ module IDE.Workspaces (
, workspaceAddPackage'
, workspaceRemovePackage
, workspacePackageNew
+, workspaceTryQuiet
+, workspaceNewHere
, packageTry
, packageTry_
, packageTryQuiet

0 comments on commit a4f9b3b

Please sign in to comment.
Something went wrong with that request. Please try again.