-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | standard type constructor class hierarchy, only with methods of rank 2 types -- -- A mirror image of the standard type constructor class hierarchy rooted -- in Functor, except with methods of rank 2 types and class -- instances of kind (k->*)->*. The classes enable generic -- handling of heterogenously typed data structures and other neat -- tricks. @package rank2classes @version 1.5 -- | Import this module qualified, like this: -- --
-- import qualified Rank2 ---- -- This will bring into scope the standard classes Functor, -- Applicative, Foldable, and Traversable, but with -- a Rank2. prefix and a twist that their methods operate on a -- heterogenous collection. The same property is shared by the less -- standard classes Apply, Distributive, and -- Logistic. module Rank2 -- | Equivalent of Functor for rank 2 data types, satisfying the -- usual functor laws -- --
-- id <$> g == g -- (p . q) <$> g == p <$> (q <$> g) --class Functor g (<$>) :: Functor g => (forall a. p a -> q a) -> g p -> g q infixl 4 <$> -- | Subclass of Functor halfway to Applicative, satisfying -- --
-- (.) <$> u <*> v <*> w == u <*> (v <*> w) --class Functor g => Apply g -- | Equivalent of <*> for rank 2 data types (<*>) :: Apply g => g (p ~> q) -> g p -> g q -- | Equivalent of liftA2 for rank 2 data types liftA2 :: Apply g => (forall a. p a -> q a -> r a) -> g p -> g q -> g r -- | Equivalent of liftA3 for rank 2 data types liftA3 :: Apply g => (forall a. p a -> q a -> r a -> s a) -> g p -> g q -> g r -> g s infixl 4 <*> -- | Equivalent of Applicative for rank 2 data types class Apply g => Applicative g pure :: Applicative g => (forall a. f a) -> g f -- | Equivalent of Foldable for rank 2 data types class Foldable g foldMap :: (Foldable g, Monoid m) => (forall a. p a -> m) -> g p -> m -- | Equivalent of Traversable for rank 2 data types class (Functor g, Foldable g) => Traversable g traverse :: (Traversable g, Applicative m) => (forall a. p a -> m (q a)) -> g p -> m (g q) sequence :: (Traversable g, Applicative m) => g (Compose m p) -> m (g p) -- | Equivalent of Distributive for rank 2 data types class DistributiveTraversable g => Distributive g collect :: (Distributive g, Functor p) => (a -> g q) -> p a -> g (Compose p q) distribute :: (Distributive g, Functor p) => p (g q) -> g (Compose p q) -- | Dual of traverse, equivalent of cotraverse for rank 2 -- data types cotraverse :: (Distributive g, Functor m) => (forall a. m (p a) -> q a) -> m (g p) -> g q -- | A weaker Distributive that requires Traversable to use, -- not just a Functor. class Functor g => DistributiveTraversable (g :: (k -> Type) -> Type) collectTraversable :: (DistributiveTraversable g, Traversable f1) => (a -> g f2) -> f1 a -> g (Compose f1 f2) distributeTraversable :: (DistributiveTraversable g, Traversable f1) => f1 (g f2) -> g (Compose f1 f2) cotraverseTraversable :: (DistributiveTraversable g, Traversable f1) => (forall x. f1 (f2 x) -> f x) -> f1 (g f2) -> g f cotraverseTraversable :: (DistributiveTraversable g, Traversable m, Distributive g) => (forall a. m (p a) -> q a) -> m (g p) -> g q -- | Equivalent of Logistic for rank 2 data types class Functor g => Logistic g deliver :: (Logistic g, Contravariant p) => p (g q -> g q) -> g (Compose p (q ~> q)) -- | A variant of distribute convenient with Monad instances distributeJoin :: (Distributive g, Monad f) => f (g f) -> g f -- | Equivalent of Compose for rank 2 data types newtype Compose g p q Compose :: g (Compose p q) -> Compose g p q [getCompose] :: Compose g p q -> g (Compose p q) -- | A rank-2 equivalent of (), a zero-element tuple data Empty f Empty :: Empty f -- | A rank-2 tuple of only one element newtype Only a f Only :: f a -> Only a f [fromOnly] :: Only a f -> f a -- | A nested parametric type represented as a rank-2 type newtype Flip g a f Flip :: g (f a) -> Flip g a f [unFlip] :: Flip g a f -> g (f a) -- | Equivalent of Identity for rank 2 data types newtype Identity g f Identity :: g f -> Identity g f [runIdentity] :: Identity g f -> g f -- | Lifted product of functors. data Product (f :: k -> Type) (g :: k -> Type) (a :: k) Pair :: f a -> g a -> Product (f :: k -> Type) (g :: k -> Type) (a :: k) -- | Lifted sum of functors. data Sum (f :: k -> Type) (g :: k -> Type) (a :: k) InL :: f a -> Sum (f :: k -> Type) (g :: k -> Type) (a :: k) InR :: g a -> Sum (f :: k -> Type) (g :: k -> Type) (a :: k) -- | Wrapper for functions that map the argument constructor type newtype Arrow p q a Arrow :: (p a -> q a) -> Arrow p q a [apply] :: Arrow p q a -> p a -> q a type (~>) = Arrow infixr 0 ~> ($) :: Arrow p q a -> p a -> q a infixr 0 $ -- | Helper function for accessing the first field of a Pair fst :: Product g h p -> g p -- | Helper function for accessing the second field of a Pair snd :: Product g h p -> h p -- | Alphabetical synonym for <*> ap :: Apply g => g (p ~> q) -> g p -> g q -- | Alphabetical synonym for <$> fmap :: Functor g => (forall a. p a -> q a) -> g p -> g q liftA4 :: Apply g => (forall a. p a -> q a -> r a -> s a -> t a) -> g p -> g q -> g r -> g s -> g t liftA5 :: Apply g => (forall a. p a -> q a -> r a -> s a -> t a -> u a) -> g p -> g q -> g r -> g s -> g t -> g u -- | Like fmap, but traverses over its argument fmapTraverse :: (DistributiveTraversable g, Traversable f) => (forall a. f (t a) -> u a) -> f (g t) -> g u -- | Like liftA2, but traverses over its first argument liftA2Traverse1 :: (Apply g, DistributiveTraversable g, Traversable f) => (forall a. f (t a) -> u a -> v a) -> f (g t) -> g u -> g v -- | Like liftA2, but traverses over its second argument liftA2Traverse2 :: (Apply g, DistributiveTraversable g, Traversable f) => (forall a. t a -> f (u a) -> v a) -> g t -> f (g u) -> g v -- | Like liftA2, but traverses over both its arguments liftA2TraverseBoth :: forall f1 f2 g t u v. (Apply g, DistributiveTraversable g, Traversable f1, Traversable f2) => (forall a. f1 (t a) -> f2 (u a) -> v a) -> f1 (g t) -> f2 (g u) -> g v -- | Synonym for cotraverse -- | Deprecated: Use cotraverse instead. distributeWith :: (Distributive g, Functor f) => (forall i. f (a i) -> b i) -> f (g a) -> g b -- | Synonym for cotraverseTraversable -- | Deprecated: Use cotraverseTraversable instead. distributeWithTraversable :: (DistributiveTraversable g, Traversable m) => (forall a. m (p a) -> q a) -> m (g p) -> g q -- | Enumerate getters for each element getters :: Distributive g => g (Compose ((->) (g f)) f) -- | Enumerate setters for each element setters :: Logistic g => g ((f ~> f) ~> Const (g f -> g f)) instance forall k (f :: k). GHC.Show.Show (Rank2.Empty f) instance forall k (f :: k). GHC.Classes.Ord (Rank2.Empty f) instance forall k (f :: k). GHC.Classes.Eq (Rank2.Empty f) instance forall k (a :: k) (f :: k -> *). GHC.Show.Show (f a) => GHC.Show.Show (Rank2.Only a f) instance forall k (a :: k) (f :: k -> *). GHC.Classes.Ord (f a) => GHC.Classes.Ord (Rank2.Only a f) instance forall k (a :: k) (f :: k -> *). GHC.Classes.Eq (f a) => GHC.Classes.Eq (Rank2.Only a f) instance forall k (g :: k -> *) (f :: k). GHC.Show.Show (g f) => GHC.Show.Show (Rank2.Identity g f) instance forall k (g :: k -> *) (f :: k). GHC.Classes.Ord (g f) => GHC.Classes.Ord (Rank2.Identity g f) instance forall k (g :: k -> *) (f :: k). GHC.Classes.Eq (g f) => GHC.Classes.Eq (Rank2.Identity g f) instance forall k1 (g :: k1 -> *) k2 (a :: k2) (f :: k2 -> k1). GHC.Show.Show (g (f a)) => GHC.Show.Show (Rank2.Flip g a f) instance forall k1 (g :: k1 -> *) k2 (a :: k2) (f :: k2 -> k1). GHC.Classes.Ord (g (f a)) => GHC.Classes.Ord (Rank2.Flip g a f) instance forall k1 (g :: k1 -> *) k2 (a :: k2) (f :: k2 -> k1). GHC.Classes.Eq (g (f a)) => GHC.Classes.Eq (Rank2.Flip g a f) instance forall k1 k (g :: (k1 -> *) -> *) (p :: k -> *) (q :: k1 -> k). GHC.Classes.Eq (g (Data.Functor.Compose.Compose p q)) => GHC.Classes.Eq (Rank2.Compose g p q) instance forall k1 k (g :: (k1 -> *) -> *) (p :: k -> *) (q :: k1 -> k). GHC.Classes.Ord (g (Data.Functor.Compose.Compose p q)) => GHC.Classes.Ord (Rank2.Compose g p q) instance forall k1 k (g :: (k1 -> *) -> *) (p :: k -> *) (q :: k1 -> k). GHC.Show.Show (g (Data.Functor.Compose.Compose p q)) => GHC.Show.Show (Rank2.Compose g p q) instance forall k1 k2 (g :: k1 -> *) (f :: k2 -> k1) (a :: k2). GHC.Base.Semigroup (g (f a)) => GHC.Base.Semigroup (Rank2.Flip g a f) instance forall k1 k2 (g :: k1 -> *) (f :: k2 -> k1) (a :: k2). GHC.Base.Monoid (g (f a)) => GHC.Base.Monoid (Rank2.Flip g a f) instance forall k (g :: * -> *) (a :: k). GHC.Base.Functor g => Rank2.Functor (Rank2.Flip g a) instance forall k (g :: * -> *) (a :: k). GHC.Base.Applicative g => Rank2.Apply (Rank2.Flip g a) instance forall k (g :: * -> *) (a :: k). GHC.Base.Applicative g => Rank2.Applicative (Rank2.Flip g a) instance forall k (g :: * -> *) (a :: k). Data.Foldable.Foldable g => Rank2.Foldable (Rank2.Flip g a) instance forall k (g :: * -> *) (a :: k). Data.Traversable.Traversable g => Rank2.Traversable (Rank2.Flip g a) instance forall k (g :: (k -> *) -> *) (p :: * -> *). (Rank2.Functor g, GHC.Base.Functor p) => Rank2.Functor (Rank2.Compose g p) instance forall k (g :: (k -> *) -> *) (p :: * -> *). (Rank2.Foldable g, Data.Foldable.Foldable p) => Rank2.Foldable (Rank2.Compose g p) instance forall k (g :: (k -> *) -> *) (p :: * -> *). (Rank2.Traversable g, Data.Traversable.Traversable p) => Rank2.Traversable (Rank2.Compose g p) instance forall k (g :: (k -> *) -> *) (p :: * -> *). (Rank2.Apply g, GHC.Base.Applicative p) => Rank2.Apply (Rank2.Compose g p) instance forall k (g :: (k -> *) -> *) (p :: * -> *). (Rank2.Applicative g, GHC.Base.Applicative p) => Rank2.Applicative (Rank2.Compose g p) instance forall k (g :: (k -> *) -> *) (p :: * -> *). (Rank2.DistributiveTraversable g, Data.Distributive.Distributive p) => Rank2.DistributiveTraversable (Rank2.Compose g p) instance forall k1 (g :: (k1 -> *) -> *) (p :: * -> *). (Rank2.Distributive g, Data.Distributive.Distributive p) => Rank2.Distributive (Rank2.Compose g p) instance forall k1 (g :: (k1 -> *) -> *) (p :: * -> *). (Rank2.Logistic g, Data.Functor.Logistic.Logistic p) => Rank2.Logistic (Rank2.Compose g p) instance forall k (g :: (k -> *) -> *). Rank2.Functor g => Rank2.Functor (Rank2.Identity g) instance forall k (g :: (k -> *) -> *). Rank2.Foldable g => Rank2.Foldable (Rank2.Identity g) instance forall k (g :: (k -> *) -> *). Rank2.Traversable g => Rank2.Traversable (Rank2.Identity g) instance forall k (g :: (k -> *) -> *). Rank2.Apply g => Rank2.Apply (Rank2.Identity g) instance forall k (g :: (k -> *) -> *). Rank2.Applicative g => Rank2.Applicative (Rank2.Identity g) instance forall k (g :: (k -> *) -> *). Rank2.DistributiveTraversable g => Rank2.DistributiveTraversable (Rank2.Identity g) instance forall k1 (g :: (k1 -> *) -> *). Rank2.Distributive g => Rank2.Distributive (Rank2.Identity g) instance forall k1 (g :: (k1 -> *) -> *). Rank2.Logistic g => Rank2.Logistic (Rank2.Identity g) instance forall k (a :: k). Rank2.Functor (Rank2.Only a) instance forall k (x :: k). Rank2.Foldable (Rank2.Only x) instance forall k (x :: k). Rank2.Traversable (Rank2.Only x) instance forall k (x :: k). Rank2.Apply (Rank2.Only x) instance forall k (x :: k). Rank2.Applicative (Rank2.Only x) instance forall k (x :: k). Rank2.DistributiveTraversable (Rank2.Only x) instance forall k1 (x :: k1). Rank2.Distributive (Rank2.Only x) instance forall k1 (x :: k1). Rank2.Logistic (Rank2.Only x) instance Rank2.Functor Rank2.Empty instance Rank2.Foldable Rank2.Empty instance Rank2.Traversable Rank2.Empty instance Rank2.Apply Rank2.Empty instance Rank2.Applicative Rank2.Empty instance Rank2.DistributiveTraversable Rank2.Empty instance Rank2.Distributive Rank2.Empty instance Rank2.Logistic Rank2.Empty instance Rank2.Logistic Data.Proxy.Proxy instance forall k1 (g :: (k1 -> *) -> *) (h :: (k1 -> *) -> *). (Rank2.Logistic g, Rank2.Logistic h) => Rank2.Logistic (Data.Functor.Product.Product g h) instance forall k1 (f :: (k1 -> *) -> *) i (c :: GHC.Generics.Meta). Rank2.Logistic f => Rank2.Logistic (GHC.Generics.M1 i c f) instance forall k1 (f :: (k1 -> *) -> *). Rank2.Logistic f => Rank2.Logistic (GHC.Generics.Rec1 f) instance forall k1 (f :: (k1 -> *) -> *) (g :: (k1 -> *) -> *). (Rank2.Logistic f, Rank2.Logistic g) => Rank2.Logistic (f GHC.Generics.:*: g) instance Rank2.DistributiveTraversable Data.Proxy.Proxy instance forall k (g :: (k -> *) -> *) (h :: (k -> *) -> *). (Rank2.DistributiveTraversable g, Rank2.DistributiveTraversable h) => Rank2.DistributiveTraversable (Data.Functor.Product.Product g h) instance forall k (f :: (k -> *) -> *) i (c :: GHC.Generics.Meta). Rank2.DistributiveTraversable f => Rank2.DistributiveTraversable (GHC.Generics.M1 i c f) instance forall k (f :: (k -> *) -> *). Rank2.DistributiveTraversable f => Rank2.DistributiveTraversable (GHC.Generics.Rec1 f) instance forall k (f :: (k -> *) -> *) (g :: (k -> *) -> *). (Rank2.DistributiveTraversable f, Rank2.DistributiveTraversable g) => Rank2.DistributiveTraversable (f GHC.Generics.:*: g) instance Rank2.Distributive Data.Proxy.Proxy instance GHC.Base.Monoid x => Rank2.DistributiveTraversable (Data.Functor.Const.Const x) instance forall k1 (g :: (k1 -> *) -> *) (h :: (k1 -> *) -> *). (Rank2.Distributive g, Rank2.Distributive h) => Rank2.Distributive (Data.Functor.Product.Product g h) instance GHC.Base.Monoid c => Rank2.DistributiveTraversable (GHC.Generics.K1 i c) instance forall k1 (f :: (k1 -> *) -> *) i (c :: GHC.Generics.Meta). Rank2.Distributive f => Rank2.Distributive (GHC.Generics.M1 i c f) instance forall k1 (f :: (k1 -> *) -> *). Rank2.Distributive f => Rank2.Distributive (GHC.Generics.Rec1 f) instance forall k1 (f :: (k1 -> *) -> *) (g :: (k1 -> *) -> *). (Rank2.Distributive f, Rank2.Distributive g) => Rank2.Distributive (f GHC.Generics.:*: g) instance Rank2.Applicative Data.Proxy.Proxy instance (GHC.Base.Semigroup x, GHC.Base.Monoid x) => Rank2.Applicative (Data.Functor.Const.Const x) instance forall k (g :: (k -> *) -> *) (h :: (k -> *) -> *). (Rank2.Applicative g, Rank2.Applicative h) => Rank2.Applicative (Data.Functor.Product.Product g h) instance (GHC.Base.Semigroup c, GHC.Base.Monoid c) => Rank2.Applicative (GHC.Generics.K1 i c) instance forall k (f :: (k -> *) -> *) i (c :: GHC.Generics.Meta). Rank2.Applicative f => Rank2.Applicative (GHC.Generics.M1 i c f) instance forall k (f :: (k -> *) -> *). Rank2.Applicative f => Rank2.Applicative (GHC.Generics.Rec1 f) instance forall k (f :: (k -> *) -> *) (g :: (k -> *) -> *). (Rank2.Applicative f, Rank2.Applicative g) => Rank2.Applicative (f GHC.Generics.:*: g) instance Rank2.Apply Data.Proxy.Proxy instance GHC.Base.Semigroup x => Rank2.Apply (Data.Functor.Const.Const x) instance forall k (g :: (k -> *) -> *) (h :: (k -> *) -> *). (Rank2.Apply g, Rank2.Apply h) => Rank2.Apply (Data.Functor.Product.Product g h) instance Rank2.Apply GHC.Generics.V1 instance Rank2.Apply GHC.Generics.U1 instance GHC.Base.Semigroup c => Rank2.Apply (GHC.Generics.K1 i c) instance forall k (f :: (k -> *) -> *) i (c :: GHC.Generics.Meta). Rank2.Apply f => Rank2.Apply (GHC.Generics.M1 i c f) instance forall k (f :: (k -> *) -> *). Rank2.Apply f => Rank2.Apply (GHC.Generics.Rec1 f) instance forall k (f :: (k -> *) -> *) (g :: (k -> *) -> *). (Rank2.Apply f, Rank2.Apply g) => Rank2.Apply (f GHC.Generics.:*: g) instance Rank2.Traversable Data.Proxy.Proxy instance Rank2.Traversable (Data.Functor.Const.Const x) instance forall k (g :: (k -> *) -> *) (h :: (k -> *) -> *). (Rank2.Traversable g, Rank2.Traversable h) => Rank2.Traversable (Data.Functor.Product.Product g h) instance forall k (g :: (k -> *) -> *) (h :: (k -> *) -> *). (Rank2.Traversable g, Rank2.Traversable h) => Rank2.Traversable (Data.Functor.Sum.Sum g h) instance Rank2.Traversable GHC.Generics.V1 instance Rank2.Traversable GHC.Generics.U1 instance Rank2.Traversable (GHC.Generics.K1 i c) instance forall k (f :: (k -> *) -> *) i (c :: GHC.Generics.Meta). Rank2.Traversable f => Rank2.Traversable (GHC.Generics.M1 i c f) instance forall k (f :: (k -> *) -> *). Rank2.Traversable f => Rank2.Traversable (GHC.Generics.Rec1 f) instance forall k (f :: (k -> *) -> *) (g :: (k -> *) -> *). (Rank2.Traversable f, Rank2.Traversable g) => Rank2.Traversable (f GHC.Generics.:+: g) instance forall k (f :: (k -> *) -> *) (g :: (k -> *) -> *). (Rank2.Traversable f, Rank2.Traversable g) => Rank2.Traversable (f GHC.Generics.:*: g) instance Rank2.Foldable Data.Proxy.Proxy instance Rank2.Foldable (Data.Functor.Const.Const x) instance forall k (g :: (k -> *) -> *) (h :: (k -> *) -> *). (Rank2.Foldable g, Rank2.Foldable h) => Rank2.Foldable (Data.Functor.Product.Product g h) instance forall k (g :: (k -> *) -> *) (h :: (k -> *) -> *). (Rank2.Foldable g, Rank2.Foldable h) => Rank2.Foldable (Data.Functor.Sum.Sum g h) instance Rank2.Foldable GHC.Generics.V1 instance Rank2.Foldable GHC.Generics.U1 instance Rank2.Foldable (GHC.Generics.K1 i c) instance forall k (f :: (k -> *) -> *) i (c :: GHC.Generics.Meta). Rank2.Foldable f => Rank2.Foldable (GHC.Generics.M1 i c f) instance forall k (f :: (k -> *) -> *). Rank2.Foldable f => Rank2.Foldable (GHC.Generics.Rec1 f) instance forall k (f :: (k -> *) -> *) (g :: (k -> *) -> *). (Rank2.Foldable f, Rank2.Foldable g) => Rank2.Foldable (f GHC.Generics.:+: g) instance forall k (f :: (k -> *) -> *) (g :: (k -> *) -> *). (Rank2.Foldable f, Rank2.Foldable g) => Rank2.Foldable (f GHC.Generics.:*: g) instance Rank2.Functor Data.Proxy.Proxy instance Rank2.Functor (Data.Functor.Const.Const a) instance forall k (g :: (k -> *) -> *) (h :: (k -> *) -> *). (Rank2.Functor g, Rank2.Functor h) => Rank2.Functor (Data.Functor.Product.Product g h) instance forall k (g :: (k -> *) -> *) (h :: (k -> *) -> *). (Rank2.Functor g, Rank2.Functor h) => Rank2.Functor (Data.Functor.Sum.Sum g h) instance Rank2.Functor GHC.Generics.V1 instance Rank2.Functor GHC.Generics.U1 instance Rank2.Functor (GHC.Generics.K1 i c) instance forall k (f :: (k -> *) -> *) i (c :: GHC.Generics.Meta). Rank2.Functor f => Rank2.Functor (GHC.Generics.M1 i c f) instance forall k (f :: (k -> *) -> *). Rank2.Functor f => Rank2.Functor (GHC.Generics.Rec1 f) instance forall k (f :: (k -> *) -> *) (g :: (k -> *) -> *). (Rank2.Functor f, Rank2.Functor g) => Rank2.Functor (f GHC.Generics.:+: g) instance forall k (f :: (k -> *) -> *) (g :: (k -> *) -> *). (Rank2.Functor f, Rank2.Functor g) => Rank2.Functor (f GHC.Generics.:*: g) -- | This module exports the templates for automatic instance deriving of -- Rank2 type classes. The most common way to use it would be -- --
-- import qualified Rank2.TH -- data MyDataType f = ... -- $(Rank2.TH.deriveAll ''MyDataType) ---- -- or, if you're picky, you can invoke only deriveFunctor and -- whichever other instances you need instead. module Rank2.TH deriveAll :: Name -> Q [Dec] deriveFunctor :: Name -> Q [Dec] deriveApply :: Name -> Q [Dec] -- | This function always succeeds, but the methods it generates may be -- partial. Use with care. unsafeDeriveApply :: Name -> Q [Dec] deriveApplicative :: Name -> Q [Dec] deriveFoldable :: Name -> Q [Dec] deriveTraversable :: Name -> Q [Dec] deriveDistributive :: Name -> Q [Dec] deriveDistributiveTraversable :: Name -> Q [Dec] deriveLogistic :: Name -> Q [Dec] instance GHC.Show.Show Rank2.TH.Deriving