packages feed

nemesis 2009.6.13.2 → 2009.6.14

raw patch · 9 files changed

+90/−56 lines, 9 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

+ Nemesis view
@@ -0,0 +1,28 @@+nemesis = do+  +  clean+    [ "**/*.hi"+    , "**/*.o"+    , "manifest"+    ]+    +  desc "learn Haskell"+  task "learn-haskell: learn-fp" (putStrLn "Haskell is awesome!")+  +  desc "learn Functional Programming"+  task "learn-fp : learn-lisp" $ do+    sh "echo 'into FP'"++  desc "learn LISP"+  task "learn-lisp" $ do+    sh "echo 'LISP is cool!'"+    +  task "dist" $ do+    sh "cabal clean"+    sh "cabal configure"+    sh "cabal sdist"++  task "i" (sh "ghci -isrc src/System/Nemesis.hs")++  task "manifest" $ do+    sh "find . | grep 'hs$' > manifest"
− Nemesis.hs
@@ -1,31 +0,0 @@--- template nemesis file--nemesis = do-  -  clean-    [ "**/*.hi"-    , "**/*.o"-    , "manifest"-    ]-    -  desc "learn Haskell"-  task "learn-haskell: learn-fp" (putStrLn "Haskell is awesome!")-  -  desc "learn Functional Programming"-  task "learn-fp : learn-lisp" $ do-    sh "echo 'into FP'"--  desc "learn LISP"-  task "learn-lisp" $ do-    sh "echo 'LISP is cool!'"-    -  task "dist" $ do-    sh "cabal clean"-    sh "cabal configure"-    sh "cabal sdist"--  task "i" (sh "ghci -isrc src/System/Nemesis.hs")--  task "manifest" $ do-    sh "find . | grep 'hs$' > manifest"-    
changelog.md view
@@ -1,3 +1,11 @@+2009.6.14+---------++### Feature++* Support compilable Nemesis, i.e. with import and main+* sort task list when output+ 2009.6.13.2 ----------- 
nemesis.cabal view
@@ -1,5 +1,5 @@ Name:                 nemesis-Version:              2009.6.13.2+Version:              2009.6.14 Build-type:           Simple Synopsis:             a rake like task management tool Description:@@ -14,7 +14,7 @@ Cabal-version:        >= 1.2 category:             Web homepage:             http://github.com/nfjinjing/nemesis-data-files:           readme.md, changelog.md, knownissue.md, Nemesis.hs+data-files:           readme.md, changelog.md, knownissue.md, Nemesis  library   ghc-options: -Wall
readme.md view
@@ -89,8 +89,6 @@  Example: -    module Main where-         import System.Nemesis (run)     import System.Nemesis.DSL @@ -99,4 +97,9 @@              main = run nemesis +Hint+---- +Save typing by aliasing `./nes` to `n`, i.e. inside `.your_shellrc`++    alias n="./nes"
src/System/Nemesis.hs view
@@ -2,10 +2,11 @@  module System.Nemesis where -import Prelude hiding ((.), (>), (^), lookup) import Control.Monad.State hiding (State, join) import Data.Default+import Data.List (sort) import Data.Map (Map, insert, empty, lookup, elems)+import Prelude hiding ((.), (>), (^), lookup) import System import System.Nemesis.Util @@ -58,7 +59,7 @@     help = execStateT unit def >>= list_task     list_task n = do       br-      n.tasks.elems.mapM_ print+      n.tasks.elems.sort.mapM_ print       br     br = putStrLn "" 
src/System/Nemesis/DSL.hs view
@@ -4,13 +4,13 @@  import Control.Monad.State hiding (State, join) import Data.Default+import Data.List (nub, sort) import Prelude hiding ((.), (>), (^), lookup) import System+import System.Directory+import System.FilePath.Glob import System.Nemesis import System.Nemesis.Util-import System.FilePath.Glob-import Data.List (nub, sort)-import System.Directory  desc :: String -> Unit desc s = do@@ -40,7 +40,7 @@  clean :: [String] -> Unit clean xs = do-  desc "Remove any temporary products. map (rm -rf)"+  desc "Remove any temporary products."   task "clean" $ do     paths <- globDir (xs.map compile) "." ^ fst ^ join' ^ nub ^ sort ^ reverse     mapM_ rm_any paths
src/System/Nemesis/Runner.hs view
@@ -1,32 +1,48 @@+import Data.List (find) import Prelude hiding ((.), (>), (^)) import System.Cmd import System.Nemesis.Util -start, end, sep_block :: String-sep_block = "\n\n\n\n"-start = sep_block ++ start_nemesis ++ start_nemesis_dsl++start, end :: String+start = start_nemesis ++ start_nemesis_dsl   where      start_nemesis     = "import System.Nemesis (run)\n"     start_nemesis_dsl = "import System.Nemesis.DSL\n"-end = sep_block ++ "main = run nemesis\n"+end = "\nmain = run nemesis\n"  main :: IO () main = do   dir <- ls "."-  src <- readFile $ dir.filter (belongs_to possible_source) .get_name-  let h = src.lines.takeWhile (lower > starts_with sep > not) .unlines+  let src_name = dir.filter (belongs_to possible_source) .get_name+      src_o  = src_base_name src_name ++ ".o"+      src_hi = src_base_name src_name ++ ".hi"+  src <- readFile src_name+  +  let patch_end   = patch_src main_src src end+      patch_start = patch_src import_src src start+      h = src.lines.takeWhile (lower > starts_with sep > not) .unlines       t = src.lines.dropWhile (lower > starts_with sep > not) .unlines   if t.null-    then output $ start ++ h ++ end-    else output $ h ++ start ++ t ++ end+    then output $ patch_start ++ h ++ patch_end+    else output $ h ++ patch_start ++ "\n" ++ t ++ patch_end   -  system $ "ghc --make -O1 " ++ tmp_name ++ " -o " ++ bin-  rm tmp_name-  rm tmp_o-  rm tmp_hi+  if ((null $ patch_end ++ patch_start) && src_name.ends_with ".hs")+    then do+      system $ "ghc --make -O1 " ++ src_name ++ " -o " ++ bin+      rm src_o+      rm src_hi+    else do+      system $ "ghc --make -O1 " ++ tmp_name ++ " -o " ++ bin+      rm tmp_name+      rm tmp_o+      rm tmp_hi      where-    get_name []     = error "Nemesis does not exists"++    main_src        = "main ="+    import_src      = "import System.Nemesis"+    get_name []     = error "Nemesis does not exist!"     get_name xs     = xs.first     possible_source = ["Nemesis", "nemesis", "nemesis.hs", "Nemesis.hs"]     sep             = "-- nem"@@ -35,4 +51,11 @@     tmp_o           = "nemesis-tmp.o"     tmp_hi          = "nemesis-tmp.hi"     bin             = "nem"+    src_base_name s = if s.ends_with ".hs" +                        then s.reverse.drop 3.reverse+                        else s+    patch_src l s p = case s.lines.find (starts_with l) of+                        Nothing -> p+                        Just _ -> ""+     
src/System/Nemesis/Util.hs view
@@ -6,14 +6,13 @@ import Control.Category (Category) import Data.Char (toLower) import Data.Function (on)-import Data.List (isPrefixOf, (\\))+import Data.List (isPrefixOf, isSuffixOf, (\\)) import Prelude hiding ((>), (.), (^)) import System.Directory import qualified Data.List as L  -- utility functions from mps --- base DSL (.) :: a -> (a -> b) -> b a . f = f a infixl 9 .@@ -59,6 +58,9 @@  starts_with :: String -> String -> Bool starts_with = isPrefixOf++ends_with :: String -> String -> Bool+ends_with = isSuffixOf  ls :: String -> IO [String] ls s = getDirectoryContents s ^ (\\ [".", ".."])