initial commit
This commit is contained in:
commit
05e4fb61e2
15 changed files with 421 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/tutorial.md
|
||||||
|
/.stack-work/
|
5
.hlint.yaml
Normal file
5
.hlint.yaml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
- ignore: {name: Use String}
|
||||||
|
- error: {lhs: foldl x, rhs: foldl' x}
|
||||||
|
- error: {lhs: modifyTVar x, rhs: modifyTVar' x}
|
||||||
|
- error: {lhs: atomicModifyIORef x, rhs: atomicModifyIORef' x}
|
||||||
|
- group: {name: generalise, enabled: true}
|
35
.travis.yml
Normal file
35
.travis.yml
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
# Use new container infrastructure to enable caching
|
||||||
|
sudo: false
|
||||||
|
|
||||||
|
# Choose a lightweight base image; we provide our own build tools.
|
||||||
|
language: c
|
||||||
|
|
||||||
|
# GHC depends on GMP. You can add other dependencies here as well.
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- libgmp-dev
|
||||||
|
|
||||||
|
# The different configurations we want to test. You could also do things like
|
||||||
|
# change flags or use --stack-yaml to point to a different file.
|
||||||
|
env:
|
||||||
|
- ARGS=""
|
||||||
|
#- ARGS="--resolver lts-10"
|
||||||
|
- ARGS="--resolver lts"
|
||||||
|
- ARGS="--resolver nightly"
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
# Download and unpack the stack executable
|
||||||
|
- mkdir -p ~/.local/bin
|
||||||
|
- export PATH=$HOME/.local/bin:$PATH
|
||||||
|
- travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
|
||||||
|
|
||||||
|
# This line does all of the work: installs GHC if necessary, builds the
|
||||||
|
# library, executables, and test suites, and runs the test suites.
|
||||||
|
# `--no-terminal works` around some quirks in Travis's terminal implementation.
|
||||||
|
script: stack $ARGS --no-terminal --install-ghc test
|
||||||
|
|
||||||
|
# Caching so the next build will be fast too.
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/.stack
|
12
CHANGELOG.md
Normal file
12
CHANGELOG.md
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
Change log
|
||||||
|
==========
|
||||||
|
|
||||||
|
human-friendly-id-gen uses [Semantic Versioning][1].
|
||||||
|
The change log is available [on GitHub][2].
|
||||||
|
|
||||||
|
[1]: http://semver.org/spec/v2.0.0.html
|
||||||
|
[2]: https://github.com/yogsototh/human-friendly-id-gen/releases
|
||||||
|
|
||||||
|
## v0.1.0.0
|
||||||
|
|
||||||
|
* Initially created.
|
13
LICENSE
Normal file
13
LICENSE
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
Copyright (c) 2018, Yann Esposito
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
6
README.md
Normal file
6
README.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
human-friendly-id-gen
|
||||||
|
==========
|
||||||
|
|
||||||
|
New Haskell project using stack template `hwp`.
|
||||||
|
|
||||||
|
Please read file `tutorial.md` for first steps in using the template.
|
2
Setup.hs
Normal file
2
Setup.hs
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
import Distribution.Simple
|
||||||
|
main = defaultMain
|
106
human-friendly-id-gen.cabal
Normal file
106
human-friendly-id-gen.cabal
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
-- This file has been generated from package.yaml by hpack version 0.28.2.
|
||||||
|
--
|
||||||
|
-- see: https://github.com/sol/hpack
|
||||||
|
--
|
||||||
|
-- hash: c277b81ff031d947f88bdd54614d02de3b1cf3250caa509b48b416941d2a11a6
|
||||||
|
|
||||||
|
name: human-friendly-id-gen
|
||||||
|
version: 0.1.0.0
|
||||||
|
category: Test
|
||||||
|
stability: alpha (experimental)
|
||||||
|
homepage: https://github.com/yogsototh/human-friendly-id-gen#readme
|
||||||
|
bug-reports: https://github.com/yogsototh/human-friendly-id-gen/issues
|
||||||
|
author: Yann Esposito
|
||||||
|
maintainer: yann.esposito@gmail.com
|
||||||
|
copyright: © 2018 Yann Esposito
|
||||||
|
license: ISC
|
||||||
|
license-file: LICENSE
|
||||||
|
build-type: Simple
|
||||||
|
cabal-version: >= 1.10
|
||||||
|
extra-source-files:
|
||||||
|
README.md
|
||||||
|
stack.yaml
|
||||||
|
|
||||||
|
source-repository head
|
||||||
|
type: git
|
||||||
|
location: https://github.com/yogsototh/human-friendly-id-gen
|
||||||
|
|
||||||
|
library
|
||||||
|
exposed-modules:
|
||||||
|
Lib
|
||||||
|
other-modules:
|
||||||
|
Paths_human_friendly_id_gen
|
||||||
|
hs-source-dirs:
|
||||||
|
src
|
||||||
|
default-extensions: OverloadedStrings NoImplicitPrelude ScopedTypeVariables
|
||||||
|
ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wredundant-constraints -Wnoncanonical-monad-instances -Werror -O2
|
||||||
|
build-depends:
|
||||||
|
base >=4.8 && <5
|
||||||
|
, protolude
|
||||||
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
executable human-friendly-id-gen-exe
|
||||||
|
main-is: Main.hs
|
||||||
|
other-modules:
|
||||||
|
Paths_human_friendly_id_gen
|
||||||
|
hs-source-dirs:
|
||||||
|
src-exe
|
||||||
|
default-extensions: OverloadedStrings NoImplicitPrelude ScopedTypeVariables
|
||||||
|
ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wredundant-constraints -Wnoncanonical-monad-instances -Werror -O2 -threaded -rtsopts -with-rtsopts=-N
|
||||||
|
build-depends:
|
||||||
|
base >=4.8 && <5
|
||||||
|
, human-friendly-id-gen
|
||||||
|
, protolude
|
||||||
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
test-suite human-friendly-id-gen-doctest
|
||||||
|
type: exitcode-stdio-1.0
|
||||||
|
main-is: Main.hs
|
||||||
|
other-modules:
|
||||||
|
Paths_human_friendly_id_gen
|
||||||
|
hs-source-dirs:
|
||||||
|
src-doctest
|
||||||
|
default-extensions: OverloadedStrings NoImplicitPrelude ScopedTypeVariables
|
||||||
|
ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wredundant-constraints -Wnoncanonical-monad-instances -Werror -O2 -threaded -rtsopts -with-rtsopts=-N
|
||||||
|
build-depends:
|
||||||
|
Glob >=0.7
|
||||||
|
, QuickCheck >=2.5
|
||||||
|
, base >=4.8 && <5
|
||||||
|
, doctest >=0.10
|
||||||
|
, human-friendly-id-gen
|
||||||
|
, protolude
|
||||||
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
test-suite human-friendly-id-gen-test
|
||||||
|
type: exitcode-stdio-1.0
|
||||||
|
main-is: Main.hs
|
||||||
|
other-modules:
|
||||||
|
Paths_human_friendly_id_gen
|
||||||
|
hs-source-dirs:
|
||||||
|
src-test
|
||||||
|
default-extensions: OverloadedStrings NoImplicitPrelude ScopedTypeVariables
|
||||||
|
ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wredundant-constraints -Wnoncanonical-monad-instances -Werror -O2 -threaded -rtsopts -with-rtsopts=-N
|
||||||
|
build-depends:
|
||||||
|
base >=4.8 && <5
|
||||||
|
, human-friendly-id-gen
|
||||||
|
, protolude
|
||||||
|
, tasty >=0.11
|
||||||
|
, tasty-hunit >=0.9
|
||||||
|
, tasty-smallcheck >=0.8
|
||||||
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
benchmark human-friendly-id-gen-benchmark
|
||||||
|
type: exitcode-stdio-1.0
|
||||||
|
main-is: Main.hs
|
||||||
|
other-modules:
|
||||||
|
Paths_human_friendly_id_gen
|
||||||
|
hs-source-dirs:
|
||||||
|
src-benchmark
|
||||||
|
default-extensions: OverloadedStrings NoImplicitPrelude ScopedTypeVariables
|
||||||
|
ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wredundant-constraints -Wnoncanonical-monad-instances -Werror -O2 -threaded -rtsopts -with-rtsopts=-N
|
||||||
|
build-depends:
|
||||||
|
base >=4.8 && <5
|
||||||
|
, criterion >=1.1
|
||||||
|
, human-friendly-id-gen
|
||||||
|
, protolude
|
||||||
|
default-language: Haskell2010
|
75
package.yaml
Normal file
75
package.yaml
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
name: human-friendly-id-gen
|
||||||
|
version: '0.1.0.0'
|
||||||
|
category: Test
|
||||||
|
author: Yann Esposito
|
||||||
|
maintainer: yann.esposito@gmail.com
|
||||||
|
copyright: © 2018 Yann Esposito
|
||||||
|
github: yogsototh/human-friendly-id-gen
|
||||||
|
license: ISC
|
||||||
|
extra-source-files:
|
||||||
|
- README.md
|
||||||
|
- stack.yaml
|
||||||
|
default-extensions:
|
||||||
|
- OverloadedStrings
|
||||||
|
- NoImplicitPrelude
|
||||||
|
- ScopedTypeVariables
|
||||||
|
ghc-options:
|
||||||
|
- -Wall
|
||||||
|
- -Wcompat
|
||||||
|
- -Wincomplete-uni-patterns
|
||||||
|
- -Wredundant-constraints
|
||||||
|
- -Wnoncanonical-monad-instances
|
||||||
|
- -Werror
|
||||||
|
- -O2
|
||||||
|
dependencies:
|
||||||
|
- base >=4.8 && <5
|
||||||
|
- protolude
|
||||||
|
library:
|
||||||
|
source-dirs: src
|
||||||
|
executables:
|
||||||
|
human-friendly-id-gen-exe:
|
||||||
|
main: Main.hs
|
||||||
|
source-dirs: src-exe
|
||||||
|
ghc-options:
|
||||||
|
- -threaded
|
||||||
|
- -rtsopts
|
||||||
|
- -with-rtsopts=-N
|
||||||
|
dependencies:
|
||||||
|
- human-friendly-id-gen
|
||||||
|
tests:
|
||||||
|
human-friendly-id-gen-doctest:
|
||||||
|
main: Main.hs
|
||||||
|
source-dirs: src-doctest
|
||||||
|
ghc-options:
|
||||||
|
- -threaded
|
||||||
|
- -rtsopts
|
||||||
|
- -with-rtsopts=-N
|
||||||
|
dependencies:
|
||||||
|
- doctest >=0.10
|
||||||
|
- Glob >=0.7
|
||||||
|
- QuickCheck >=2.5
|
||||||
|
- human-friendly-id-gen
|
||||||
|
human-friendly-id-gen-test:
|
||||||
|
main: Main.hs
|
||||||
|
source-dirs: src-test
|
||||||
|
ghc-options:
|
||||||
|
- -threaded
|
||||||
|
- -rtsopts
|
||||||
|
- -with-rtsopts=-N
|
||||||
|
dependencies:
|
||||||
|
- tasty >=0.11
|
||||||
|
- tasty-hunit >=0.9
|
||||||
|
- tasty-smallcheck >=0.8
|
||||||
|
- human-friendly-id-gen
|
||||||
|
benchmarks:
|
||||||
|
human-friendly-id-gen-benchmark:
|
||||||
|
main: Main.hs
|
||||||
|
source-dirs: src-benchmark
|
||||||
|
ghc-options:
|
||||||
|
- -threaded
|
||||||
|
- -rtsopts
|
||||||
|
- -with-rtsopts=-N
|
||||||
|
dependencies:
|
||||||
|
- criterion >=1.1
|
||||||
|
- human-friendly-id-gen
|
||||||
|
stability: alpha (experimental)
|
9
src-benchmark/Main.hs
Normal file
9
src-benchmark/Main.hs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import Protolude
|
||||||
|
|
||||||
|
import Criterion
|
||||||
|
import Criterion.Main
|
||||||
|
|
||||||
|
import Lib (inc)
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = defaultMain [bench "inc 41" (whnf inc (41 :: Int))]
|
7
src-doctest/Main.hs
Normal file
7
src-doctest/Main.hs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import Protolude
|
||||||
|
|
||||||
|
import System.FilePath.Glob
|
||||||
|
import Test.DocTest
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = glob "src/**/*.hs" >>= doctest
|
6
src-exe/Main.hs
Normal file
6
src-exe/Main.hs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import Protolude
|
||||||
|
|
||||||
|
import Lib (inc)
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = print (inc 41)
|
40
src-test/Main.hs
Normal file
40
src-test/Main.hs
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
import Protolude
|
||||||
|
|
||||||
|
import Test.Tasty
|
||||||
|
import Test.Tasty.HUnit
|
||||||
|
import Test.Tasty.SmallCheck
|
||||||
|
|
||||||
|
import Lib (inc)
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = defaultMain $ testGroup "all-tests" tests
|
||||||
|
|
||||||
|
tests :: [TestTree]
|
||||||
|
tests =
|
||||||
|
[ testGroup "SmallCheck" scTests
|
||||||
|
, testGroup "Unit tests" huTests
|
||||||
|
]
|
||||||
|
|
||||||
|
scTests :: [TestTree]
|
||||||
|
scTests =
|
||||||
|
[ testProperty "inc == succ" prop_succ
|
||||||
|
, testProperty "inc . negate == negate . pred" prop_pred
|
||||||
|
]
|
||||||
|
|
||||||
|
huTests :: [TestTree]
|
||||||
|
huTests =
|
||||||
|
[ testCase "Increment below TheAnswer" case_inc_below
|
||||||
|
, testCase "Decrement above TheAnswer" case_dec_above
|
||||||
|
]
|
||||||
|
|
||||||
|
prop_succ :: Int -> Bool
|
||||||
|
prop_succ n = inc n == succ n
|
||||||
|
|
||||||
|
prop_pred :: Int -> Bool
|
||||||
|
prop_pred n = inc (negate n) == negate (pred n)
|
||||||
|
|
||||||
|
case_inc_below :: Assertion
|
||||||
|
case_inc_below = inc 41 @?= (42 :: Int)
|
||||||
|
|
||||||
|
case_dec_above :: Assertion
|
||||||
|
case_dec_above = negate (inc (negate 43)) @?= (42 :: Int)
|
38
src/Lib.hs
Normal file
38
src/Lib.hs
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
{- |
|
||||||
|
Module : Lib
|
||||||
|
Description : Example of a library file.
|
||||||
|
Copyright : (c) 2018, Yann Esposito
|
||||||
|
License : ISC
|
||||||
|
Maintainer : yann.esposito@gmail.com
|
||||||
|
Stability : experimental
|
||||||
|
Portability : POSIX
|
||||||
|
|
||||||
|
Example of library file which is also used for testing the test suites.
|
||||||
|
You can write a longer description of this module here and add @some markup@.
|
||||||
|
|
||||||
|
-}
|
||||||
|
module Lib
|
||||||
|
(
|
||||||
|
-- * Exported functions
|
||||||
|
inc
|
||||||
|
) where
|
||||||
|
|
||||||
|
import Protolude
|
||||||
|
|
||||||
|
-- | Increment one 'Num' value.
|
||||||
|
--
|
||||||
|
-- >>> let answer = 42 :: Int
|
||||||
|
-- >>> let prev = answer - 1
|
||||||
|
-- >>> inc prev
|
||||||
|
-- 42
|
||||||
|
-- >>> succ . Prelude.last . Prelude.take prev . iterate inc $ 1
|
||||||
|
-- 42
|
||||||
|
--
|
||||||
|
-- Properties:
|
||||||
|
--
|
||||||
|
-- prop> succ x == inc x
|
||||||
|
-- prop> inc (negate x) == negate (pred x)
|
||||||
|
--
|
||||||
|
inc :: Int -- ^ value to increment
|
||||||
|
-> Int -- ^ result
|
||||||
|
inc x = x + 1
|
65
stack.yaml
Normal file
65
stack.yaml
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
# This file was automatically generated by 'stack init'
|
||||||
|
#
|
||||||
|
# Some commonly used options have been documented as comments in this file.
|
||||||
|
# For advanced use and comprehensive documentation of the format, please see:
|
||||||
|
# https://docs.haskellstack.org/en/stable/yaml_configuration/
|
||||||
|
|
||||||
|
# Resolver to choose a 'specific' stackage snapshot or a compiler version.
|
||||||
|
# A snapshot resolver dictates the compiler version and the set of packages
|
||||||
|
# to be used for project dependencies. For example:
|
||||||
|
#
|
||||||
|
# resolver: lts-3.5
|
||||||
|
# resolver: nightly-2015-09-21
|
||||||
|
# resolver: ghc-7.10.2
|
||||||
|
# resolver: ghcjs-0.1.0_ghc-7.10.2
|
||||||
|
#
|
||||||
|
# The location of a snapshot can be provided as a file or url. Stack assumes
|
||||||
|
# a snapshot provided as a file might change, whereas a url resource does not.
|
||||||
|
#
|
||||||
|
# resolver: ./custom-snapshot.yaml
|
||||||
|
# resolver: https://example.com/snapshots/2018-01-01.yaml
|
||||||
|
resolver: lts-12.8
|
||||||
|
|
||||||
|
# User packages to be built.
|
||||||
|
# Various formats can be used as shown in the example below.
|
||||||
|
#
|
||||||
|
# packages:
|
||||||
|
# - some-directory
|
||||||
|
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
|
||||||
|
# - location:
|
||||||
|
# git: https://github.com/commercialhaskell/stack.git
|
||||||
|
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
|
||||||
|
# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a
|
||||||
|
# subdirs:
|
||||||
|
# - auto-update
|
||||||
|
# - wai
|
||||||
|
packages:
|
||||||
|
- .
|
||||||
|
# Dependency packages to be pulled from upstream that are not in the resolver
|
||||||
|
# using the same syntax as the packages field.
|
||||||
|
# (e.g., acme-missiles-0.3)
|
||||||
|
# extra-deps: []
|
||||||
|
|
||||||
|
# Override default flag values for local packages and extra-deps
|
||||||
|
# flags: {}
|
||||||
|
|
||||||
|
# Extra package databases containing global packages
|
||||||
|
# extra-package-dbs: []
|
||||||
|
|
||||||
|
# Control whether we use the GHC we find on the path
|
||||||
|
# system-ghc: true
|
||||||
|
#
|
||||||
|
# Require a specific version of stack, using version ranges
|
||||||
|
# require-stack-version: -any # Default
|
||||||
|
# require-stack-version: ">=1.7"
|
||||||
|
#
|
||||||
|
# Override the architecture used by stack, especially useful on Windows
|
||||||
|
# arch: i386
|
||||||
|
# arch: x86_64
|
||||||
|
#
|
||||||
|
# Extra directories used by stack for building
|
||||||
|
# extra-include-dirs: [/path/to/dir]
|
||||||
|
# extra-lib-dirs: [/path/to/dir]
|
||||||
|
#
|
||||||
|
# Allow a newer minor version of GHC than the snapshot specifies
|
||||||
|
# compiler-check: newer-minor
|
Loading…
Reference in a new issue