initial commit

This commit is contained in:
Yann Esposito (Yogsototh) 2018-12-02 12:33:51 +01:00
commit 831aa825eb
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646
25 changed files with 527 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/tutorial.md
/.stack-work/

5
.hlint.yaml Normal file
View 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
View 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
View file

@ -0,0 +1,12 @@
Change log
==========
aggreact 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/aggreact/releases
## v0.1.0.0
* Initially created.

13
LICENSE Normal file
View 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.

17
README.md Normal file
View file

@ -0,0 +1,17 @@
`aggreact`
==========
Add comments to your static website and also list all mentions on multiple
social networks.
## Install
- Install [`stack`](https://haskellstack.org)
- clone this repo
- `stack build`
## Use
``` haskell
stack exec -- aggreact
```

2
Setup.hs Normal file
View file

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

113
aggreact.cabal Normal file
View file

@ -0,0 +1,113 @@
-- This file has been generated from package.yaml by hpack version 0.28.2.
--
-- see: https://github.com/sol/hpack
--
-- hash: dbea1e0f8e841e18db7ba59a8d31a8b8146cc860758b3ea43c34252a7f6229a3
name: aggreact
version: 0.1.0.0
category: Test
stability: alpha (experimental)
homepage: https://github.com/yogsototh/aggreact#readme
bug-reports: https://github.com/yogsototh/aggreact/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/aggreact
library
exposed-modules:
Aggreact
Aggreact.Comments
Store
other-modules:
Paths_aggreact
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
, containers
, protolude
, servant
, servant-server
, time
, versioning
default-language: Haskell2010
executable aggreact
main-is: Main.hs
other-modules:
Paths_aggreact
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:
aggreact
, base >=4.8 && <5
, protolude
default-language: Haskell2010
test-suite aggreact-doctest
type: exitcode-stdio-1.0
main-is: Main.hs
other-modules:
Paths_aggreact
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
, aggreact
, base >=4.8 && <5
, doctest >=0.10
, protolude
default-language: Haskell2010
test-suite aggreact-test
type: exitcode-stdio-1.0
main-is: Main.hs
other-modules:
Paths_aggreact
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:
aggreact
, base >=4.8 && <5
, protolude
, tasty >=0.11
, tasty-hunit >=0.9
, tasty-smallcheck >=0.8
default-language: Haskell2010
benchmark aggreact-benchmark
type: exitcode-stdio-1.0
main-is: Main.hs
other-modules:
Paths_aggreact
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:
aggreact
, base >=4.8 && <5
, criterion >=1.1
, protolude
default-language: Haskell2010

BIN
dist-newstyle/cache/compiler vendored Normal file

Binary file not shown.

BIN
dist-newstyle/cache/config vendored Normal file

Binary file not shown.

BIN
dist-newstyle/cache/elaborated-plan vendored Normal file

Binary file not shown.

BIN
dist-newstyle/cache/improved-plan vendored Normal file

Binary file not shown.

1
dist-newstyle/cache/plan.json vendored Normal file

File diff suppressed because one or more lines are too long

BIN
dist-newstyle/cache/solver-plan vendored Normal file

Binary file not shown.

BIN
dist-newstyle/cache/source-hashes vendored Normal file

Binary file not shown.

BIN
dist-newstyle/cache/up-to-date vendored Normal file

Binary file not shown.

81
package.yaml Normal file
View file

@ -0,0 +1,81 @@
name: aggreact
version: '0.1.0.0'
category: Test
author: Yann Esposito
maintainer: yann.esposito@gmail.com
copyright: © 2018 Yann Esposito
github: yogsototh/aggreact
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
dependencies:
- containers
- servant
- servant-server
- time
- versioning
executables:
aggreact:
main: Main.hs
source-dirs: src-exe
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- aggreact
tests:
aggreact-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
- aggreact
aggreact-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
- aggreact
benchmarks:
aggreact-benchmark:
main: Main.hs
source-dirs: src-benchmark
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- criterion >=1.1
- aggreact
stability: alpha (experimental)

9
src-benchmark/Main.hs Normal file
View 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
View 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
View file

@ -0,0 +1,6 @@
import Protolude
import Aggreact (inc)
main :: IO ()
main = print (inc 41)

40
src-test/Main.hs Normal file
View 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)

36
src/Aggreact.hs Normal file
View file

@ -0,0 +1,36 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE Strict #-}
{- |
Module : Aggreact
Description : Example of a library file.
Copyright : (c) 2018, Yann Esposito
License : ISC
Maintainer : yann.esposito@gmail.com
Stability : experimental
Portability : POSIX
Main library
-}
module Aggreact
(
-- * Exported functions
mainServe
, Conf (..)
) where
import Protolude
import Aggreact.Comments
import Servant.API
type CommentAPI =
"comments" :> Capture "stub" Text :> Get '[JSON] Comments
data Conf = Conf { port :: Int16 }
mainServe :: Conf -> IO ()
mainServe = undefined

44
src/Aggreact/Comments.hs Normal file
View file

@ -0,0 +1,44 @@
{-# LANGUAGE Strict #-}
{- |
Module : Aggreact
Description : Example of a library file.
Copyright : (c) 2018, Yann Esposito
License : ISC
Maintainer : yann.esposito@gmail.com
Stability : experimental
Portability : POSIX
Main library
-}
module Aggreact.Comments
(
-- * Types
ID (..)
, Comment (..)
, Comments
) where
import Protolude
import Data.Time (UTCTime)
import Data.Tree (Tree (..))
newtype ID = ID Int64 deriving (Eq,Ord)
type Comments = Tree Comment
data Comment =
Comment
{ id :: ID
, parent :: ID
, created :: UTCTime
, content :: Text
, userid :: Text
}
data Root =
Root
{ stub :: Text
} deriving (Show)

38
src/Store.hs Normal file
View file

@ -0,0 +1,38 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE Strict #-}
{- |
Module : Aggreact
Description : Example of a library file.
Copyright : (c) 2018, Yann Esposito
License : ISC
Maintainer : yann.esposito@gmail.com
Stability : experimental
Portability : POSIX
Main library
-}
module Store
(
-- * Exported Functions
inc
) where
import Protolude
import qualified Versioning.Base as V
import qualified Versioning.JSON as VJSON
load :: FilePath -> v -> IO (Either Text (v a))
load dbFile v = do
dbFileExists <- doesFileExist dbFile
db <- if dbFileExists
then do
fileContent <- BS.readFile dbFile
VJSON.fromJsonAnyVersionEither fileContent `fmap` \x -> V.upgrade latestVersion x
else
return (dbFile <> " doesn't exists")

66
stack.yaml Normal file
View file

@ -0,0 +1,66 @@
# 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.20
# 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:
- versioning-0.3.0.1
# 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