Files (empty) → 0.1.0.0
raw patch · 9 files changed
+107/−0 lines, 9 filesdep +Filesdep +basedep +hspecsetup-changed
Dependencies added: Files, base, hspec
Files
- Files.cabal +36/−0
- LICENSE +21/−0
- Setup.hs +2/−0
- library/Files.hs +7/−0
- library/deps/Heads.hs +11/−0
- library/deps/Hello.hs +4/−0
- src/Main.hs +13/−0
- test-suite/HeadsSpec.hs +12/−0
- test-suite/Spec.hs +1/−0
+ Files.cabal view
@@ -0,0 +1,36 @@+name: Files+version: 0.1.0.0+synopsis: File content extraction/rearrangement+description: Please see README.md+homepage: https://github.com/githubuser/Files#readme+license: MIT+license-file: LICENSE+author: Yuhang(Steven) Wang+maintainer: stevenyhw.project@gmail.com+copyright: 2016 Yuhang(Steven) Wang+category: IO+build-type: Simple+cabal-version: >=1.10++executable Files+ hs-source-dirs: src+ main-is: Main.hs+ default-language: Haskell2010+ build-depends: base >= 4.7 && < 5+ , Files ++library+ exposed-modules: Files+ other-modules: Heads, Hello+ hs-source-dirs: library, library/deps+ build-depends: base >= 4.7 && < 5+ ghc-options: -Wall+ default-language: Haskell2010++test-suite hspec+ build-depends: base, Files, hspec+ other-modules: HeadsSpec+ default-language: Haskell2010+ hs-source-dirs: test-suite+ main-is: Spec.hs+ type: exitcode-stdio-1.0
+ LICENSE view
@@ -0,0 +1,21 @@+MIT License + +Copyright (c) 2016 Steven(Yuhang) Wang + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ library/Files.hs view
@@ -0,0 +1,7 @@+module Files + ( module Heads + , module Hello) where + +import Heads +import Hello +
+ library/deps/Heads.hs view
@@ -0,0 +1,11 @@+module Heads (heads) where + +heads :: Int -> [String] -> IO [String] +heads n file_names = aux file_names [] + where + aux :: [String] -> [String] -> IO [String] + aux [] accum = return accum + aux (name:names) accum = do + content <- readFile name + let items = take n (lines content) + aux names (accum ++ items)
+ library/deps/Hello.hs view
@@ -0,0 +1,4 @@+module Hello (hello) where + +hello :: String -> String +hello s = "Hello " ++ s ++ "!"
+ src/Main.hs view
@@ -0,0 +1,13 @@+module Main where+import Files+import System.Environment+main :: IO ()+main = do+ (output:numLines:files) <- getArgs+ let n = read numLines + allLines <- heads n files+ writeFile output (unlines allLines)+ print (hello "Steven")+ putStrLn "hello world"++
+ test-suite/HeadsSpec.hs view
@@ -0,0 +1,12 @@+module HeadsSpec (spec) where + +import Files (heads) +import Test.Hspec +import Test.Hspec.QuickCheck + +spec :: Spec +spec = do + describe "heads" $ do + it "returns a list top few files from many files" $ do + results <- heads 2 ["data/in/f1.txt", "data/in/f2.txt"] + results `shouldBe` ["a", "b", "1", "2"]
+ test-suite/Spec.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}