packages feed

natural-transformation 0.3.1 → 0.4

raw patch · 6 files changed

+43/−34 lines, 6 filesdep +semigroupsdep ~containersdep ~natural-transformationdep ~tasty

Dependencies added: semigroups

Dependency ranges changed: containers, natural-transformation, tasty, tasty-quickcheck

Files

CHANGELOG.md view
@@ -1,3 +1,10 @@+# 0.4+* Rename `Nat` constructor to `NT`+* Rename `run` to `unwrapNT`+* Rename `nat` to `wrapNT`+* Backport the `Semigroup` instance for `(:~>)` by conditionally depending on+  the `semigroups` package+ # 0.3.1 * Adding `run` and `nat`. 
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2015, The University of Kansas+Copyright (c) 2015-2016, The University of Kansas  All rights reserved. 
natural-transformation.cabal view
@@ -1,5 +1,5 @@ name:                natural-transformation-version:             0.3.1+version:             0.4 synopsis:            A natural transformation package. description:         A natural transformation transforms a container @f a@ into another                      container @g a@. Natural transformations act as functor morphisms@@ -14,23 +14,26 @@ stability:           Provisional author:              Andy Gill maintainer:          Andy Gill <andygill@ku.edu>-copyright:           Copyright (c) 2015 The University of Kansas+copyright:           Copyright (c) 2015-2016 The University of Kansas category:            Control build-type:          Simple extra-source-files:  CHANGELOG.md, README.md-tested-with:         GHC == 7.8.4, GHC == 7.10.3+tested-with:         GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.1 cabal-version:       >= 1.10  source-repository head   type:                git-  location:            git://github.com/ku-fpg/natural-transformation+  location:            https://github.com/ku-fpg/natural-transformation  library   exposed-modules:     Control.Natural                        Control.Natural.RULES                        Control.Object-                       -  build-depends:       base >= 4.7 && < 5++  build-depends:       base       >= 4.7  && < 5+  if !impl(ghc >= 8.0)+    build-depends:     semigroups >= 0.16 && < 0.19+   hs-source-dirs:      src   default-language:    Haskell2010   ghc-options:         -Wall@@ -40,7 +43,7 @@   main-is:             Properties.hs   build-depends:       base                   >= 4.7 && < 5                      , containers             >= 0.1 && < 0.6-                     , natural-transformation == 0.3.1+                     , natural-transformation == 0.4                      , quickcheck-instances   >= 0.1 && < 0.4                      , tasty                  >= 0.8 && < 0.12                      , tasty-quickcheck       >= 0.8 && < 0.9
src/Control/Natural.hs view
@@ -24,8 +24,8 @@     -- * Type Synonym for a Natural Transformation   , type (~>)     -- * Conversion functions between the newtype and the synonym-  , run-  , nat+  , wrapNT+  , unwrapNT     -- * Class for Natural Transformations   , Transformation(..)   ) where@@ -35,9 +35,7 @@ #if !(MIN_VERSION_base(4,8,0)) import           Data.Monoid (Monoid(..)) #endif-#if MIN_VERSION_base(4,9,0) import           Data.Semigroup (Semigroup(..))-#endif import           Data.Typeable  ---------------------------------------------------------------------------@@ -50,21 +48,19 @@  infixr 0 :~>, $$ -- | A natural transformation suitable for storing in a container.-newtype f :~> g = Nat { ($$) :: f ~> g }+newtype f :~> g = NT { ($$) :: f ~> g }   deriving Typeable  instance C.Category (:~>) where-    id = Nat id-    Nat f . Nat g = Nat (f . g)+    id = NT id+    NT f . NT g = NT (f . g) -#if MIN_VERSION_base(4,9,0) instance f ~ g => Semigroup (f :~> g) where-    Nat f <> Nat g = Nat (f . g)-#endif+    NT f <> NT g = NT (f . g)  instance f ~ g => Monoid (f :~> g) where-    mempty = Nat id-    mappend (Nat f) (Nat g) = Nat (f . g)+    mempty = NT id+    mappend = (<>)  infix 0 # -- | A (natural) transformation is inside @t@, and contains @f@ and @g@@@ -78,14 +74,17 @@     (#) :: t -> forall a . f a -> g a  instance Transformation f g (f :~> g) where-    Nat f # g = f g+    NT f # g = f g --- | 'run' is the nonfix version of @#@. It is used to break natural---   transformation wrappers, including ':~>'.-run :: Transformation f g t => t -> (forall a . f a -> g a)-run = (#)+-- | 'wrapNT' builds our natural transformation abstraction out of+-- a natural transformation function.+--+-- An alias to 'NT' provided for symmetry with 'unwrapNT'.+--+wrapNT :: (forall a . f a -> g a) -> f :~> g+wrapNT = NT --- | 'nat' builds our natural transformation abstraction out of---    a natural transformation function.-nat :: (forall a . f a -> g a) -> f :~> g-nat = Nat+-- | 'unwrapNT' is the nonfix version of @#@. It is used to break natural+--   transformation wrappers, including ':~>'.+unwrapNT :: Transformation f g t => t -> (forall a . f a -> g a)+unwrapNT = (#)
src/Control/Object.hs view
@@ -22,4 +22,4 @@ newtype Object f = Object (f ~> IO)  instance Transformation f IO (Object f) where-    Object f # g = Nat f # g+    Object f # g = NT f # g
tests/Properties.hs view
@@ -58,19 +58,19 @@  -- | A natural transformations from lists to lists that 'reverse's. listReverseNT :: [] :~> []-listReverseNT = Nat reverse+listReverseNT = NT reverse  -- | A natural transformation from lists to lists that shifts all elements to the left, -- moving the head element to the back. listShiftNT :: [] :~> []-listShiftNT = Nat $ \l -> case l of+listShiftNT = NT $ \l -> case l of                                []     -> []                                (x:xs) -> xs ++ [x]  -- | A natural transformation from lists to 'Seq's. listSeqNT :: [] :~> Seq-listSeqNT = Nat fromList+listSeqNT = NT fromList  -- | A natural transformation from 'Seq's to lists. seqListNT :: Seq :~> []-seqListNT = Nat toList+seqListNT = NT toList