#ifndef MIN_VERSION_GLASGOW_HASKELL
#define MIN_VERSION_GLASGOW_HASKELL(a,b,c,d) 0
#endif
  
#if MIN_VERSION_GLASGOW_HASKELL(7,10,0,0)
#else
#endif
module Data.ALaCarte where
data (f :+: g) a b
    = Inl (f a b)
    | Inr (g a b)
#if  __GLASGOW_HASKELL__>=708
  deriving (Functor)
#endif
infixr :+:
class f :<: g
  where
    inj :: f a b -> g a b
    prj :: g a b -> Maybe (f a b)
instance  (f :<: f)
  where
    inj = id
    prj = Just
instance  (f :<: (f :+: g))
  where
    inj = Inl
    prj (Inl f) = Just f
    prj _       = Nothing
instance  (f :<: h) => (f :<: (g :+: h))
  where
    inj = Inr . inj
    prj (Inr h) = prj h
    prj _       = Nothing
class HFunctor h
  where
    
    hfmap :: (forall b . m b -> n b) -> h m a -> h n a
instance (HFunctor h1, HFunctor h2) => HFunctor (h1 :+: h2)
  where
    hfmap f (Inl i) = Inl (hfmap f i)
    hfmap f (Inr i) = Inr (hfmap f i)