Skip to content

Commit

Permalink
Use 'adjust' from 'typerep-map'
Browse files Browse the repository at this point in the history
  • Loading branch information
int-index committed Aug 20, 2018
1 parent ce892d9 commit 6938f8d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion caps.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ library
exposed-modules: Monad.Capabilities
build-depends: base >=4.10 && <4.12,
transformers,
typerep-map >=0.2,
typerep-map >=0.3,
template-haskell
hs-source-dirs: src
default-language: Haskell2010
Expand Down
11 changes: 2 additions & 9 deletions src/Monad/Capabilities.hs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ import Data.Proxy
import Data.Type.Equality
import Data.List (foldl1')
import GHC.TypeLits (TypeError, ErrorMessage(..))
import Type.Reflection (Typeable, typeRep)
import Type.Reflection (Typeable)
import Unsafe.Coerce (unsafeCoerce)

import qualified Data.TypeRepMap as TypeRepMap
Expand Down Expand Up @@ -456,14 +456,7 @@ adjustCap ::
Capabilities caps m ->
Capabilities caps m
adjustCap f (Capabilities caps) =
Capabilities (TypeRepMap.hoistWithKey adj caps)
where
-- TODO: use 'TypeRepMap.adjust' when it is implemented, see #48
adj :: forall x. Typeable x => CapElem m x -> CapElem m x
adj =
case testEquality (typeRep @cap) (typeRep @x) of
Just Refl -> overCapElem f
Nothing -> id
Capabilities (TypeRepMap.adjust (overCapElem f) caps)

-- | Extract a capability from 'CapsT' and provide it to a continuation.
withCap :: (Typeable cap, HasCap cap caps) => (cap (CapsT caps m) -> CapsT caps m a) -> CapsT caps m a
Expand Down

0 comments on commit 6938f8d

Please sign in to comment.