TypeCompose 0.6.0 → 0.6.1
raw patch · 3 files changed
+21/−11 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- TypeCompose.cabal +1/−4
- src/Control/Compose.hs +19/−6
- wikipage.tw +1/−1
TypeCompose.cabal view
@@ -1,5 +1,5 @@ Name: TypeCompose-Version: 0.6.0+Version: 0.6.1 Synopsis: Type composition classes & instances Category: Composition, Control Description:@@ -7,9 +7,6 @@ composition, as well as some modules who haven't yet found a home. . Please see the project wiki page: <http://haskell.org/haskellwiki/TypeCompose>- .- The module documentation pages have links to colorized source code and- to wiki pages where you can read and contribute /user comments/. Enjoy! . © 2007 by Conal Elliott; BSD3 license. Author: Conal Elliott
src/Control/Compose.hs view
@@ -165,8 +165,12 @@ type O = (:.) -- Here it is, as promised.+ instance (Functor g, Functor f) => Functor (g :. f) where fmap = fmapFF +-- instance (Functor g, Functor f) => Functor (g :. f) where+-- fmap = inO.fmap.fmap+ -- | @newtype@ bijection biO :: g (f a) :<->: (g :. f) a biO = Bi O unO@@ -184,35 +188,44 @@ inO :: (g (f a) -> g' (f' a')) -> ((g :. f) a -> (g' :. f') a') inO = (O .).(. unO) +-- inO h (O gfa) = O (h gfa)+-- inO h = O . h . unO+ -- | Apply a binary function within the 'O' constructor. inO2 :: (g (f a) -> g' (f' a') -> g'' (f'' a'')) -> ((g :. f) a -> (g' :. f') a' -> (g'' :. f'') a'')-inO2 h (O gfa) = inO (h gfa)+inO2 = (inO .).(.unO) +-- inO2 h (O gfa) (O gfa') = O (h gfa gfa')+-- inO2 h (O gfa) = inO (h gfa)+ -- | Apply a ternary function within the 'O' constructor. inO3 :: (g (f a) -> g' (f' a') -> g'' (f'' a'') -> g''' (f''' a''')) -> ((g :. f) a -> (g' :. f') a' -> (g'' :. f'') a'' -> (g''' :. f''') a''')-inO3 h (O gfa) = inO2 (h gfa)+inO3 = (inO2 .).(.unO)+-- inO3 h (O gfa) = inO2 (h gfa) -- | Used for the @Functor :. Functor@ instance of 'Functor' fmapFF :: ( Functor g, Functor f) => (a -> b) -> (g :. f) a -> (g :. f) b-fmapFF h = inO $ fmap (fmap h)+fmapFF = inO.fmap.fmap -- | Used for the @Cofunctor :. Cofunctor@ instance of 'Functor' fmapCC :: (Cofunctor g, Cofunctor f) => (a -> b) -> (g :. f) a -> (g :. f) b-fmapCC h = inO $ cofmap (cofmap h)+fmapCC = inO.cofmap.cofmap -- | Used for the @Functor :. Cofunctor@ instance of 'Functor' cofmapFC :: (Functor g, Cofunctor f) => (b -> a) -> (g :. f) a -> (g :. f) b-cofmapFC h (O gf) = O (fmap (cofmap h) gf)+cofmapFC = inO.fmap.cofmap +-- cofmapFC h (O gf) = O (fmap (cofmap h) gf)+ -- | Used for the @Cofunctor :. Functor@ instance of 'Functor' cofmapCF :: (Cofunctor g, Functor f) => (b -> a) -> (g :. f) a -> (g :. f) b cofmapCF h (O gf) = O (cofmap (fmap h) gf) instance (Applicative g, Applicative f) => Applicative (g :. f) where pure = O . pure . pure- (<*>) = inO2 (liftA2 (<*>))+ (<*>) = (inO2.liftA2) (<*>) -- Possible Alternative instances:
wikipage.tw view
@@ -32,7 +32,7 @@ === Pair- & function-like types === -The <hask>Data.Pair</hask> and <hask>Data.Lambda</hask> patterns emerged while working on [[DeepArrow]] and [[Eros]]. <hask>Data.Pair</hask> generalizes <hask>zip</hask> and <hask>unzip</hask> from <hask>[]</hask> to other functors. It also provides variants of type <hask>f a -> f (a,b)</hask> and <hask>f a -> f (a,b)</hask>. <hask>Data.Lambda</hask> is similar with classes for lambda-like constructions.+The <hask>Data.Zip</hask> and <hask>Data.Lambda</hask> patterns emerged while working on [[DeepArrow]] and [[Eros]]. <hask>Data.Zip</hask> generalizes <hask>zip</hask> and <hask>unzip</hask> from <hask>[]</hask> to other functors. It also provides variants of type <hask>f a -> f (a,b)</hask> and <hask>f a -> f (a,b)</hask>. <hask>Data.Lambda</hask> is similar with classes for lambda-like constructions. For example uses of <hask>Pair</hask> and <hask>Lambda</hask>, see [[TV]] and [[Eros]].