From 657a18e4a2ffb601c8cb04d3c4ca584ee39327d4 Mon Sep 17 00:00:00 2001 From: Tony Morris Date: Tue, 25 Sep 2012 15:12:03 +1000 Subject: [PATCH 01/10] delete leksah --- Package.lkshw | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 Package.lkshw diff --git a/Package.lkshw b/Package.lkshw deleted file mode 100644 index 82e6027..0000000 --- a/Package.lkshw +++ /dev/null @@ -1,10 +0,0 @@ -Version of workspace file format: - 1 -Time of storage: - "Mon Jan 10 08:54:11 EST 2012" -Name of the workspace: - "Package" -File paths of contained packages: - ["Package.cabal"] -Maybe file path of an active package: - Just "Package.cabal" From 8cf3f15c2b73a773e798bcc4c1373129cb3c0cb3 Mon Sep 17 00:00:00 2001 From: Tony Morris Date: Tue, 25 Sep 2012 15:13:42 +1000 Subject: [PATCH 02/10] undef --- .ghci | 3 --- 1 file changed, 3 deletions(-) diff --git a/.ghci b/.ghci index f54f985..90bbe46 100644 --- a/.ghci +++ b/.ghci @@ -3,7 +3,4 @@ :m + Test.QuickCheck :set prompt ">> " :set -Wall -:def hlint const . return $ ":! hlint \"src\"" -:def hoogle \s -> return $ ":! hoogle --count=15 \"" ++ s ++ "\"" -:def pl \s -> return $ ":! pointfree \"" ++ s ++ "\"" From d3d924d0f21fc31add929b77431a9e44ece109ef Mon Sep 17 00:00:00 2001 From: Tony Morris Date: Thu, 11 Oct 2012 20:27:18 +1000 Subject: [PATCH 03/10] add GHC flags --- Package.cabal | 5 +++++ demo/Package-Demo.cabal | 5 +++++ test/Package-Test.cabal | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/Package.cabal b/Package.cabal index 79ce532..b13c516 100644 --- a/Package.cabal +++ b/Package.cabal @@ -32,3 +32,8 @@ Library Exposed-Modules: M + GHC-Options: + -Wall + -O2 + -funbox-strict-fields + diff --git a/demo/Package-Demo.cabal b/demo/Package-Demo.cabal index 156f5ec..b2bc952 100644 --- a/demo/Package-Demo.cabal +++ b/demo/Package-Demo.cabal @@ -33,3 +33,8 @@ Executable package-demo Build-Depends: base < 5 && >= 3 + GHC-Options: + -Wall + -O2 + -funbox-strict-fields + diff --git a/test/Package-Test.cabal b/test/Package-Test.cabal index 9d96b0b..9ce374a 100644 --- a/test/Package-Test.cabal +++ b/test/Package-Test.cabal @@ -37,3 +37,8 @@ Executable package-test , test-framework-quickcheck2 , test-framework-hunit + GHC-Options: + -Wall + -O2 + -funbox-strict-fields + From f3cd0bcc0a712ab56294e26eb462f84554bddfe2 Mon Sep 17 00:00:00 2001 From: Tony Morris Date: Fri, 19 Oct 2012 17:26:21 +1000 Subject: [PATCH 04/10] rename to package --- .idea/modules.xml | 2 +- Package.cabal => package.cabal | 2 +- haskell-package.iml => package.iml | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename Package.cabal => package.cabal (96%) rename haskell-package.iml => package.iml (100%) diff --git a/.idea/modules.xml b/.idea/modules.xml index 99fb251..3869787 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ - + diff --git a/Package.cabal b/package.cabal similarity index 96% rename from Package.cabal rename to package.cabal index b13c516..692479d 100644 --- a/Package.cabal +++ b/package.cabal @@ -1,4 +1,4 @@ -Name: Haskell-Package +Name: package Version: 0.0.1 License: BSD3 License-File: LICENSE diff --git a/haskell-package.iml b/package.iml similarity index 100% rename from haskell-package.iml rename to package.iml From 2a38124368e733449b3e9e7c9da204fc93dc979c Mon Sep 17 00:00:00 2001 From: Tony Morris Date: Mon, 22 Oct 2012 12:30:09 +1000 Subject: [PATCH 05/10] script to rename package --- package | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100755 package diff --git a/package b/package new file mode 100755 index 0000000..54e814a --- /dev/null +++ b/package @@ -0,0 +1,75 @@ +#!/usr/bin/env runhaskell + +import Data.Time +import System.Directory +import System.Environment +import System.FilePath +import System.IO + +{- +* rename package.iml +* replace in .idea/modules.xml +* rename package.cabal +* replace in package.cabal + * Name +* first module +-} + + +main = + do args <- getArgs + case args of + [] -> + do n <- getProgName + hPutStrLn stderr (n ++ " [first-module]") + (h:t) -> + let piml = "package.iml" + himl = h ++ ".iml" + mods = "modules.xml" + imods = ".idea" mods + pcabal = "package.cabal" + hcabal = h ++ ".cabal" + in do tmp <- getTemporaryDirectory + now <- getCurrentTime + let dir = tmp h show now + createDirectoryIfMissing True dir + cbl <- readFile pcabal + writeFile (dir hcabal) (replace "Name: package" ("Name: " ++ h) cbl) + copyFile piml (dir himl) + iml <- readFile imods + writeFile (dir mods) (replace piml himl iml) + removeFile piml + removeFile pcabal + copyFile (dir himl) himl + copyFile (dir hcabal) hcabal + copyFile (dir mods) imods + case t of + [] -> return () + (m:_) -> error "todo -- first module" + +replace :: + Eq a => + [a] + -> [a] + -> [a] + -> [a] +replace [] _ v = + v +replace _ _ [] = + [] +replace x y v@(c:w) = + let fd [] [] = + Just [] + fd [] e@(_:_) = + Just e + fd (_:_) [] = + Nothing + fd (h:t) (h':t') = + if h == h' + then + fd t t' + else + Nothing + in case fd x v of + Nothing -> c : replace x y w + Just q -> y ++ replace x y q From f90fe06ec7173001b11adf306622b99ed083ad26 Mon Sep 17 00:00:00 2001 From: Tony Morris Date: Mon, 22 Oct 2012 14:07:55 +1000 Subject: [PATCH 06/10] script to rename package --- package | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/package b/package index 54e814a..98aa1cb 100755 --- a/package +++ b/package @@ -1,21 +1,14 @@ #!/usr/bin/env runhaskell +import Data.List import Data.Time import System.Directory import System.Environment import System.FilePath import System.IO -{- -* rename package.iml -* replace in .idea/modules.xml -* rename package.cabal -* replace in package.cabal - * Name -* first module --} - - +main :: + IO () main = do args <- getArgs case args of @@ -29,6 +22,7 @@ main = imods = ".idea" mods pcabal = "package.cabal" hcabal = h ++ ".cabal" + src = "src" in do tmp <- getTemporaryDirectory now <- getCurrentTime let dir = tmp h show now @@ -45,7 +39,19 @@ main = copyFile (dir mods) imods case t of [] -> return () - (m:_) -> error "todo -- first module" + (m:_) -> let n = split (=='.') m + s [] = error "unexpected empty list" + s [l] = ([], l) + s (hh:tt@(_:_)) = let (p, k) = s tt + in (hh:p, k) + in case n of + [] -> return () + _ -> let (p, k) = s n + p' = src joinPath p + k' = k ++ ".hs" + in do createDirectoryIfMissing True p' + writeFile (p' k') ("module " ++ intercalate "." p ++ '.' : k ++ " where\n") + removeFile (src "M.hs") replace :: Eq a => @@ -73,3 +79,13 @@ replace x y v@(c:w) = in case fd x v of Nothing -> c : replace x y w Just q -> y ++ replace x y q + +split :: + (a -> Bool) + -> [a] + -> [[a]] +split p = + unfoldr (\x -> case x of + [] -> Nothing + _ -> Just . fmap (drop 1) . break p $ x) + From 76c4a55ee9b564f209679bfcccb7fdafe8479735 Mon Sep 17 00:00:00 2001 From: Tony Morris Date: Mon, 22 Oct 2012 14:17:54 +1000 Subject: [PATCH 07/10] script to rename package --- package | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/package b/package index 98aa1cb..09e4111 100755 --- a/package +++ b/package @@ -34,9 +34,7 @@ main = writeFile (dir mods) (replace piml himl iml) removeFile piml removeFile pcabal - copyFile (dir himl) himl - copyFile (dir hcabal) hcabal - copyFile (dir mods) imods + -- OMG I am such a nasty hacker case t of [] -> return () (m:_) -> let n = split (=='.') m @@ -50,8 +48,16 @@ main = p' = src joinPath p k' = k ++ ".hs" in do createDirectoryIfMissing True p' - writeFile (p' k') ("module " ++ intercalate "." p ++ '.' : k ++ " where\n") + let m' = intercalate "." p ++ '.' : k + writeFile (p' k') ("module " ++ m' ++ " where\n") + hc <- readFile (dir hcabal) + -- eek! + length hc `seq` writeFile (dir hcabal) (replace "Exposed-Modules:\n M" ("Exposed-Modules:\n " ++ m') hc) removeFile (src "M.hs") + copyFile (dir himl) himl + copyFile (dir hcabal) hcabal + copyFile (dir mods) imods + replace :: Eq a => From 1a1370376b50cd1f936e1ca26c5cf0454c54f565 Mon Sep 17 00:00:00 2001 From: Tony Morris Date: Mon, 29 Oct 2012 11:02:21 +1000 Subject: [PATCH 08/10] missing import --- package | 1 + 1 file changed, 1 insertion(+) diff --git a/package b/package index 09e4111..af03f36 100755 --- a/package +++ b/package @@ -1,5 +1,6 @@ #!/usr/bin/env runhaskell +import Control.Monad.Instances import Data.List import Data.Time import System.Directory From d09cec4ec9bfc18104b56d461221d2c88039d653 Mon Sep 17 00:00:00 2001 From: Tony Morris Date: Mon, 29 Oct 2012 11:34:07 +1000 Subject: [PATCH 09/10] modify .ghci --- package | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package b/package index af03f36..6bcebf9 100755 --- a/package +++ b/package @@ -23,6 +23,7 @@ main = imods = ".idea" mods pcabal = "package.cabal" hcabal = h ++ ".cabal" + ghci = ".ghci" src = "src" in do tmp <- getTemporaryDirectory now <- getCurrentTime @@ -50,11 +51,15 @@ main = k' = k ++ ".hs" in do createDirectoryIfMissing True p' let m' = intercalate "." p ++ '.' : k + m'' = intercalate "/" p ++ '/' : k ++ ".hs" writeFile (p' k') ("module " ++ m' ++ " where\n") hc <- readFile (dir hcabal) -- eek! length hc `seq` writeFile (dir hcabal) (replace "Exposed-Modules:\n M" ("Exposed-Modules:\n " ++ m') hc) removeFile (src "M.hs") + hghci <- readFile ghci + writeFile (dir ghci) (replace "M.hs" m'' hghci) + copyFile (dir ghci) ghci copyFile (dir himl) himl copyFile (dir hcabal) hcabal copyFile (dir mods) imods From 2d772e7bf798786d1037760c3f421688787f0f67 Mon Sep 17 00:00:00 2001 From: Tony Morris Date: Mon, 5 Nov 2012 16:19:25 +1000 Subject: [PATCH 10/10] remove duplicate GHC options --- package.cabal | 5 ----- 1 file changed, 5 deletions(-) diff --git a/package.cabal b/package.cabal index 692479d..b6fa403 100644 --- a/package.cabal +++ b/package.cabal @@ -32,8 +32,3 @@ Library Exposed-Modules: M - GHC-Options: - -Wall - -O2 - -funbox-strict-fields -