{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE StandaloneKindSignatures #-}

module Data.SOP.Functors (
    Flip (..)
  , K2 (..)
  , Product2 (..)
  , snd2
  ) where

import           Data.Kind (Type)
import           GHC.Generics (Generic)
import           NoThunks.Class

type Product2 :: (Type -> Type -> Type)
              -> (Type -> Type -> Type)
              -> Type -> Type -> Type
data Product2 f g x y = Pair2 (f x y) (g x y)
  deriving (Product2 f g x y -> Product2 f g x y -> Bool
(Product2 f g x y -> Product2 f g x y -> Bool)
-> (Product2 f g x y -> Product2 f g x y -> Bool)
-> Eq (Product2 f g x y)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall (f :: * -> * -> *) (g :: * -> * -> *) x y.
(Eq (f x y), Eq (g x y)) =>
Product2 f g x y -> Product2 f g x y -> Bool
$c== :: forall (f :: * -> * -> *) (g :: * -> * -> *) x y.
(Eq (f x y), Eq (g x y)) =>
Product2 f g x y -> Product2 f g x y -> Bool
== :: Product2 f g x y -> Product2 f g x y -> Bool
$c/= :: forall (f :: * -> * -> *) (g :: * -> * -> *) x y.
(Eq (f x y), Eq (g x y)) =>
Product2 f g x y -> Product2 f g x y -> Bool
/= :: Product2 f g x y -> Product2 f g x y -> Bool
Eq, (forall x. Product2 f g x y -> Rep (Product2 f g x y) x)
-> (forall x. Rep (Product2 f g x y) x -> Product2 f g x y)
-> Generic (Product2 f g x y)
forall x. Rep (Product2 f g x y) x -> Product2 f g x y
forall x. Product2 f g x y -> Rep (Product2 f g x y) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (f :: * -> * -> *) (g :: * -> * -> *) x y x.
Rep (Product2 f g x y) x -> Product2 f g x y
forall (f :: * -> * -> *) (g :: * -> * -> *) x y x.
Product2 f g x y -> Rep (Product2 f g x y) x
$cfrom :: forall (f :: * -> * -> *) (g :: * -> * -> *) x y x.
Product2 f g x y -> Rep (Product2 f g x y) x
from :: forall x. Product2 f g x y -> Rep (Product2 f g x y) x
$cto :: forall (f :: * -> * -> *) (g :: * -> * -> *) x y x.
Rep (Product2 f g x y) x -> Product2 f g x y
to :: forall x. Rep (Product2 f g x y) x -> Product2 f g x y
Generic, Int -> Product2 f g x y -> ShowS
[Product2 f g x y] -> ShowS
Product2 f g x y -> String
(Int -> Product2 f g x y -> ShowS)
-> (Product2 f g x y -> String)
-> ([Product2 f g x y] -> ShowS)
-> Show (Product2 f g x y)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall (f :: * -> * -> *) (g :: * -> * -> *) x y.
(Show (f x y), Show (g x y)) =>
Int -> Product2 f g x y -> ShowS
forall (f :: * -> * -> *) (g :: * -> * -> *) x y.
(Show (f x y), Show (g x y)) =>
[Product2 f g x y] -> ShowS
forall (f :: * -> * -> *) (g :: * -> * -> *) x y.
(Show (f x y), Show (g x y)) =>
Product2 f g x y -> String
$cshowsPrec :: forall (f :: * -> * -> *) (g :: * -> * -> *) x y.
(Show (f x y), Show (g x y)) =>
Int -> Product2 f g x y -> ShowS
showsPrec :: Int -> Product2 f g x y -> ShowS
$cshow :: forall (f :: * -> * -> *) (g :: * -> * -> *) x y.
(Show (f x y), Show (g x y)) =>
Product2 f g x y -> String
show :: Product2 f g x y -> String
$cshowList :: forall (f :: * -> * -> *) (g :: * -> * -> *) x y.
(Show (f x y), Show (g x y)) =>
[Product2 f g x y] -> ShowS
showList :: [Product2 f g x y] -> ShowS
Show)

snd2 :: Product2 f g x y -> g x y
snd2 :: forall (f :: * -> * -> *) (g :: * -> * -> *) x y.
Product2 f g x y -> g x y
snd2 (Pair2 f x y
_ g x y
g) = g x y
g

type Flip :: (x -> y -> Type) -> y -> x -> Type
newtype Flip f x y = Flip {forall x y (f :: x -> y -> *) (x :: y) (y :: x).
Flip f x y -> f y x
unFlip :: f y x}
  deriving (Flip f x y -> Flip f x y -> Bool
(Flip f x y -> Flip f x y -> Bool)
-> (Flip f x y -> Flip f x y -> Bool) -> Eq (Flip f x y)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall y x (f :: x -> y -> *) (x :: y) (y :: x).
Eq (f y x) =>
Flip f x y -> Flip f x y -> Bool
$c== :: forall y x (f :: x -> y -> *) (x :: y) (y :: x).
Eq (f y x) =>
Flip f x y -> Flip f x y -> Bool
== :: Flip f x y -> Flip f x y -> Bool
$c/= :: forall y x (f :: x -> y -> *) (x :: y) (y :: x).
Eq (f y x) =>
Flip f x y -> Flip f x y -> Bool
/= :: Flip f x y -> Flip f x y -> Bool
Eq, (forall x. Flip f x y -> Rep (Flip f x y) x)
-> (forall x. Rep (Flip f x y) x -> Flip f x y)
-> Generic (Flip f x y)
forall x. Rep (Flip f x y) x -> Flip f x y
forall x. Flip f x y -> Rep (Flip f x y) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall y x (f :: x -> y -> *) (x :: y) (y :: x) x.
Rep (Flip f x y) x -> Flip f x y
forall y x (f :: x -> y -> *) (x :: y) (y :: x) x.
Flip f x y -> Rep (Flip f x y) x
$cfrom :: forall y x (f :: x -> y -> *) (x :: y) (y :: x) x.
Flip f x y -> Rep (Flip f x y) x
from :: forall x. Flip f x y -> Rep (Flip f x y) x
$cto :: forall y x (f :: x -> y -> *) (x :: y) (y :: x) x.
Rep (Flip f x y) x -> Flip f x y
to :: forall x. Rep (Flip f x y) x -> Flip f x y
Generic, Context -> Flip f x y -> IO (Maybe ThunkInfo)
Proxy (Flip f x y) -> String
(Context -> Flip f x y -> IO (Maybe ThunkInfo))
-> (Context -> Flip f x y -> IO (Maybe ThunkInfo))
-> (Proxy (Flip f x y) -> String)
-> NoThunks (Flip f x y)
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
forall y x (f :: x -> y -> *) (x :: y) (y :: x).
NoThunks (f y x) =>
Context -> Flip f x y -> IO (Maybe ThunkInfo)
forall y x (f :: x -> y -> *) (x :: y) (y :: x).
NoThunks (f y x) =>
Proxy (Flip f x y) -> String
$cnoThunks :: forall y x (f :: x -> y -> *) (x :: y) (y :: x).
NoThunks (f y x) =>
Context -> Flip f x y -> IO (Maybe ThunkInfo)
noThunks :: Context -> Flip f x y -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall y x (f :: x -> y -> *) (x :: y) (y :: x).
NoThunks (f y x) =>
Context -> Flip f x y -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> Flip f x y -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall y x (f :: x -> y -> *) (x :: y) (y :: x).
NoThunks (f y x) =>
Proxy (Flip f x y) -> String
showTypeOf :: Proxy (Flip f x y) -> String
NoThunks, Int -> Flip f x y -> ShowS
[Flip f x y] -> ShowS
Flip f x y -> String
(Int -> Flip f x y -> ShowS)
-> (Flip f x y -> String)
-> ([Flip f x y] -> ShowS)
-> Show (Flip f x y)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall y x (f :: x -> y -> *) (x :: y) (y :: x).
Show (f y x) =>
Int -> Flip f x y -> ShowS
forall y x (f :: x -> y -> *) (x :: y) (y :: x).
Show (f y x) =>
[Flip f x y] -> ShowS
forall y x (f :: x -> y -> *) (x :: y) (y :: x).
Show (f y x) =>
Flip f x y -> String
$cshowsPrec :: forall y x (f :: x -> y -> *) (x :: y) (y :: x).
Show (f y x) =>
Int -> Flip f x y -> ShowS
showsPrec :: Int -> Flip f x y -> ShowS
$cshow :: forall y x (f :: x -> y -> *) (x :: y) (y :: x).
Show (f y x) =>
Flip f x y -> String
show :: Flip f x y -> String
$cshowList :: forall y x (f :: x -> y -> *) (x :: y) (y :: x).
Show (f y x) =>
[Flip f x y] -> ShowS
showList :: [Flip f x y] -> ShowS
Show)

type K2 :: Type -> x -> y -> Type
newtype K2 a b c = K2 a