key 0.1.0.0 → 0.1.1.0
raw patch · 2 files changed
+21/−8 lines, 2 filesdep +transformersdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: transformers
Dependency ranges changed: base
API changes (from Hackage documentation)
- Control.Monad.Trans.Key: data Keyring s a
- Control.Monad.Trans.Key: instance forall k (s :: k). GHC.Base.Applicative (Control.Monad.Trans.Key.Keyring s)
- Control.Monad.Trans.Key: instance forall k (s :: k). GHC.Base.Functor (Control.Monad.Trans.Key.Keyring s)
- Control.Monad.Trans.Key: instance forall k (s :: k). GHC.Base.Monad (Control.Monad.Trans.Key.Keyring s)
+ Control.Monad.Trans.Key: data KeyringT s f a
+ Control.Monad.Trans.Key: instance forall k (s :: k) (f :: * -> *). Control.Monad.Fail.MonadFail f => Control.Monad.Fail.MonadFail (Control.Monad.Trans.Key.KeyringT s f)
+ Control.Monad.Trans.Key: instance forall k (s :: k) (f :: * -> *). Control.Monad.Fix.MonadFix f => Control.Monad.Fix.MonadFix (Control.Monad.Trans.Key.KeyringT s f)
+ Control.Monad.Trans.Key: instance forall k (s :: k) (f :: * -> *). GHC.Base.Alternative f => GHC.Base.Alternative (Control.Monad.Trans.Key.KeyringT s f)
+ Control.Monad.Trans.Key: instance forall k (s :: k) (f :: * -> *). GHC.Base.Applicative f => GHC.Base.Applicative (Control.Monad.Trans.Key.KeyringT s f)
+ Control.Monad.Trans.Key: instance forall k (s :: k) (f :: * -> *). GHC.Base.Functor f => GHC.Base.Functor (Control.Monad.Trans.Key.KeyringT s f)
+ Control.Monad.Trans.Key: instance forall k (s :: k) (f :: * -> *). GHC.Base.Monad f => GHC.Base.Monad (Control.Monad.Trans.Key.KeyringT s f)
+ Control.Monad.Trans.Key: instance forall k (s :: k) (f :: * -> *). GHC.Base.MonadPlus f => GHC.Base.MonadPlus (Control.Monad.Trans.Key.KeyringT s f)
+ Control.Monad.Trans.Key: instance forall k (s :: k). Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.Key.KeyringT s)
+ Control.Monad.Trans.Key: type Keyring s = KeyringT s Identity
+ Control.Monad.Trans.Key: unKeyringT :: (forall s. KeyringT s f a) -> f a
- Control.Monad.Trans.Key: newKey :: Keyring s (Key s a)
+ Control.Monad.Trans.Key: newKey :: Applicative p => KeyringT s p (Key s a)
Files
- Control/Monad/Trans/Key.hs +18/−6
- key.cabal +3/−2
Control/Monad/Trans/Key.hs view
@@ -1,24 +1,36 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} -module Control.Monad.Trans.Key (Keyring, Key, newKey, unKeyring) where+module Control.Monad.Trans.Key (Key, newKey, Keyring, unKeyring, KeyringT, unKeyringT) where import Control.Applicative-import Control.Monad (guard)+import Control.Monad (MonadPlus (..), guard)+import Control.Monad.Fail+import Control.Monad.Fix+import Control.Monad.Trans.Class+import Control.Monad.Trans.Reader+import Data.Functor.Identity import Data.IORef import Data.Type.Equality import Numeric.Natural import System.IO.Unsafe import Unsafe.Coerce -newtype Keyring s a = Keyring (IORef Natural -> a) deriving (Functor, Applicative, Monad) newtype Key s a = Key Natural instance TestEquality (Key s) where Key i `testEquality` Key j = unsafeCoerce Refl <$ guard (i == j) -newKey :: Keyring s (Key s a)-newKey = Keyring $ \ r -> unsafePerformIO . atomicModifyIORef' r $ liftA2 (,) (+1) Key+newKey :: Applicative p => KeyringT s p (Key s a)+newKey = KeyringT . ReaderT $ \ r -> pure . unsafePerformIO . atomicModifyIORef' r $ liftA2 (,) (+1) Key +type Keyring s = KeyringT s Identity+ unKeyring :: (∀ s . Keyring s a) -> a-unKeyring (Keyring f) = f $ unsafePerformIO $ newIORef 0+unKeyring x = runIdentity (unKeyringT x)++newtype KeyringT s f a = KeyringT (ReaderT (IORef Natural) f a)+ deriving (Functor, Applicative, Alternative, Monad, MonadPlus, MonadFix, MonadFail, MonadTrans)++unKeyringT :: (∀ s . KeyringT s f a) -> f a+unKeyringT (KeyringT (ReaderT f)) = f $ unsafePerformIO $ newIORef 0
key.cabal view
@@ -1,5 +1,5 @@ name: key-version: 0.1.0.0+version: 0.1.1.0 synopsis: Type-safe unconstrained dynamic typing description: A library of monadic typed keys which can be compared for equality, returning an equality proof if equal. @@ -19,7 +19,8 @@ library hs-source-dirs: . exposed-modules: Control.Monad.Trans.Key- build-depends: base >= 4.7 && < 5+ build-depends: base >= 4.9 && < 5+ , transformers >= 0.4 && < 0.6 default-language: Haskell2010 default-extensions: UnicodeSyntax , LambdaCase