{-# LANGUAGE CPP, DeriveDataTypeable, DeriveTraversable, DeriveFoldable,
       DeriveGeneric #-}
module Data.Functor.Of (Of(..)) where
import Data.Monoid (Monoid (..))
import Data.Semigroup (Semigroup (..))
import Control.Applicative
import Data.Traversable (Traversable)
import Data.Foldable (Foldable)
import Data.Bifunctor
import Data.Data
#if MIN_VERSION_base(4,9,0)
import Data.Functor.Classes
import Data.Foldable (Foldable)
import Data.Traversable (Traversable)
#endif
#if MIN_VERSION_base(4,10,0)
import Data.Bifoldable (Bifoldable, bifoldMap)
import Data.Bitraversable (Bitraversable, bitraverse)
#endif
import GHC.Generics (Generic, Generic1)

-- | A left-strict pair; the base functor for streams of individual elements.
data Of a b = !a :> b
    deriving (Of a b -> DataType
Of a b -> Constr
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall {a} {b}. (Data a, Data b) => Typeable (Of a b)
forall a b. (Data a, Data b) => Of a b -> DataType
forall a b. (Data a, Data b) => Of a b -> Constr
forall a b.
(Data a, Data b) =>
(forall b. Data b => b -> b) -> Of a b -> Of a b
forall a b u.
(Data a, Data b) =>
Int -> (forall d. Data d => d -> u) -> Of a b -> u
forall a b u.
(Data a, Data b) =>
(forall d. Data d => d -> u) -> Of a b -> [u]
forall a b r r'.
(Data a, Data b) =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Of a b -> r
forall a b r r'.
(Data a, Data b) =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Of a b -> r
forall a b (m :: * -> *).
(Data a, Data b, Monad m) =>
(forall d. Data d => d -> m d) -> Of a b -> m (Of a b)
forall a b (m :: * -> *).
(Data a, Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Of a b -> m (Of a b)
forall a b (c :: * -> *).
(Data a, Data b) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Of a b)
forall a b (c :: * -> *).
(Data a, Data b) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Of a b -> c (Of a b)
forall a b (t :: * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Of a b))
forall a b (t :: * -> * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Of a b))
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Of a b)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Of a b -> c (Of a b)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Of a b))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Of a b -> m (Of a b)
$cgmapMo :: forall a b (m :: * -> *).
(Data a, Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Of a b -> m (Of a b)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Of a b -> m (Of a b)
$cgmapMp :: forall a b (m :: * -> *).
(Data a, Data b, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Of a b -> m (Of a b)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Of a b -> m (Of a b)
$cgmapM :: forall a b (m :: * -> *).
(Data a, Data b, Monad m) =>
(forall d. Data d => d -> m d) -> Of a b -> m (Of a b)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Of a b -> u
$cgmapQi :: forall a b u.
(Data a, Data b) =>
Int -> (forall d. Data d => d -> u) -> Of a b -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Of a b -> [u]
$cgmapQ :: forall a b u.
(Data a, Data b) =>
(forall d. Data d => d -> u) -> Of a b -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Of a b -> r
$cgmapQr :: forall a b r r'.
(Data a, Data b) =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Of a b -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Of a b -> r
$cgmapQl :: forall a b r r'.
(Data a, Data b) =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Of a b -> r
gmapT :: (forall b. Data b => b -> b) -> Of a b -> Of a b
$cgmapT :: forall a b.
(Data a, Data b) =>
(forall b. Data b => b -> b) -> Of a b -> Of a b
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Of a b))
$cdataCast2 :: forall a b (t :: * -> * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Of a b))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Of a b))
$cdataCast1 :: forall a b (t :: * -> *) (c :: * -> *).
(Data a, Data b, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Of a b))
dataTypeOf :: Of a b -> DataType
$cdataTypeOf :: forall a b. (Data a, Data b) => Of a b -> DataType
toConstr :: Of a b -> Constr
$ctoConstr :: forall a b. (Data a, Data b) => Of a b -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Of a b)
$cgunfold :: forall a b (c :: * -> *).
(Data a, Data b) =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Of a b)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Of a b -> c (Of a b)
$cgfoldl :: forall a b (c :: * -> *).
(Data a, Data b) =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Of a b -> c (Of a b)
Data, Of a b -> Of a b -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall a b. (Eq a, Eq b) => Of a b -> Of a b -> Bool
/= :: Of a b -> Of a b -> Bool
$c/= :: forall a b. (Eq a, Eq b) => Of a b -> Of a b -> Bool
== :: Of a b -> Of a b -> Bool
$c== :: forall a b. (Eq a, Eq b) => Of a b -> Of a b -> Bool
Eq, forall a. Of a a -> Bool
forall a a. Eq a => a -> Of a a -> Bool
forall a a. Num a => Of a a -> a
forall a a. Ord a => Of a a -> a
forall m a. Monoid m => (a -> m) -> Of a a -> m
forall a m. Monoid m => Of a m -> m
forall a a. Of a a -> Bool
forall a a. Of a a -> Int
forall a a. Of a a -> [a]
forall a b. (a -> b -> b) -> b -> Of a a -> b
forall a a. (a -> a -> a) -> Of a a -> a
forall a m a. Monoid m => (a -> m) -> Of a a -> m
forall a b a. (b -> a -> b) -> b -> Of a a -> b
forall a a b. (a -> b -> b) -> b -> Of a a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => Of a a -> a
$cproduct :: forall a a. Num a => Of a a -> a
sum :: forall a. Num a => Of a a -> a
$csum :: forall a a. Num a => Of a a -> a
minimum :: forall a. Ord a => Of a a -> a
$cminimum :: forall a a. Ord a => Of a a -> a
maximum :: forall a. Ord a => Of a a -> a
$cmaximum :: forall a a. Ord a => Of a a -> a
elem :: forall a. Eq a => a -> Of a a -> Bool
$celem :: forall a a. Eq a => a -> Of a a -> Bool
length :: forall a. Of a a -> Int
$clength :: forall a a. Of a a -> Int
null :: forall a. Of a a -> Bool
$cnull :: forall a a. Of a a -> Bool
toList :: forall a. Of a a -> [a]
$ctoList :: forall a a. Of a a -> [a]
foldl1 :: forall a. (a -> a -> a) -> Of a a -> a
$cfoldl1 :: forall a a. (a -> a -> a) -> Of a a -> a
foldr1 :: forall a. (a -> a -> a) -> Of a a -> a
$cfoldr1 :: forall a a. (a -> a -> a) -> Of a a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> Of a a -> b
$cfoldl' :: forall a b a. (b -> a -> b) -> b -> Of a a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Of a a -> b
$cfoldl :: forall a b a. (b -> a -> b) -> b -> Of a a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Of a a -> b
$cfoldr' :: forall a a b. (a -> b -> b) -> b -> Of a a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Of a a -> b
$cfoldr :: forall a a b. (a -> b -> b) -> b -> Of a a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> Of a a -> m
$cfoldMap' :: forall a m a. Monoid m => (a -> m) -> Of a a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Of a a -> m
$cfoldMap :: forall a m a. Monoid m => (a -> m) -> Of a a -> m
fold :: forall m. Monoid m => Of a m -> m
$cfold :: forall a m. Monoid m => Of a m -> m
Foldable, Of a b -> Of a b -> Bool
Of a b -> Of a b -> Ordering
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {a} {b}. (Ord a, Ord b) => Eq (Of a b)
forall a b. (Ord a, Ord b) => Of a b -> Of a b -> Bool
forall a b. (Ord a, Ord b) => Of a b -> Of a b -> Ordering
forall a b. (Ord a, Ord b) => Of a b -> Of a b -> Of a b
min :: Of a b -> Of a b -> Of a b
$cmin :: forall a b. (Ord a, Ord b) => Of a b -> Of a b -> Of a b
max :: Of a b -> Of a b -> Of a b
$cmax :: forall a b. (Ord a, Ord b) => Of a b -> Of a b -> Of a b
>= :: Of a b -> Of a b -> Bool
$c>= :: forall a b. (Ord a, Ord b) => Of a b -> Of a b -> Bool
> :: Of a b -> Of a b -> Bool
$c> :: forall a b. (Ord a, Ord b) => Of a b -> Of a b -> Bool
<= :: Of a b -> Of a b -> Bool
$c<= :: forall a b. (Ord a, Ord b) => Of a b -> Of a b -> Bool
< :: Of a b -> Of a b -> Bool
$c< :: forall a b. (Ord a, Ord b) => Of a b -> Of a b -> Bool
compare :: Of a b -> Of a b -> Ordering
$ccompare :: forall a b. (Ord a, Ord b) => Of a b -> Of a b -> Ordering
Ord,
              ReadPrec [Of a b]
ReadPrec (Of a b)
ReadS [Of a b]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall a b. (Read a, Read b) => ReadPrec [Of a b]
forall a b. (Read a, Read b) => ReadPrec (Of a b)
forall a b. (Read a, Read b) => Int -> ReadS (Of a b)
forall a b. (Read a, Read b) => ReadS [Of a b]
readListPrec :: ReadPrec [Of a b]
$creadListPrec :: forall a b. (Read a, Read b) => ReadPrec [Of a b]
readPrec :: ReadPrec (Of a b)
$creadPrec :: forall a b. (Read a, Read b) => ReadPrec (Of a b)
readList :: ReadS [Of a b]
$creadList :: forall a b. (Read a, Read b) => ReadS [Of a b]
readsPrec :: Int -> ReadS (Of a b)
$creadsPrec :: forall a b. (Read a, Read b) => Int -> ReadS (Of a b)
Read, Int -> Of a b -> ShowS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall a b. (Show a, Show b) => Int -> Of a b -> ShowS
forall a b. (Show a, Show b) => [Of a b] -> ShowS
forall a b. (Show a, Show b) => Of a b -> String
showList :: [Of a b] -> ShowS
$cshowList :: forall a b. (Show a, Show b) => [Of a b] -> ShowS
show :: Of a b -> String
$cshow :: forall a b. (Show a, Show b) => Of a b -> String
showsPrec :: Int -> Of a b -> ShowS
$cshowsPrec :: forall a b. (Show a, Show b) => Int -> Of a b -> ShowS
Show, forall {a}. Functor (Of a)
forall a. Foldable (Of a)
forall a (m :: * -> *) a. Monad m => Of a (m a) -> m (Of a a)
forall a (f :: * -> *) a. Applicative f => Of a (f a) -> f (Of a a)
forall a (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Of a a -> m (Of a b)
forall a (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Of a a -> f (Of a b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Of a a -> f (Of a b)
sequence :: forall (m :: * -> *) a. Monad m => Of a (m a) -> m (Of a a)
$csequence :: forall a (m :: * -> *) a. Monad m => Of a (m a) -> m (Of a a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Of a a -> m (Of a b)
$cmapM :: forall a (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Of a a -> m (Of a b)
sequenceA :: forall (f :: * -> *) a. Applicative f => Of a (f a) -> f (Of a a)
$csequenceA :: forall a (f :: * -> *) a. Applicative f => Of a (f a) -> f (Of a a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Of a a -> f (Of a b)
$ctraverse :: forall a (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Of a a -> f (Of a b)
Traversable, Typeable, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a b x. Rep (Of a b) x -> Of a b
forall a b x. Of a b -> Rep (Of a b) x
$cto :: forall a b x. Rep (Of a b) x -> Of a b
$cfrom :: forall a b x. Of a b -> Rep (Of a b) x
Generic, forall a a. Rep1 (Of a) a -> Of a a
forall a a. Of a a -> Rep1 (Of a) a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cto1 :: forall a a. Rep1 (Of a) a -> Of a a
$cfrom1 :: forall a a. Of a a -> Rep1 (Of a) a
Generic1)
infixr 5 :>

instance (Semigroup a, Semigroup b) => Semigroup (Of a b) where
  (a
m :> b
w) <> :: Of a b -> Of a b -> Of a b
<> (a
m' :> b
w') = (a
m forall a. Semigroup a => a -> a -> a
<> a
m') forall a b. a -> b -> Of a b
:> (b
w forall a. Semigroup a => a -> a -> a
<> b
w')
  {-#INLINE (<>) #-}

instance (Monoid a, Monoid b) => Monoid (Of a b) where
  mempty :: Of a b
mempty = forall a. Monoid a => a
mempty forall a b. a -> b -> Of a b
:> forall a. Monoid a => a
mempty
  {-#INLINE mempty #-}
#if !(MIN_VERSION_base(4,11,0))
  mappend (m :> w) (m' :> w') = mappend m m' :> mappend w w'
  {-#INLINE mappend #-}
#endif

instance Functor (Of a) where
  fmap :: forall a b. (a -> b) -> Of a a -> Of a b
fmap a -> b
f (a
a :> a
x) = a
a forall a b. a -> b -> Of a b
:> a -> b
f a
x
  {-#INLINE fmap #-}
  a
a <$ :: forall a b. a -> Of a b -> Of a a
<$ (a
b :> b
_)   = a
b forall a b. a -> b -> Of a b
:> a
a
  {-#INLINE (<$) #-}

#if MIN_VERSION_base(4,8,0)
instance Bifunctor Of where
  bimap :: forall a b c d. (a -> b) -> (c -> d) -> Of a c -> Of b d
bimap a -> b
f c -> d
g (a
a :> c
b) = a -> b
f a
a forall a b. a -> b -> Of a b
:> c -> d
g c
b
  {-#INLINE bimap #-}
  first :: forall a b c. (a -> b) -> Of a c -> Of b c
first a -> b
f   (a
a :> c
b) = a -> b
f a
a forall a b. a -> b -> Of a b
:> c
b
  {-#INLINE first #-}
  second :: forall b c a. (b -> c) -> Of a b -> Of a c
second b -> c
g  (a
a :> b
b) = a
a forall a b. a -> b -> Of a b
:> b -> c
g b
b
  {-#INLINE second #-}
#endif

#if MIN_VERSION_base(4,10,0)
-- | @since 0.2.4.0
instance Bifoldable Of where
  bifoldMap :: forall m a b. Monoid m => (a -> m) -> (b -> m) -> Of a b -> m
bifoldMap a -> m
f b -> m
g (a
a :> b
b) = a -> m
f a
a forall a. Monoid a => a -> a -> a
`mappend` b -> m
g b
b
  {-#INLINE bifoldMap #-}

-- | @since 0.2.4.0
instance Bitraversable Of where
  bitraverse :: forall (f :: * -> *) a c b d.
Applicative f =>
(a -> f c) -> (b -> f d) -> Of a b -> f (Of c d)
bitraverse a -> f c
f b -> f d
g (a
a :> b
b) = forall a b. a -> b -> Of a b
(:>) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f c
f a
a forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> b -> f d
g b
b
  {-#INLINE bitraverse #-}
#endif

instance Monoid a => Applicative (Of a) where
  pure :: forall a. a -> Of a a
pure a
x = forall a. Monoid a => a
mempty forall a b. a -> b -> Of a b
:> a
x
  {-#INLINE pure #-}
  (a
m :> a -> b
f) <*> :: forall a b. Of a (a -> b) -> Of a a -> Of a b
<*> (a
m' :> a
x) = forall a. Monoid a => a -> a -> a
mappend a
m a
m' forall a b. a -> b -> Of a b
:> a -> b
f a
x
  {-#INLINE (<*>) #-}
  (a
m :> a
_) *> :: forall a b. Of a a -> Of a b -> Of a b
*> (a
m' :> b
y)  = forall a. Monoid a => a -> a -> a
mappend a
m a
m' forall a b. a -> b -> Of a b
:> b
y
  {-#INLINE (*>) #-}
  (a
m :> a
x) <* :: forall a b. Of a a -> Of a b -> Of a a
<* (a
m' :> b
_)  = forall a. Monoid a => a -> a -> a
mappend a
m a
m' forall a b. a -> b -> Of a b
:> a
x
  {-#INLINE (<*) #-}

instance Monoid a => Monad (Of a) where
  return :: forall a. a -> Of a a
return = forall (f :: * -> *) a. Applicative f => a -> f a
pure
  {-#INLINE return #-}
  >> :: forall a b. Of a a -> Of a b -> Of a b
(>>) = forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
(*>)
  {-#INLINE (>>) #-}
  (a
m :> a
x) >>= :: forall a b. Of a a -> (a -> Of a b) -> Of a b
>>= a -> Of a b
f = let a
m' :> b
y = a -> Of a b
f a
x in forall a. Monoid a => a -> a -> a
mappend a
m a
m' forall a b. a -> b -> Of a b
:> b
y
  {-#INLINE (>>=) #-}

#if MIN_VERSION_base(4,9,0)
instance Show a => Show1 (Of a) where
  liftShowsPrec :: forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Of a a -> ShowS
liftShowsPrec = forall (f :: * -> * -> *) a b.
Show2 f =>
(Int -> a -> ShowS)
-> ([a] -> ShowS)
-> (Int -> b -> ShowS)
-> ([b] -> ShowS)
-> Int
-> f a b
-> ShowS
liftShowsPrec2 forall a. Show a => Int -> a -> ShowS
showsPrec forall a. Show a => [a] -> ShowS
showList

instance Eq a => Eq1 (Of a) where
  liftEq :: forall a b. (a -> b -> Bool) -> Of a a -> Of a b -> Bool
liftEq = forall (f :: * -> * -> *) a b c d.
Eq2 f =>
(a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool
liftEq2 forall a. Eq a => a -> a -> Bool
(==)

instance Ord a => Ord1 (Of a) where
  liftCompare :: forall a b. (a -> b -> Ordering) -> Of a a -> Of a b -> Ordering
liftCompare = forall (f :: * -> * -> *) a b c d.
Ord2 f =>
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> f a c -> f b d -> Ordering
liftCompare2 forall a. Ord a => a -> a -> Ordering
compare

instance Show2 Of where
  liftShowsPrec2 :: forall a b.
(Int -> a -> ShowS)
-> ([a] -> ShowS)
-> (Int -> b -> ShowS)
-> ([b] -> ShowS)
-> Int
-> Of a b
-> ShowS
liftShowsPrec2 Int -> a -> ShowS
spa [a] -> ShowS
_sla Int -> b -> ShowS
spb [b] -> ShowS
_slb Int
p (a
a :> b
b) =
    Bool -> ShowS -> ShowS
showParen (Int
p forall a. Ord a => a -> a -> Bool
> Int
5) forall a b. (a -> b) -> a -> b
$
    Int -> a -> ShowS
spa Int
6 a
a forall b c a. (b -> c) -> (a -> b) -> a -> c
.
    String -> ShowS
showString String
" :> " forall b c a. (b -> c) -> (a -> b) -> a -> c
.
    Int -> b -> ShowS
spb Int
6 b
b

instance Eq2 Of where
  liftEq2 :: forall a b c d.
(a -> b -> Bool) -> (c -> d -> Bool) -> Of a c -> Of b d -> Bool
liftEq2 a -> b -> Bool
f c -> d -> Bool
g (a
x :> c
y) (b
z :> d
w) = a -> b -> Bool
f a
x b
z Bool -> Bool -> Bool
&& c -> d -> Bool
g c
y d
w

instance Ord2 Of where
  liftCompare2 :: forall a b c d.
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> Of a c -> Of b d -> Ordering
liftCompare2 a -> b -> Ordering
comp1 c -> d -> Ordering
comp2 (a
x :> c
y) (b
z :> d
w) =
    a -> b -> Ordering
comp1 a
x b
z forall a. Monoid a => a -> a -> a
`mappend` c -> d -> Ordering
comp2 c
y d
w
#endif