Browse Source

Initial commit

master
Drew Short 7 years ago
commit
94fb955718
  1. 25
      .gitignore
  2. 30
      LICENSE
  3. 3
      README.md
  4. 2
      Setup.hs
  5. 6
      app/Main.hs
  6. 43
      sothr-dot-com.cabal
  7. 6
      src/Data/String/Strip.hs
  8. 19
      test/Data/String/StripSpec.hs
  9. 1
      test/Spec.hs

25
.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/

30
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.

3
README.md

@ -0,0 +1,3 @@
# sothr-dot-com
add description of sothr-dot-com here

2
Setup.hs

@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain

6
app/Main.hs

@ -0,0 +1,6 @@
module Main where
import Data.String.Strip
main :: IO ()
main = interact strip

43
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

6
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

19
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)

1
test/Spec.hs

@ -0,0 +1 @@
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}