diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6889945..d5eec3e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,8 +23,8 @@ jobs: ~/.cabal/packages ~/.cabal/store dist-newstyle - key: cache-${{ runner.os }}-${{ hashFiles('nixpkgs.nix') }}-v${{ env.cache-invalidation-key }}-${{ hashFiles('linear-base.cabal') }}-${{ github.sha }} - restore-keys: cache-${{ runner.os }}-${{ hashFiles('nixpkgs.nix') }}-v${{ env.cache-invalidation-key }}-${{ hashFiles('linear-base.cabal') }}- + key: cache-${{ runner.os }}-${{ hashFiles('nixpkgs.nix') }}-v${{ env.cache-invalidation-key }}-${{ hashFiles('capability.cabal') }}-${{ github.sha }} + restore-keys: cache-${{ runner.os }}-${{ hashFiles('nixpkgs.nix') }}-v${{ env.cache-invalidation-key }}-${{ hashFiles('capability.cabal') }}- - name: Update Cabal's database run: $NIXSHELL --run "cabal update" - name: Build Cabal's dependencies @@ -35,3 +35,18 @@ jobs: run: $NIXSHELL --run "cabal --flag=dev test" - name: Haddock run: $NIXSHELL --run "cabal haddock" + + stack-ghc9: + name: Build on GHC 9.0 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.3.4 + - name: Cache dependencies + uses: actions/cache@v2.1.6 + with: + path: ~/.stack + key: stack-ghc9-${{ runner.os }}-v${{ env.cache-invalidation-key }}-${{ hashFiles('stack-ghc9.yaml.lock', 'capability.cabal') }} + - name: Upgrade stack + run: stack upgrade + - name: Build + run: stack --stack-yaml=stack-ghc9.yaml build --pedantic --test --bench --no-run-tests --no-run-benchmarks diff --git a/capability.cabal b/capability.cabal index 8726bd8..d788501 100644 --- a/capability.cabal +++ b/capability.cabal @@ -58,7 +58,6 @@ library Capability.Stream Capability.TypeOf Capability.Writer - Capability.Writer.Discouraged build-depends: base >= 4.14 && < 5.0 , constraints >= 0.1 && < 0.14 @@ -67,7 +66,6 @@ library , generic-lens >= 2.0 && < 2.2 , lens >= 4.16 && < 5.1 , monad-control >= 1.0 && < 1.1 - , monad-unlift >= 0.2 && < 0.3 , mtl >= 2.0 && < 3.0 , mutable-containers >= 0.3 && < 0.4 , primitive >= 0.6 && < 0.8 diff --git a/src/Capability.hs b/src/Capability.hs index 4462c00..613f862 100644 --- a/src/Capability.hs +++ b/src/Capability.hs @@ -103,11 +103,6 @@ -- The use of tags allows one to have independent effects that share a superclass. -- E.g. @HasState "foo" Int@ and @HasWriter "bar" String@. -- --- Some of the capability modules have a “discouraged” companion (such as --- "Capability.Writer.Discouraged"). These modules contain deriving-via --- combinators which you can use if you absolutely must: they are correct, but --- inefficient, so we recommend that you do not. --- -- Finally there are -- -- * "Capability.Derive" diff --git a/src/Capability/Error.hs b/src/Capability/Error.hs index fb66776..3d2dac7 100644 --- a/src/Capability/Error.hs +++ b/src/Capability/Error.hs @@ -174,8 +174,8 @@ wrapError :: forall innertag t (cs :: [Capability]) inner m a. , HasCatch innertag inner (t m) , All cs m) => (forall m'. All (HasCatch innertag inner ': cs) m' => m' a) -> m a -wrapError = - derive @t @'[HasCatch innertag inner] @cs +wrapError action = + derive @t @'[HasCatch innertag inner] @cs action {-# INLINE wrapError #-} -- XXX: Does it make sense to add a HasMask capability similar to @MonadMask@? diff --git a/src/Capability/Reader/Internal/Class.hs b/src/Capability/Reader/Internal/Class.hs index 4d691ee..5266504 100644 --- a/src/Capability/Reader/Internal/Class.hs +++ b/src/Capability/Reader/Internal/Class.hs @@ -107,8 +107,8 @@ magnify :: forall innertag t (cs :: [Capability]) inner m a. , HasReader innertag inner (t m) , All cs m) => (forall m'. All (HasReader innertag inner ': cs) m' => m' a) -> m a -magnify = - derive @t @'[HasReader innertag inner] @cs +magnify action = + derive @t @'[HasReader innertag inner] @cs action {-# INLINE magnify #-} -------------------------------------------------------------------------------- diff --git a/src/Capability/Reflection.hs b/src/Capability/Reflection.hs index ad5a4a7..1235752 100644 --- a/src/Capability/Reflection.hs +++ b/src/Capability/Reflection.hs @@ -73,7 +73,7 @@ interpret_ :: Reified tag c m -> (forall m'. c m' => m' a) -> m a -interpret_ = interpret @tag @'[] @c +interpret_ dict action = interpret @tag @'[] @c dict action {-# INLINE interpret_ #-} -- | @interpret \@tag \@ambient dict action@ diff --git a/src/Capability/State/Internal/Class.hs b/src/Capability/State/Internal/Class.hs index c2a4410..e91657f 100644 --- a/src/Capability/State/Internal/Class.hs +++ b/src/Capability/State/Internal/Class.hs @@ -132,8 +132,8 @@ zoom :: forall innertag t (cs :: [Capability]) inner m a. , HasState innertag inner (t m) , All cs m ) => (forall m'. All (HasState innertag inner ': cs) m' => m' a) -> m a -zoom = - derive @t @'[HasState innertag inner] @cs +zoom action = + derive @t @'[HasState innertag inner] @cs action {-# INLINE zoom #-} -------------------------------------------------------------------------------- diff --git a/src/Capability/Writer/Discouraged.hs b/src/Capability/Writer/Discouraged.hs deleted file mode 100644 index f923fc6..0000000 --- a/src/Capability/Writer/Discouraged.hs +++ /dev/null @@ -1,55 +0,0 @@ -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE InstanceSigs #-} -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} -{-# LANGUAGE UndecidableInstances #-} - -{-# OPTIONS_GHC -Wno-orphans #-} -{-# OPTIONS_GHC -Wno-simplifiable-class-constraints #-} - --- | Defines discouraged instances of writer monad capabilities. - -module Capability.Writer.Discouraged - ( ) where - -import Capability.Accessors -import Capability.Writer -import Control.Monad.Trans.Class (lift) -import Control.Monad.Trans.Unlift (MonadTransUnlift, Unlift(..), askUnlift) -import Data.Coerce (coerce) -import GHC.Exts (Proxy#) - --- | Lift one layer in a monad transformer stack. --- --- Note, that if the 'HasWriter' instance is based on 'HasState', then it is --- more efficient to apply 'Lift' to the underlying state capability. E.g. --- you should favour --- --- > deriving (HasWriter tag w) via --- > WriterLog (Lift (SomeTrans (MonadState SomeStateMonad))) --- --- over --- --- > deriving (HasWriter tag w) via --- > Lift (SomeTrans (WriterLog (MonadState SomeStateMonad))) -instance - -- MonadTransUnlift constraint requires -Wno-simplifiable-class-constraints - (HasWriter tag w m, MonadTransUnlift t, Monad (t m)) - => HasWriter tag w (Lift (t m)) - where - writer_ :: forall a. Proxy# tag -> (a, w) -> Lift (t m) a - writer_ _ = coerce @((a, w) -> t m a) $ lift . writer @tag - {-# INLINE writer_ #-} - listen_ :: forall a. Proxy# tag -> Lift (t m) a -> Lift (t m) (a, w) - listen_ _ = coerce @(t m a -> t m (a, w)) $ \m -> do - u <- askUnlift - lift $ listen @tag $ unlift u m - {-# INLINE listen_ #-} - pass_ :: forall a. Proxy# tag -> Lift (t m) (a, w -> w) -> Lift (t m) a - pass_ _ = coerce @(t m (a, w -> w) -> t m a) $ \m -> do - u <- askUnlift - lift $ pass @tag $ unlift u m - {-# INLINE pass_ #-} diff --git a/stack-ghc9.yaml b/stack-ghc9.yaml new file mode 100644 index 0000000..55ea160 --- /dev/null +++ b/stack-ghc9.yaml @@ -0,0 +1,12 @@ +resolver: nightly-2021-07-04 + +packages: +- . + +extra-deps: +# Generic-lens is not yet released in a 9.0-compatible version +- git: https://github.com/kcsongor/generic-lens.git + commit: 8e1fc7dcf444332c474fca17110d4bc554db08c8 + subdirs: + - generic-lens-core + - generic-lens diff --git a/stack-ghc9.yaml.lock b/stack-ghc9.yaml.lock new file mode 100644 index 0000000..863096a --- /dev/null +++ b/stack-ghc9.yaml.lock @@ -0,0 +1,38 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +packages: +- completed: + subdir: generic-lens-core + name: generic-lens-core + version: 2.1.0.0 + git: https://github.com/kcsongor/generic-lens.git + pantry-tree: + size: 2283 + sha256: 5a26b16c38ad8d8ebc81182e1d09858858f16dc117a0c7b084d8446d3a17d749 + commit: 8e1fc7dcf444332c474fca17110d4bc554db08c8 + original: + subdir: generic-lens-core + git: https://github.com/kcsongor/generic-lens.git + commit: 8e1fc7dcf444332c474fca17110d4bc554db08c8 +- completed: + subdir: generic-lens + name: generic-lens + version: 2.1.0.0 + git: https://github.com/kcsongor/generic-lens.git + pantry-tree: + size: 2630 + sha256: aba81557550537d4cfda2c1b07accff8589da44a1e418a3cde5639eb438d1c86 + commit: 8e1fc7dcf444332c474fca17110d4bc554db08c8 + original: + subdir: generic-lens + git: https://github.com/kcsongor/generic-lens.git + commit: 8e1fc7dcf444332c474fca17110d4bc554db08c8 +snapshots: +- completed: + size: 540164 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2021/7/4.yaml + sha256: 195e3e9394de03e724525e210f82e30c4488f7c8a09fc70850d75d8b79332993 + original: nightly-2021-07-04