packages feed

perm 0.2.0.0 → 0.2.0.1

raw patch · 6 files changed

+109/−86 lines, 6 filessetup-changed

Files

Control/Applicative/Perm.hs view
@@ -1,18 +1,18 @@-{- |
-Copyright: Andy Sonnenburg (c) 2012
-License: BSD-style (see the file LICENSE)
-Maintainer: Andy Sonnenburg <andy22286@gmail.com>
-Stability: experimental
-Portability: non-portable
--}
-module Control.Applicative.Perm
-       ( Perm
-       , runPerm
-       , liftPerm
-       , hoistPerm
-       ) where
-
-import Control.Monad.Perm.Internal (Perm,
-                                    hoistPerm,
-                                    liftPerm,
-                                    runPerm)
+{- |+Copyright: Andy Sonnenburg (c) 2012+License: BSD-style (see the file LICENSE)+Maintainer: Andy Sonnenburg <andy22286@gmail.com>+Stability: experimental+Portability: non-portable+-}+module Control.Applicative.Perm+       ( Perm+       , runPerm+       , liftPerm+       , hoistPerm+       ) where++import Control.Monad.Perm.Internal (Perm,+                                    hoistPerm,+                                    liftPerm,+                                    runPerm)
Control/Monad/Perm.hs view
@@ -1,18 +1,18 @@-{- |
-Copyright: Andy Sonnenburg (c) 2012
-License: BSD-style (see the file LICENSE)
-Maintainer: Andy Sonnenburg <andy22286@gmail.com>
-Stability: experimental
-Portability: non-portable
--}
-module Control.Monad.Perm
-       ( PermT
-       , runPermT
-       , liftPerm
-       , hoistPerm
-       ) where
-
-import Control.Monad.Perm.Internal (PermT,
-                                    liftPerm,
-                                    hoistPerm,
-                                    runPermT)
+{- |+Copyright: Andy Sonnenburg (c) 2012+License: BSD-style (see the file LICENSE)+Maintainer: Andy Sonnenburg <andy22286@gmail.com>+Stability: experimental+Portability: non-portable+-}+module Control.Monad.Perm+       ( PermT+       , runPermT+       , liftPerm+       , hoistPerm+       ) where++import Control.Monad.Perm.Internal (PermT,+                                    liftPerm,+                                    hoistPerm,+                                    runPermT)
Control/Monad/Perm/Internal.hs view
@@ -23,23 +23,31 @@  import Control.Applicative import Control.Monad-import Control.Monad.Catch.Class-import Control.Monad.IO.Class-import Control.Monad.Reader.Class-import Control.Monad.State.Class+#if LANGUAGE_DefaultSignatures+import Control.Monad.Catch.Class (MonadThrow)+#else+import Control.Monad.Catch.Class (MonadThrow (throw))+#endif+import Control.Monad.IO.Class (MonadIO (liftIO))+#if MIN_VERSION_mtl(2, 1, 0)+import Control.Monad.Reader.Class (MonadReader (ask, local, reader))+import Control.Monad.State.Class (MonadState (get, put, state))+#else+import Control.Monad.Reader.Class (MonadReader (ask, local))+import Control.Monad.State.Class (MonadState (get, put))+#endif import Control.Monad.Trans.Class (MonadTrans (lift))  import Data.Foldable (foldr)-import Data.Monoid (mempty)-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 704-import Data.Monoid ((<>))+#if MIN_VERSION_base(4, 5, 0)+import Data.Monoid ((<>), mempty) #else-import Data.Monoid (Monoid, mappend)+import Data.Monoid (Monoid, mappend, mempty) #endif  import Prelude (Maybe (..), ($), (.), const, flip, fst, id, map, maybe) -#if !defined(__GLASGOW_HASKELL__) || __GLASGOW_HASKELL__ < 704+#if !MIN_VERSION_base(4, 5, 0) (<>) :: Monoid m => m -> m -> m (<>) = mappend {-# INLINE (<>) #-}@@ -57,16 +65,25 @@  instance Functor (PermT m) where   fmap f (Choice a xs) = Choice (f <$> a) (fmap f <$> xs)+#if MIN_VERSION_base(4, 2, 0)+  a <$ Choice b xs = Choice (a <$ b) (fmap (a <$) xs)+#endif  instance Functor (Branch m) where   fmap f (Ap perm m) = Ap (fmap (f .) perm) m   fmap f (Bind k m) = Bind (fmap f . k) m+#if MIN_VERSION_base(4, 2, 0)+  a <$ Ap perm m = Ap (const a <$ perm) m+  a <$ Bind k m = Bind ((a <$) . k) m+#endif  instance Applicative (PermT m) where   pure a = Choice (pure a) mempty   f@(Choice f' fs) <*> a@(Choice a' as) =     Choice (f' <*> a') (fmap (`apB` a) fs <> fmap (f `apP`) as)+#if MIN_VERSION_base(4, 2, 0)   (*>) = liftThen (*>)+#endif  apP :: PermT m (a -> b) -> Branch m a -> Branch m b f `apP` Ap perm m = (f .@ perm) `Ap` m@@ -92,7 +109,7 @@   Choice (Just a) xs >>= k = case k a of     Choice a' xs' -> Choice a' (map (bindP k) xs <> xs')   (>>) = liftThen (>>)-  fail _ = Choice mzero mempty+  fail s = Choice (fail s) mempty  bindP :: Monad m => (a -> PermT m b) -> Branch m a -> Branch m b bindP k (Ap perm m) = Bind (\ a -> k . ($ a) =<< perm) m@@ -111,6 +128,9 @@ instance MonadReader r m => MonadReader r (PermT m) where   ask = lift ask   local f (Choice a xs) = Choice a (map (localBranch f) xs)+#if MIN_VERSION_mtl(2, 1, 0)+  reader = lift . reader+#endif  localBranch :: MonadReader r m => (r -> r) -> Branch m a -> Branch m a localBranch f (Ap perm m) = Ap (local f perm) (local f m)@@ -119,6 +139,9 @@ instance MonadState s m => MonadState s (PermT m) where   get = lift get   put = lift . put+#if MIN_VERSION_mtl(2, 1, 0)+  state = lift . state+#endif  #ifdef LANGUAGE_DefaultSignatures instance MonadThrow e m => MonadThrow e (PermT m)@@ -171,8 +194,8 @@ liftBranch = Ap (Choice (pure id) mempty)  {- |-Lift a natural transformation from @m@ to @n@ into a natural transformation-from @'PermT'' c m@ to @'PermT'' c n@.+Lift a monad homomorphism from @m@ to @n@ into a monad homomorphism from+@'PermT' m@ to @'PermT' n@. -} hoistPerm :: Monad n => (forall a . m a -> n a) -> PermT m b -> PermT n b hoistPerm f (Choice a xs) = Choice a (hoistBranch f <$> xs)
LICENSE view
@@ -1,30 +1,30 @@-Copyright (c) 2012, Andy Sonnenburg
-
-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 Andy Sonnenburg 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.
+Copyright (c) 2012, Andy Sonnenburg++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 Andy Sonnenburg 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.
Setup.lhs view
@@ -1,7 +1,7 @@-#!/usr/bin/env runhaskell
-> module Main (main) where
-
-> import Distribution.Simple (defaultMain)
-
-> main :: IO ()
-> main = defaultMain
+#!/usr/bin/env runhaskell+> module Main (main) where++> import Distribution.Simple (defaultMain)++> main :: IO ()+> main = defaultMain
perm.cabal view
@@ -1,5 +1,5 @@ name:          perm-version:       0.2.0.0+version:       0.2.0.1 cabal-version: >= 1.10 synopsis:      permutation Applicative and Monad with many mtl instances description: