{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE UndecidableInstances #-}
#if __GLASGOW_HASKELL__ >= 706
{-# LANGUAGE PolyKinds #-}
#endif
{-# OPTIONS_GHC -fno-warn-orphans #-}
module TextShow.Data.Bifunctor () where
import Data.Bifunctor.Biff (Biff)
import Data.Bifunctor.Clown (Clown)
import Data.Bifunctor.Fix (Fix(..))
import Data.Bifunctor.Flip (Flip)
import Data.Bifunctor.Join (Join(..))
import Data.Bifunctor.Joker (Joker)
import Data.Bifunctor.Product (Product)
import Data.Bifunctor.Sum (Sum)
import Data.Bifunctor.Tannen (Tannen)
import Data.Bifunctor.Wrapped (WrappedBifunctor)
import TextShow (TextShow(..), TextShow1(..), TextShow2(..))
import TextShow.TH (deriveTextShow2, makeShowbPrec, makeLiftShowbPrec)
instance TextShow (p (f a) (g b)) => TextShow (Biff p f g a b) where
showbPrec = $(makeShowbPrec ''Biff)
instance (TextShow2 p, TextShow1 f, TextShow1 g, TextShow a) => TextShow1 (Biff p f g a) where
liftShowbPrec = liftShowbPrec2 showbPrec showbList
$(deriveTextShow2 ''Biff)
instance TextShow (f a) => TextShow (Clown f a b) where
showbPrec = $(makeShowbPrec ''Clown)
instance TextShow (f a) => TextShow1 (Clown f a) where
liftShowbPrec = $(makeLiftShowbPrec ''Clown)
$(deriveTextShow2 ''Clown)
instance TextShow (p (Fix p a) a) => TextShow (Fix p a) where
showbPrec = $(makeShowbPrec ''Fix)
instance TextShow2 p => TextShow1 (Fix p) where
liftShowbPrec sp sl p =
liftShowbPrec2 (liftShowbPrec sp sl) (liftShowbList sp sl) sp sl p . out
instance TextShow (p b a) => TextShow (Flip p a b) where
showbPrec = $(makeShowbPrec ''Flip)
instance (TextShow2 p, TextShow a) => TextShow1 (Flip p a) where
liftShowbPrec = liftShowbPrec2 showbPrec showbList
$(deriveTextShow2 ''Flip)
instance TextShow (p a a) => TextShow (Join p a) where
showbPrec = $(makeShowbPrec ''Join)
instance TextShow2 p => TextShow1 (Join p) where
liftShowbPrec sp sl p = liftShowbPrec2 sp sl sp sl p . runJoin
instance TextShow (g b) => TextShow (Joker g a b) where
showbPrec = $(makeShowbPrec ''Joker)
instance TextShow1 g => TextShow1 (Joker g a) where
liftShowbPrec = $(makeLiftShowbPrec ''Joker)
$(deriveTextShow2 ''Joker)
instance (TextShow (f a b), TextShow (g a b)) => TextShow (Product f g a b) where
showbPrec = $(makeShowbPrec ''Product)
instance (TextShow2 f, TextShow2 g, TextShow a) => TextShow1 (Product f g a) where
liftShowbPrec = liftShowbPrec2 showbPrec showbList
$(deriveTextShow2 ''Product)
instance (TextShow (f a b), TextShow (g a b)) => TextShow (Sum f g a b) where
showbPrec = $(makeShowbPrec ''Sum)
instance (TextShow2 f, TextShow2 g, TextShow a) => TextShow1 (Sum f g a) where
liftShowbPrec = liftShowbPrec2 showbPrec showbList
$(deriveTextShow2 ''Sum)
instance TextShow (f (p a b)) => TextShow (Tannen f p a b) where
showbPrec = $(makeShowbPrec ''Tannen)
instance (TextShow1 f, TextShow2 p, TextShow a) => TextShow1 (Tannen f p a) where
liftShowbPrec = liftShowbPrec2 showbPrec showbList
$(deriveTextShow2 ''Tannen)
instance TextShow (p a b) => TextShow (WrappedBifunctor p a b) where
showbPrec = $(makeShowbPrec ''WrappedBifunctor)
instance (TextShow2 p, TextShow a) => TextShow1 (WrappedBifunctor p a) where
liftShowbPrec = liftShowbPrec2 showbPrec showbList
$(deriveTextShow2 ''WrappedBifunctor)