commit 94fb9557186ecb577c1b9137ce7dd1f426c0815d Author: Drew Short Date: Tue Aug 15 17:29:14 2017 -0500 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..809eda0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +# Created by .ignore support plugin (hsz.mobi) +### Haskell template +dist +dist-* +cabal-dev +*.o +*.hi +*.chi +*.chs.h +*.dyn_o +*.dyn_hi +.hpc +.hsenv +.cabal-sandbox/ +cabal.sandbox.config +*.prof +*.aux +*.hp +*.eventlog +.stack-work/ +cabal.project.local +.HTF/ + +*.iml +.idea/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e616ce7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,30 @@ +Copyright Drew Short (c) 2017 + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of Author name here nor the names of other + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..9f55af8 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# sothr-dot-com + +add description of sothr-dot-com here \ No newline at end of file diff --git a/Setup.hs b/Setup.hs new file mode 100644 index 0000000..9a994af --- /dev/null +++ b/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/app/Main.hs b/app/Main.hs new file mode 100644 index 0000000..10421fb --- /dev/null +++ b/app/Main.hs @@ -0,0 +1,6 @@ +module Main where + +import Data.String.Strip + +main :: IO () +main = interact strip diff --git a/sothr-dot-com.cabal b/sothr-dot-com.cabal new file mode 100644 index 0000000..64950b0 --- /dev/null +++ b/sothr-dot-com.cabal @@ -0,0 +1,43 @@ +name: sothr-dot-com +version: 0.1.0.0 +-- synopsis: +-- description: +homepage: https://github.com/githubuser/sothr-dot-com#readme +license: BSD3 +license-file: LICENSE +author: Author name here +maintainer: example@example.com +copyright: 2017 Author name here +category: Web +build-type: Simple +extra-source-files: README.md +cabal-version: >=1.10 + +library + hs-source-dirs: src + exposed-modules: Data.String.Strip + build-depends: base >= 4.7 && < 5 + default-language: Haskell2010 + +executable sothr-dot-com + hs-source-dirs: app + main-is: Main.hs + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: base + , sothr-dot-com + default-language: Haskell2010 + +test-suite sothr-dot-com-test + type: exitcode-stdio-1.0 + hs-source-dirs: test + main-is: Spec.hs + build-depends: base + , sothr-dot-com + , hspec + , QuickCheck + ghc-options: -threaded -rtsopts -with-rtsopts=-N + default-language: Haskell2010 + +source-repository head + type: git + location: https://github.com/githubuser/sothr-dot-com diff --git a/src/Data/String/Strip.hs b/src/Data/String/Strip.hs new file mode 100644 index 0000000..a8d5273 --- /dev/null +++ b/src/Data/String/Strip.hs @@ -0,0 +1,6 @@ +module Data.String.Strip (strip) where + +import Data.Char + +strip :: String -> String +strip = dropWhile isSpace . reverse . dropWhile isSpace . reverse diff --git a/test/Data/String/StripSpec.hs b/test/Data/String/StripSpec.hs new file mode 100644 index 0000000..3ecb689 --- /dev/null +++ b/test/Data/String/StripSpec.hs @@ -0,0 +1,19 @@ +module Data.String.StripSpec (main, spec) where + +import Test.Hspec +import Test.QuickCheck + +import Data.String.Strip + +-- `main` is here so that this module can be run from GHCi on its own. It is +-- not needed for automatic spec discovery. +main :: IO () +main = hspec spec + +spec :: Spec +spec = do + describe "strip" $ do + it "removes leading and trailing whitespace" $ do + strip "\t foo bar\n" `shouldBe` "foo bar" + it "is idempotent" $ property $ + \str -> strip str === strip (strip str) diff --git a/test/Spec.hs b/test/Spec.hs new file mode 100644 index 0000000..a824f8c --- /dev/null +++ b/test/Spec.hs @@ -0,0 +1 @@ +{-# OPTIONS_GHC -F -pgmF hspec-discover #-}