+ga_swap_second f =
+ ga_swap >>> ga_first f >>> ga_swap
+ -- implementation of ga_second for GArrowSwap
+ -- See also
+ -- http://haskell.org/haskellwiki/Class_system_extension_proposal
+ -- "Allowing superclass methods to be overridden in derived classes";
+ -- if we had this we could do a better job here
+
+
+
+------------------------------------------------------------------------
+-- Products, Coproducts, etc
+
+
+class (GArrowDrop g (<*>) u,
+ GArrowCopy g (<*>) u) =>
+ GArrowProd g (<*>) u
+
+class GArrow g (<+>) u =>
+ GArrowSum g (<+>) u where
+ ga_merge :: g (x<+>x) x
+ ga_never :: g u x
+
+ga_inl :: GArrowSum g (<+>) u => g x (x<+>y)
+ga_inl = ga_uncancelr >>> ga_second ga_never
+
+ga_inr :: GArrowSum g (<+>) u => g x (y<+>x)
+ga_inr = ga_uncancell >>> ga_first ga_never
+
+
+------------------------------------------------------------------------
+-- Loop
+
+class GArrow g (**) u => GArrowLoop g (**) u where
+ ga_loopl :: g (x**z) (y**z) -> g x y
+ ga_loopr :: g (z**x) (z**y) -> g x y
+
+
+------------------------------------------------------------------------
+-- Literal. Note that ga_literal should never appear in (unflattened)
+-- Haskell programs, though the user may wish to write implementations
+-- of this function (I haven't yet found a way to enforce this
+-- restriction using exports)
+
+class GArrow g (**) u => GArrowLiteral g (**) u t r where
+ ga_literal :: t -> g u r
+
+
+
+
+------------------------------------------------------------------------
+-- Constant and Run, which are dual to each other
+
+class GArrow g (**) u => GArrowEval g (**) u r t where
+ ga_eval :: g u r -> t
+
+class GArrow g (**) u => GArrowConstant g (**) u t r where
+ ga_constant :: t -> g u r
+
+
+
+------------------------------------------------------------------------
+-- Reify and Reflect, which are "curried" versions of eval/const
+
+-- If you have this for R the identity map on types, you're basically
+-- a Control.Arrow; you can also define essentially all the other
+-- methods of GArrow, GArrowDrop, GArrowCopy, etc in terms of this.
+class GArrow g (**) u => GArrowReify g (**) u x y r q where
+ ga_reify :: (x -> y) -> g r q
+
+class GArrow g (**) u => GArrowReflect g (**) u r q x y where
+ ga_reflect :: g r q -> (x -> y)
+
+
+
+
+------------------------------------------------------------------------
+-- The Kappa adjunction
+--
+-- See Hasegawa, Decomposing Typed Lambda Calculus into a Couple of
+-- Categorical Programming Languages) section 3, rule $(\times L)$
+
+class GArrow g (**) u => GArrowKappa g (**) u where
+ ga_kappa :: (g u x -> g u y) -> g x y
+
+
+
+
+
+------------------------------------------------------------------------
+-- Apply and Curry
+
+class GArrow g (**) u => GArrowApply g (**) u (~>) where
+ ga_applyl :: g (x**(x~>y) ) y
+ ga_applyr :: g ( (x~>y)**x) y
+
+class GArrow g (**) u => GArrowCurry g (**) u (~>) where
+ ga_curryl :: g (x**y) z -> g x (y~>z)
+ ga_curryr :: g (x**y) z -> g y (x~>z)
+
+
+
+
+------------------------------------------------------------------------
+-- Commonly Implemented Collections of Classes
+
+--
+-- The simply typed KAPPA calculus; see Hasegawa, __Decomposing Typed
+-- Lambda Calculus into a Couple of Categorical Programming
+-- Languages__, http://dx.doi.org/10.1007/3-540-60164-3_28
+--
+class (GArrowDrop g (**) u,
+ GArrowCopy g (**) u,
+ GArrowSwap g (**) u) =>
+ GArrowSTKC g (**) u
+
+-- The simply typed LAMBDA calculus
+class (GArrowSTKC g (**) u,
+ GArrowCurry g (**) u (~>),
+ GArrowApply g (**) u (~>)) =>
+ GArrowSTLC g (**) u (~>)
+
+-- Programming Language for Computable Functions (w/o integers and booleans)
+class (GArrowSTLC g (**) u (~>),
+ GArrowLoop g (**) u) =>
+ GArrowPCF g (**) u (~>)
+
+