From f0bf1e49db95e8b9cb0a842ac67da162460bf260 Mon Sep 17 00:00:00 2001 From: Mann mit Hut Date: Sun, 25 Jul 2021 15:18:35 +0200 Subject: [PATCH] Split effectful package (#27) * Moved effectful library to a subdirectory * Initial commit of the effectful-core library * Removed tests/benchmarks/examples from effectful-core package * Removed READMEs from packages * Updated CI * Refactored doctest script This is a bit closer to the CI setup. * Adjusted dependencies * Updated README * Updated the package descriptions * Added examples to test suite --- .github/workflows/haskell-ci.yml | 20 ++-- README.md | 16 ++- cabal.project | 3 + doctest.sh | 54 ++++++---- effectful-core/CHANGELOG.md | 2 + effectful-core/LICENSE | 30 ++++++ effectful-core/effectful-core.cabal | 100 ++++++++++++++++++ .../src}/Effectful/Error.hs | 0 .../src}/Effectful/Error/Dynamic.hs | 0 {src => effectful-core/src}/Effectful/Fail.hs | 0 .../src}/Effectful/Handler.hs | 1 - .../src}/Effectful/Internal/Effect.hs | 0 .../src}/Effectful/Internal/Env.hs | 0 .../src}/Effectful/Internal/Monad.hs | 0 .../src}/Effectful/Internal/Unlift.hs | 0 .../src}/Effectful/Monad.hs | 0 .../src}/Effectful/Reader.hs | 0 .../src}/Effectful/Reader/Dynamic.hs | 0 .../src}/Effectful/State/Dynamic.hs | 0 .../src}/Effectful/State/Local.hs | 0 .../src}/Effectful/State/Shared.hs | 0 .../src}/Effectful/Writer/Dynamic.hs | 0 .../src}/Effectful/Writer/Local.hs | 0 .../src}/Effectful/Writer/Shared.hs | 0 .../utils}/Effectful/Internal/Utils.hs | 0 {utils => effectful-core/utils}/utils.c | 0 effectful/CHANGELOG.md | 2 + effectful/LICENSE | 30 ++++++ {bench => effectful/bench}/Concurrency.hs | 0 {bench => effectful/bench}/Countdown.hs | 0 {bench => effectful/bench}/FileSizes.hs | 0 {bench => effectful/bench}/Main.hs | 0 {bench => effectful/bench}/Unlift.hs | 0 {bench => effectful/bench}/Utils.hs | 0 effectful.cabal => effectful/effectful.cabal | 65 +++++------- .../examples}/FileSystem.hs | 4 +- {src => effectful/src}/Effectful.hs | 0 {src => effectful/src}/Effectful/Async.hs | 0 {src => effectful/src}/Effectful/Resource.hs | 0 {tests => effectful/tests}/AsyncTests.hs | 0 .../tests}/ConcurrencyTests.hs | 0 {tests => effectful/tests}/ErrorTests.hs | 0 {tests => effectful/tests}/Main.hs | 0 {tests => effectful/tests}/StateTests.hs | 0 {tests => effectful/tests}/Utils.hs | 0 45 files changed, 258 insertions(+), 69 deletions(-) create mode 100644 cabal.project create mode 100644 effectful-core/CHANGELOG.md create mode 100644 effectful-core/LICENSE create mode 100644 effectful-core/effectful-core.cabal rename {src => effectful-core/src}/Effectful/Error.hs (100%) rename {src => effectful-core/src}/Effectful/Error/Dynamic.hs (100%) rename {src => effectful-core/src}/Effectful/Fail.hs (100%) rename {src => effectful-core/src}/Effectful/Handler.hs (99%) rename {src => effectful-core/src}/Effectful/Internal/Effect.hs (100%) rename {src => effectful-core/src}/Effectful/Internal/Env.hs (100%) rename {src => effectful-core/src}/Effectful/Internal/Monad.hs (100%) rename {src => effectful-core/src}/Effectful/Internal/Unlift.hs (100%) rename {src => effectful-core/src}/Effectful/Monad.hs (100%) rename {src => effectful-core/src}/Effectful/Reader.hs (100%) rename {src => effectful-core/src}/Effectful/Reader/Dynamic.hs (100%) rename {src => effectful-core/src}/Effectful/State/Dynamic.hs (100%) rename {src => effectful-core/src}/Effectful/State/Local.hs (100%) rename {src => effectful-core/src}/Effectful/State/Shared.hs (100%) rename {src => effectful-core/src}/Effectful/Writer/Dynamic.hs (100%) rename {src => effectful-core/src}/Effectful/Writer/Local.hs (100%) rename {src => effectful-core/src}/Effectful/Writer/Shared.hs (100%) rename {utils => effectful-core/utils}/Effectful/Internal/Utils.hs (100%) rename {utils => effectful-core/utils}/utils.c (100%) create mode 100644 effectful/CHANGELOG.md create mode 100644 effectful/LICENSE rename {bench => effectful/bench}/Concurrency.hs (100%) rename {bench => effectful/bench}/Countdown.hs (100%) rename {bench => effectful/bench}/FileSizes.hs (100%) rename {bench => effectful/bench}/Main.hs (100%) rename {bench => effectful/bench}/Unlift.hs (100%) rename {bench => effectful/bench}/Utils.hs (100%) rename effectful.cabal => effectful/effectful.cabal (70%) rename {examples => effectful/examples}/FileSystem.hs (93%) rename {src => effectful/src}/Effectful.hs (100%) rename {src => effectful/src}/Effectful/Async.hs (100%) rename {src => effectful/src}/Effectful/Resource.hs (100%) rename {tests => effectful/tests}/AsyncTests.hs (100%) rename {tests => effectful/tests}/ConcurrencyTests.hs (100%) rename {tests => effectful/tests}/ErrorTests.hs (100%) rename {tests => effectful/tests}/Main.hs (100%) rename {tests => effectful/tests}/StateTests.hs (100%) rename {tests => effectful/tests}/Utils.hs (100%) diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index 6206529..5347e61 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -1,6 +1,6 @@ # This GitHub workflow config has been generated by a script via # -# haskell-ci 'github' '--config=cabal.haskell-ci' 'effectful.cabal' +# haskell-ci 'github' '--config=cabal.haskell-ci' 'cabal.project' # # To regenerate the script (for example after adjusting tested-with) run # @@ -10,7 +10,7 @@ # # version: 0.13.20210621 # -# REGENDATA ("0.13.20210621",["github","--config=cabal.haskell-ci","effectful.cabal"]) +# REGENDATA ("0.13.20210621",["github","--config=cabal.haskell-ci","cabal.project"]) # name: Haskell-CI on: @@ -170,7 +170,8 @@ jobs: - name: initial cabal.project for sdist run: | touch cabal.project - echo "packages: $GITHUB_WORKSPACE/source/." >> cabal.project + echo "packages: $GITHUB_WORKSPACE/source/effectful" >> cabal.project + echo "packages: $GITHUB_WORKSPACE/source/effectful-core" >> cabal.project cat cabal.project - name: sdist run: | @@ -184,12 +185,17 @@ jobs: run: | PKGDIR_effectful="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/effectful-[0-9.]*')" echo "PKGDIR_effectful=${PKGDIR_effectful}" >> "$GITHUB_ENV" + PKGDIR_effectful_core="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/effectful-core-[0-9.]*')" + echo "PKGDIR_effectful_core=${PKGDIR_effectful_core}" >> "$GITHUB_ENV" rm -f cabal.project cabal.project.local touch cabal.project touch cabal.project.local echo "packages: ${PKGDIR_effectful}" >> cabal.project + echo "packages: ${PKGDIR_effectful_core}" >> cabal.project echo "package effectful" >> cabal.project echo " ghc-options: -Werror=missing-methods" >> cabal.project + echo "package effectful-core" >> cabal.project + echo " ghc-options: -Werror=missing-methods" >> cabal.project cat >> cabal.project <> cabal.project fi - $HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(effectful)$/; }' >> cabal.project.local + $HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(effectful|effectful-core)$/; }' >> cabal.project.local cat cabal.project cat cabal.project.local - name: dump install plan @@ -227,12 +233,14 @@ jobs: run: | if [ $((HCNUMVER < 90200)) -ne 0 ] ; then cd ${PKGDIR_effectful} || false ; fi if [ $((HCNUMVER < 90200)) -ne 0 ] ; then doctest -XBangPatterns -XConstraintKinds -XDataKinds -XDeriveFunctor -XFlexibleContexts -XFlexibleInstances -XGADTs -XGeneralizedNewtypeDeriving -XLambdaCase -XMultiParamTypeClasses -XNoStarIsType -XRankNTypes -XRecordWildCards -XRoleAnnotations -XScopedTypeVariables -XStandaloneDeriving -XStrictData -XTupleSections -XTypeApplications -XTypeFamilies -XTypeOperators src ; fi - if [ $((HCNUMVER < 90200)) -ne 0 ] ; then cd ${PKGDIR_effectful} || false ; fi - if [ $((HCNUMVER < 90200)) -ne 0 ] ; then doctest -XBangPatterns -XConstraintKinds -XDataKinds -XDeriveFunctor -XFlexibleContexts -XFlexibleInstances -XGADTs -XGeneralizedNewtypeDeriving -XLambdaCase -XMultiParamTypeClasses -XNoStarIsType -XRankNTypes -XRecordWildCards -XRoleAnnotations -XScopedTypeVariables -XStandaloneDeriving -XStrictData -XTupleSections -XTypeApplications -XTypeFamilies -XTypeOperators utils ; fi + if [ $((HCNUMVER < 90200)) -ne 0 ] ; then cd ${PKGDIR_effectful_core} || false ; fi + if [ $((HCNUMVER < 90200)) -ne 0 ] ; then doctest -XBangPatterns -XConstraintKinds -XDataKinds -XDeriveFunctor -XFlexibleContexts -XFlexibleInstances -XGADTs -XGeneralizedNewtypeDeriving -XLambdaCase -XMultiParamTypeClasses -XNoStarIsType -XRankNTypes -XRecordWildCards -XRoleAnnotations -XScopedTypeVariables -XStandaloneDeriving -XStrictData -XTupleSections -XTypeApplications -XTypeFamilies -XTypeOperators src ; fi - name: cabal check run: | cd ${PKGDIR_effectful} || false ${CABAL} -vnormal check + cd ${PKGDIR_effectful_core} || false + ${CABAL} -vnormal check - name: haddock run: | $CABAL v2-haddock $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all diff --git a/README.md b/README.md index 8a0038b..32143ee 100644 --- a/README.md +++ b/README.md @@ -100,11 +100,25 @@ to "boring" transformer stacks, most of which are a dozen of newtype'd `StateT` or `ReaderT` transformers, each with a few associated operations (usually tied to a type class), not to replace monad transformers altogether. +## Usage + +The effect system and its effects are split among several libraries: + +- The `effectful-core` library contains the main machinery of the effect system + itself and a few basic effects. + It aims for a small dependency footprint and provides the building blocks for + more advanced effects. + +- _TBD_ `effectful-resource`, `effectful-process`, ... + +- Finally, the `effectful` library which comes with 'batteries included'. It is + build on top of the other libraries and re-exports the functionality of those. + ## Example A `Filesystem` effect with two handlers, one that runs in `IO` and another that uses an in-memory virtual file system can be found -[here](https://github.com/arybczak/effectful/blob/master/examples/FileSystem.hs). +[here](https://github.com/arybczak/effectful/blob/master/effectful/examples/FileSystem.hs). ## Resources diff --git a/cabal.project b/cabal.project new file mode 100644 index 0000000..8d38526 --- /dev/null +++ b/cabal.project @@ -0,0 +1,3 @@ +packages: + effectful/effectful.cabal + effectful-core/effectful-core.cabal diff --git a/doctest.sh b/doctest.sh index 86ee5b9..0b8dc25 100755 --- a/doctest.sh +++ b/doctest.sh @@ -7,25 +7,35 @@ # - Compile doctest with the same GHC version the project currently uses. # -doctest src \ - -XBangPatterns \ - -XConstraintKinds \ - -XDataKinds \ - -XDeriveFunctor \ - -XFlexibleContexts \ - -XFlexibleInstances \ - -XGADTs \ - -XGeneralizedNewtypeDeriving \ - -XLambdaCase \ - -XMultiParamTypeClasses \ - -XNoStarIsType \ - -XRankNTypes \ - -XRecordWildCards \ - -XRoleAnnotations \ - -XScopedTypeVariables \ - -XStandaloneDeriving \ - -XStrictData \ - -XTupleSections \ - -XTypeApplications \ - -XTypeFamilies \ - -XTypeOperators +set -eu + +run_doctest() { + pushd "${1}" + doctest \ + "${2}" \ + -XBangPatterns \ + -XConstraintKinds \ + -XDataKinds \ + -XDeriveFunctor \ + -XFlexibleContexts \ + -XFlexibleInstances \ + -XGADTs \ + -XGeneralizedNewtypeDeriving \ + -XLambdaCase \ + -XMultiParamTypeClasses \ + -XNoStarIsType \ + -XRankNTypes \ + -XRecordWildCards \ + -XRoleAnnotations \ + -XScopedTypeVariables \ + -XStandaloneDeriving \ + -XStrictData \ + -XTupleSections \ + -XTypeApplications \ + -XTypeFamilies \ + -XTypeOperators + popd +} + +run_doctest effectful src +run_doctest effectful-core src diff --git a/effectful-core/CHANGELOG.md b/effectful-core/CHANGELOG.md new file mode 100644 index 0000000..c1f6c8d --- /dev/null +++ b/effectful-core/CHANGELOG.md @@ -0,0 +1,2 @@ +# effectful-core-0.0.0.0 (2021-06-13) +* Initial alpha release. diff --git a/effectful-core/LICENSE b/effectful-core/LICENSE new file mode 100644 index 0000000..c6e1d2d --- /dev/null +++ b/effectful-core/LICENSE @@ -0,0 +1,30 @@ +Copyright (c) 2021, Andrzej Rybczak + +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 Andrzej Rybczak 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. diff --git a/effectful-core/effectful-core.cabal b/effectful-core/effectful-core.cabal new file mode 100644 index 0000000..573d354 --- /dev/null +++ b/effectful-core/effectful-core.cabal @@ -0,0 +1,100 @@ +cabal-version: 2.4 +build-type: Simple +name: effectful-core +version: 0.0.0.0 +license: BSD-3-Clause +license-file: LICENSE +category: Control +maintainer: andrzej@rybczak.net +author: Andrzej Rybczak +synopsis: An easy to use, performant extensible effects library. + +description: An easy to use, performant extensible effects library with seamless + integration with the existing Haskell ecosystem. + . + This library provides the core of the effect system and is quiet + minimal. If you look for something more sophisticated have a look + at the @@ + package. + +extra-source-files: CHANGELOG.md + +tested-with: GHC ==8.8.4 || ==8.10.4 || ==9.0.1 || ==9.2.0.20210422 + +bug-reports: https://github.com/arybczak/effectful/issues +source-repository head + type: git + location: https://github.com/arybczak/effectful.git + +common language + ghc-options: -Wall -Wcompat + + default-language: Haskell2010 + + default-extensions: BangPatterns + ConstraintKinds + DataKinds + DeriveFunctor + FlexibleContexts + FlexibleInstances + GADTs + GeneralizedNewtypeDeriving + LambdaCase + MultiParamTypeClasses + NoStarIsType + RankNTypes + RecordWildCards + RoleAnnotations + ScopedTypeVariables + StandaloneDeriving + StrictData + TupleSections + TypeApplications + TypeFamilies + TypeOperators + +library effectful-internal-utils + import: language + + build-depends: base + + hs-source-dirs: utils + c-sources: utils/utils.c + + exposed-modules: Effectful.Internal.Utils + +library + import: language + + ghc-options: -O2 + + build-depends: base >= 4.13 && <5 + , containers + , effectful-internal-utils + , exceptions + , monad-control + , primitive + , transformers-base + , unliftio-core + + hs-source-dirs: src + + exposed-modules: Effectful.Error + Effectful.Error.Dynamic + Effectful.Fail + Effectful.Handler + Effectful.Internal.Effect + Effectful.Internal.Env + Effectful.Internal.Monad + Effectful.Internal.Unlift + Effectful.Monad + Effectful.Reader + Effectful.Reader.Dynamic + Effectful.State.Dynamic + Effectful.State.Local + Effectful.State.Shared + Effectful.Writer.Dynamic + Effectful.Writer.Local + Effectful.Writer.Shared + + reexported-modules: Effectful.Internal.Utils diff --git a/src/Effectful/Error.hs b/effectful-core/src/Effectful/Error.hs similarity index 100% rename from src/Effectful/Error.hs rename to effectful-core/src/Effectful/Error.hs diff --git a/src/Effectful/Error/Dynamic.hs b/effectful-core/src/Effectful/Error/Dynamic.hs similarity index 100% rename from src/Effectful/Error/Dynamic.hs rename to effectful-core/src/Effectful/Error/Dynamic.hs diff --git a/src/Effectful/Fail.hs b/effectful-core/src/Effectful/Fail.hs similarity index 100% rename from src/Effectful/Fail.hs rename to effectful-core/src/Effectful/Fail.hs diff --git a/src/Effectful/Handler.hs b/effectful-core/src/Effectful/Handler.hs similarity index 99% rename from src/Effectful/Handler.hs rename to effectful-core/src/Effectful/Handler.hs index 8e9659a..82582d9 100644 --- a/src/Effectful/Handler.hs +++ b/effectful-core/src/Effectful/Handler.hs @@ -267,4 +267,3 @@ localLiftUnliftIO (LocalEnv les) strategy k = case strategy of -- $setup -- >>> import Control.Concurrent --- >>> import Effectful diff --git a/src/Effectful/Internal/Effect.hs b/effectful-core/src/Effectful/Internal/Effect.hs similarity index 100% rename from src/Effectful/Internal/Effect.hs rename to effectful-core/src/Effectful/Internal/Effect.hs diff --git a/src/Effectful/Internal/Env.hs b/effectful-core/src/Effectful/Internal/Env.hs similarity index 100% rename from src/Effectful/Internal/Env.hs rename to effectful-core/src/Effectful/Internal/Env.hs diff --git a/src/Effectful/Internal/Monad.hs b/effectful-core/src/Effectful/Internal/Monad.hs similarity index 100% rename from src/Effectful/Internal/Monad.hs rename to effectful-core/src/Effectful/Internal/Monad.hs diff --git a/src/Effectful/Internal/Unlift.hs b/effectful-core/src/Effectful/Internal/Unlift.hs similarity index 100% rename from src/Effectful/Internal/Unlift.hs rename to effectful-core/src/Effectful/Internal/Unlift.hs diff --git a/src/Effectful/Monad.hs b/effectful-core/src/Effectful/Monad.hs similarity index 100% rename from src/Effectful/Monad.hs rename to effectful-core/src/Effectful/Monad.hs diff --git a/src/Effectful/Reader.hs b/effectful-core/src/Effectful/Reader.hs similarity index 100% rename from src/Effectful/Reader.hs rename to effectful-core/src/Effectful/Reader.hs diff --git a/src/Effectful/Reader/Dynamic.hs b/effectful-core/src/Effectful/Reader/Dynamic.hs similarity index 100% rename from src/Effectful/Reader/Dynamic.hs rename to effectful-core/src/Effectful/Reader/Dynamic.hs diff --git a/src/Effectful/State/Dynamic.hs b/effectful-core/src/Effectful/State/Dynamic.hs similarity index 100% rename from src/Effectful/State/Dynamic.hs rename to effectful-core/src/Effectful/State/Dynamic.hs diff --git a/src/Effectful/State/Local.hs b/effectful-core/src/Effectful/State/Local.hs similarity index 100% rename from src/Effectful/State/Local.hs rename to effectful-core/src/Effectful/State/Local.hs diff --git a/src/Effectful/State/Shared.hs b/effectful-core/src/Effectful/State/Shared.hs similarity index 100% rename from src/Effectful/State/Shared.hs rename to effectful-core/src/Effectful/State/Shared.hs diff --git a/src/Effectful/Writer/Dynamic.hs b/effectful-core/src/Effectful/Writer/Dynamic.hs similarity index 100% rename from src/Effectful/Writer/Dynamic.hs rename to effectful-core/src/Effectful/Writer/Dynamic.hs diff --git a/src/Effectful/Writer/Local.hs b/effectful-core/src/Effectful/Writer/Local.hs similarity index 100% rename from src/Effectful/Writer/Local.hs rename to effectful-core/src/Effectful/Writer/Local.hs diff --git a/src/Effectful/Writer/Shared.hs b/effectful-core/src/Effectful/Writer/Shared.hs similarity index 100% rename from src/Effectful/Writer/Shared.hs rename to effectful-core/src/Effectful/Writer/Shared.hs diff --git a/utils/Effectful/Internal/Utils.hs b/effectful-core/utils/Effectful/Internal/Utils.hs similarity index 100% rename from utils/Effectful/Internal/Utils.hs rename to effectful-core/utils/Effectful/Internal/Utils.hs diff --git a/utils/utils.c b/effectful-core/utils/utils.c similarity index 100% rename from utils/utils.c rename to effectful-core/utils/utils.c diff --git a/effectful/CHANGELOG.md b/effectful/CHANGELOG.md new file mode 100644 index 0000000..828f228 --- /dev/null +++ b/effectful/CHANGELOG.md @@ -0,0 +1,2 @@ +# effectful-0.0.0.0 (2021-06-13) +* Initial alpha release. diff --git a/effectful/LICENSE b/effectful/LICENSE new file mode 100644 index 0000000..c6e1d2d --- /dev/null +++ b/effectful/LICENSE @@ -0,0 +1,30 @@ +Copyright (c) 2021, Andrzej Rybczak + +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 Andrzej Rybczak 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. diff --git a/bench/Concurrency.hs b/effectful/bench/Concurrency.hs similarity index 100% rename from bench/Concurrency.hs rename to effectful/bench/Concurrency.hs diff --git a/bench/Countdown.hs b/effectful/bench/Countdown.hs similarity index 100% rename from bench/Countdown.hs rename to effectful/bench/Countdown.hs diff --git a/bench/FileSizes.hs b/effectful/bench/FileSizes.hs similarity index 100% rename from bench/FileSizes.hs rename to effectful/bench/FileSizes.hs diff --git a/bench/Main.hs b/effectful/bench/Main.hs similarity index 100% rename from bench/Main.hs rename to effectful/bench/Main.hs diff --git a/bench/Unlift.hs b/effectful/bench/Unlift.hs similarity index 100% rename from bench/Unlift.hs rename to effectful/bench/Unlift.hs diff --git a/bench/Utils.hs b/effectful/bench/Utils.hs similarity index 100% rename from bench/Utils.hs rename to effectful/bench/Utils.hs diff --git a/effectful.cabal b/effectful/effectful.cabal similarity index 70% rename from effectful.cabal rename to effectful/effectful.cabal index 03aa8cc..d368994 100644 --- a/effectful.cabal +++ b/effectful/effectful.cabal @@ -11,9 +11,13 @@ synopsis: An easy to use, performant extensible effects library. description: An easy to use, performant extensible effects library with seamless integration with the existing Haskell ecosystem. + . + This is the "batteries included" variant; See the + @@ + package for the effect system itself as well as the various other + @effectful-*@ packages if you need a smaller dependency footprint. extra-source-files: CHANGELOG.md - README.md tested-with: GHC ==8.8.4 || ==8.10.4 || ==9.0.1 || ==9.2.0.20210422 @@ -53,16 +57,6 @@ common language TypeFamilies TypeOperators -library effectful-internal-utils - import: language - - build-depends: base - - hs-source-dirs: utils - c-sources: utils/utils.c - - exposed-modules: Effectful.Internal.Utils - library import: language @@ -70,40 +64,34 @@ library build-depends: base >= 4.13 && <5 , async - , containers - , effectful-internal-utils - , exceptions - , monad-control - , primitive + , effectful-core , resourcet - , transformers-base - , unliftio-core , unliftio hs-source-dirs: src exposed-modules: Effectful Effectful.Async - Effectful.Error - Effectful.Error.Dynamic - Effectful.Fail - Effectful.Handler - Effectful.Internal.Effect - Effectful.Internal.Env - Effectful.Internal.Monad - Effectful.Internal.Unlift - Effectful.Monad - Effectful.Reader - Effectful.Reader.Dynamic Effectful.Resource - Effectful.State.Dynamic - Effectful.State.Local - Effectful.State.Shared - Effectful.Writer.Dynamic - Effectful.Writer.Local - Effectful.Writer.Shared - reexported-modules: Effectful.Internal.Utils + reexported-modules: Effectful.Error + , Effectful.Error.Dynamic + , Effectful.Fail + , Effectful.Handler + , Effectful.Internal.Effect + , Effectful.Internal.Env + , Effectful.Internal.Monad + , Effectful.Internal.Unlift + , Effectful.Internal.Utils + , Effectful.Monad + , Effectful.Reader + , Effectful.Reader.Dynamic + , Effectful.State.Dynamic + , Effectful.State.Local + , Effectful.State.Shared + , Effectful.Writer.Dynamic + , Effectful.Writer.Local + , Effectful.Writer.Shared test-suite test import: language @@ -119,7 +107,7 @@ test-suite test , tasty-hunit , unliftio - hs-source-dirs: tests + hs-source-dirs: tests examples type: exitcode-stdio-1.0 main-is: Main.hs @@ -129,6 +117,9 @@ test-suite test ErrorTests StateTests Utils + -- These are examples; We do not actually run them but list + -- them here in order to check if they compile. + FileSystem benchmark bench import: language diff --git a/examples/FileSystem.hs b/effectful/examples/FileSystem.hs similarity index 93% rename from examples/FileSystem.hs rename to effectful/examples/FileSystem.hs index d70a944..9ca1300 100644 --- a/examples/FileSystem.hs +++ b/effectful/examples/FileSystem.hs @@ -44,7 +44,7 @@ runFileSystemIO :: (IOE :> es, Error FsError :> es) => Eff (FileSystem : es) a -> Eff es a -runFileSystemIO = interpret $ \case +runFileSystemIO = interpret $ \_ -> \case ReadFile path -> adapt $ IO.readFile path WriteFile path contents -> adapt $ IO.writeFile path contents where @@ -55,7 +55,7 @@ runFileSystemPure => M.Map FilePath String -> Eff (FileSystem : es) a -> Eff es a -runFileSystemPure fs0 = reinterpret (evalState fs0) $ \case +runFileSystemPure fs0 = reinterpret (evalState fs0) $ \_ -> \case ReadFile path -> gets (M.lookup path) >>= \case Just contents -> pure contents Nothing -> throwError . FsError $ "File not found: " ++ show path diff --git a/src/Effectful.hs b/effectful/src/Effectful.hs similarity index 100% rename from src/Effectful.hs rename to effectful/src/Effectful.hs diff --git a/src/Effectful/Async.hs b/effectful/src/Effectful/Async.hs similarity index 100% rename from src/Effectful/Async.hs rename to effectful/src/Effectful/Async.hs diff --git a/src/Effectful/Resource.hs b/effectful/src/Effectful/Resource.hs similarity index 100% rename from src/Effectful/Resource.hs rename to effectful/src/Effectful/Resource.hs diff --git a/tests/AsyncTests.hs b/effectful/tests/AsyncTests.hs similarity index 100% rename from tests/AsyncTests.hs rename to effectful/tests/AsyncTests.hs diff --git a/tests/ConcurrencyTests.hs b/effectful/tests/ConcurrencyTests.hs similarity index 100% rename from tests/ConcurrencyTests.hs rename to effectful/tests/ConcurrencyTests.hs diff --git a/tests/ErrorTests.hs b/effectful/tests/ErrorTests.hs similarity index 100% rename from tests/ErrorTests.hs rename to effectful/tests/ErrorTests.hs diff --git a/tests/Main.hs b/effectful/tests/Main.hs similarity index 100% rename from tests/Main.hs rename to effectful/tests/Main.hs diff --git a/tests/StateTests.hs b/effectful/tests/StateTests.hs similarity index 100% rename from tests/StateTests.hs rename to effectful/tests/StateTests.hs diff --git a/tests/Utils.hs b/effectful/tests/Utils.hs similarity index 100% rename from tests/Utils.hs rename to effectful/tests/Utils.hs