git.iko.soy/typeable/writer-cps-mtl
on master help sign in
initial commit
commitdc63fc92246b3ea2e001773d447e4f15d99c87c6 authorDaniel Mendler <mail@daniel-mendler.de> dateThu 1 Sep 2016, 09:49 (10 years ago)
8 files changed+289
.gitignore+4 .travis.yml+94 Control/Monad/RWS/CPS.hs+49 Control/Monad/Writer/CPS.hs+29 LICENSE+30 Setup.hs+2 package.yaml+43 writer-cps-mtl.cabal+38
.gitignorenew file+4
@@ -0,0 +1,4 @@
1+dist
2+attic
3+.hpc
4+.stack*
.travis.ymlnew file+94
@@ -0,0 +1,94 @@
1+# This file has been generated -- see https://github.com/hvr/multi-ghc-travis
2+language: c
3+sudo: false
4+
5+cache:
6+ directories:
7+ - $HOME/.cabsnap
8+ - $HOME/.cabal/packages
9+
10+before_cache:
11+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
12+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar
13+
14+matrix:
15+ include:
16+ - env: CABALVER=1.16 GHCVER=7.0.4
17+ compiler: ": #GHC 7.0.4"
18+ addons: {apt: {packages: [cabal-install-1.16,ghc-7.0.4], sources: [hvr-ghc]}}
19+ - env: CABALVER=1.16 GHCVER=7.2.2
20+ compiler: ": #GHC 7.2.2"
21+ addons: {apt: {packages: [cabal-install-1.16,ghc-7.2.2], sources: [hvr-ghc]}}
22+ - env: CABALVER=1.16 GHCVER=7.4.2
23+ compiler: ": #GHC 7.4.2"
24+ addons: {apt: {packages: [cabal-install-1.16,ghc-7.4.2], sources: [hvr-ghc]}}
25+ - env: CABALVER=1.16 GHCVER=7.6.3
26+ compiler: ": #GHC 7.6.3"
27+ addons: {apt: {packages: [cabal-install-1.16,ghc-7.6.3], sources: [hvr-ghc]}}
28+ - env: CABALVER=1.18 GHCVER=7.8.4
29+ compiler: ": #GHC 7.8.4"
30+ addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}}
31+ - env: CABALVER=1.22 GHCVER=7.10.3
32+ compiler: ": #GHC 7.10.3"
33+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3], sources: [hvr-ghc]}}
34+ - env: CABALVER=1.24 GHCVER=8.0.1
35+ compiler: ": #GHC 8.0.1"
36+ addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1], sources: [hvr-ghc]}}
37+
38+before_install:
39+ - unset CC
40+ - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
41+
42+install:
43+ - cabal --version
44+ - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
45+ - if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];
46+ then
47+ zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >
48+ $HOME/.cabal/packages/hackage.haskell.org/00-index.tar;
49+ fi
50+ - travis_retry cabal update -v
51+ - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
52+ - cabal install --only-dependencies --enable-tests --enable-benchmarks --dry -v > installplan.txt
53+ - sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt
54+
55+# check whether current requested install-plan matches cached package-db snapshot
56+ - if diff -u installplan.txt $HOME/.cabsnap/installplan.txt;
57+ then
58+ echo "cabal build-cache HIT";
59+ rm -rfv .ghc;
60+ cp -a $HOME/.cabsnap/ghc $HOME/.ghc;
61+ cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/;
62+ else
63+ echo "cabal build-cache MISS";
64+ rm -rf $HOME/.cabsnap;
65+ mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;
66+ cabal install --only-dependencies --enable-tests --enable-benchmarks;
67+ fi
68+
69+# snapshot package-db on cache miss
70+ - if [ ! -d $HOME/.cabsnap ];
71+ then
72+ echo "snapshotting package-db to build-cache";
73+ mkdir $HOME/.cabsnap;
74+ cp -a $HOME/.ghc $HOME/.cabsnap/ghc;
75+ cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;
76+ fi
77+
78+# Here starts the actual work to be performed for the package under test;
79+# any command which exits with a non-zero exit code causes the build to fail.
80+script:
81+ - if [ -f configure.ac ]; then autoreconf -i; fi
82+ - cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging
83+ - cabal build # this builds all libraries and executables (including tests/benchmarks)
84+ - cabal test
85+ - cabal check
86+ - cabal sdist # tests that a source-distribution can be generated
87+
88+# Check that the resulting source distribution can be built & installed.
89+# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
90+# `cabal install --force-reinstalls dist/*-*.tar.gz`
91+ - SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
92+ (cd dist && cabal install --force-reinstalls "$SRC_TGZ")
93+
94+# EOF
Control/Monad/RWS/CPS.hsnew file+49
@@ -0,0 +1,49 @@
1+{-# OPTIONS_GHC -fno-warn-orphans #-}
2+module Control.Monad.RWS.CPS (
3+ -- * The RWS monad
4+ RWS,
5+ rws,
6+ runRWS,
7+ evalRWS,
8+ execRWS,
9+ mapRWS,
10+ withRWS,
11+ -- * The RWST monad transformer
12+ RWST,
13+ runRWST,
14+ evalRWST,
15+ execRWST,
16+ mapRWST,
17+ withRWST,
18+ -- * Strict Reader-writer-state monads
19+ module X
20+) where
21+
22+import Control.Monad as X
23+import Control.Monad.Fix as X
24+import Control.Monad.RWS.Class as X
25+import Control.Monad.Trans as X
26+import Data.Monoid as X
27+
28+import Control.Monad.Trans.RWS.CPS hiding (censor, tell, writer, listen, pass, ask,
29+ local, reader, get, put, state, listens, asks)
30+import qualified Control.Monad.Trans.RWS.CPS as CPS
31+
32+-- Orphan instance
33+instance (Monoid w, Monad m) => MonadWriter w (RWST r w s m) where
34+ tell = CPS.tell
35+ writer = CPS.writer
36+ listen = CPS.listen
37+ pass = CPS.pass
38+
39+-- Orphan instance
40+instance Monad m => MonadReader r (RWST r w s m) where
41+ ask = CPS.ask
42+ local = CPS.local
43+ reader = CPS.reader
44+
45+-- Orphan instance
46+instance Monad m => MonadState s (RWST r w s m) where
47+ get = CPS.get
48+ put = CPS.put
49+ state = CPS.state
Control/Monad/Writer/CPS.hsnew file+29
@@ -0,0 +1,29 @@
1+{-# OPTIONS_GHC -fno-warn-orphans #-}
2+module Control.Monad.Writer.CPS (
3+ -- * The Writer monad
4+ Writer,
5+ runWriter,
6+ execWriter,
7+ mapWriter,
8+ -- * The WriterT monad transformer
9+ WriterT,
10+ runWriterT,
11+ execWriterT,
12+ mapWriterT,
13+ module X
14+) where
15+
16+import Control.Monad as X
17+import Control.Monad.Fix as X
18+import Control.Monad.Trans as X
19+import Control.Monad.Writer.Class as X
20+import Data.Monoid as X
21+
22+import Control.Monad.Trans.Writer.CPS hiding (writer, listen, pass)
23+import qualified Control.Monad.Trans.Writer.CPS as CPS
24+
25+-- Orphan instance
26+instance (Monoid w, Monad m) => MonadWriter w (CPS.WriterT w m) where
27+ writer = CPS.writer
28+ listen = CPS.listen
29+ pass = CPS.pass
LICENSEnew file+30
@@ -0,0 +1,30 @@
1+Copyright (c) 2016 Daniel Mendler
2+
3+All rights reserved.
4+
5+Redistribution and use in source and binary forms, with or without
6+modification, are permitted provided that the following conditions are met:
7+
8+ * Redistributions of source code must retain the above copyright
9+ notice, this list of conditions and the following disclaimer.
10+
11+ * Redistributions in binary form must reproduce the above
12+ copyright notice, this list of conditions and the following
13+ disclaimer in the documentation and/or other materials provided
14+ with the distribution.
15+
16+ * Neither the name of the copyright holders nor the names of other
17+ contributors may be used to endorse or promote products derived
18+ from this software without specific prior written permission.
19+
20+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Setup.hsnew file+2
@@ -0,0 +1,2 @@
1+import Distribution.Simple
2+main = defaultMain
package.yamlnew file+43
@@ -0,0 +1,43 @@
1+name: writer-cps-mtl
2+version: 0.1.0.0
3+synopsis: MonadWriter orphan instances for writer-cps-transformers
4+description:
5+ The WriterT and RWST monad transformers provided by writer-cps-transformers
6+ are written in continuation passing style and avoid the space-leak
7+ problem of the traditional Control.Monad.Trans.Writer.Strict/Lazy.
8+category: Control
9+author: Daniel Mendler
10+maintainer: mail@daniel-mendler.de
11+copyright: 2016 Daniel Mendler
12+license: MIT
13+github: minad/writer-cps-mtl
14+
15+default-extensions:
16+- MultiParamTypeClasses
17+- FunctionalDependencies
18+- FlexibleInstances
19+
20+ghc-options:
21+- -Wall
22+- -Widentities
23+- -Wincomplete-uni-patterns
24+- -Wincomplete-record-updates
25+- -Wtabs
26+
27+dependencies:
28+- base < 6
29+- transformers >= 0.4 && < 0.6
30+- mtl >= 2.2 && < 2.4
31+- writer-cps-transformers == 0.1.0.0
32+
33+tested-with:
34+ GHC == 7.0.4,
35+ GHC == 7.2.2,
36+ GHC == 7.4.2,
37+ GHC == 7.6.3,
38+ GHC == 7.8.4,
39+ GHC == 7.10.3,
40+ GHC == 8.0.1
41+
42+library:
43+ source-dirs: .
writer-cps-mtl.cabalnew file+38
@@ -0,0 +1,38 @@
1+-- This file has been generated from package.yaml by hpack version 0.14.1.
2+--
3+-- see: https://github.com/sol/hpack
4+
5+name: writer-cps-mtl
6+version: 0.1.0.0
7+cabal-version: >= 1.10
8+license: MIT
9+license-file: LICENSE
10+tested-with: GHC == 7.0.4, GHC == 7.2.2, GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.1
11+author: Daniel Mendler
12+maintainer: mail@daniel-mendler.de
13+copyright: 2016 Daniel Mendler
14+category: Control
15+synopsis: MonadWriter orphan instances for writer-cps-transformers
16+homepage: https://github.com/minad/writer-cps-mtl#readme
17+bug-reports: https://github.com/minad/writer-cps-mtl/issues
18+description: The WriterT and RWST monad transformers provided by writer-cps-transformers are written in continuation passing style and avoid the space-leak problem of the traditional Control.Monad.Trans.Writer.Strict/Lazy.
19+build-type: Simple
20+
21+source-repository head
22+ type: git
23+ location: https://github.com/minad/writer-cps-mtl
24+
25+library
26+ hs-source-dirs:
27+ .
28+ default-extensions: MultiParamTypeClasses FunctionalDependencies FlexibleInstances
29+ ghc-options: -Wall -Widentities -Wincomplete-uni-patterns -Wincomplete-record-updates -Wtabs
30+ build-depends:
31+ base < 6
32+ , transformers >= 0.4 && < 0.6
33+ , mtl >= 2.2 && < 2.4
34+ , writer-cps-transformers == 0.1.0.0
35+ exposed-modules:
36+ Control.Monad.RWS.CPS
37+ Control.Monad.Writer.CPS
38+ default-language: Haskell2010