{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances,
FlexibleContexts, PolyKinds, TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
module Data.Profunctor.Product.Default
( module Data.Profunctor.Product.Default.Class
) where
import Control.Applicative (Const (Const))
import Data.Functor.Identity (Identity (Identity))
import Data.Profunctor (Profunctor, dimap)
import Data.Profunctor.Product
import Data.Tagged (Tagged (Tagged))
import Data.Profunctor.Product.Default.Class
import Data.Profunctor.Product.Tuples.TH (mkDefaultNs, maxTupleSize)
instance (Profunctor p, Default p a b) => Default p (Identity a) (Identity b)
where
def :: p (Identity a) (Identity b)
def = forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap (\(Identity a
a) -> a
a) forall a. a -> Identity a
Identity forall (p :: * -> * -> *) a b. Default p a b => p a b
def
instance (Profunctor p, Default p a b) => Default p (Const a c) (Const b c')
where
def :: p (Const a c) (Const b c')
def = forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap (\(Const a
a) -> a
a) forall {k} a (b :: k). a -> Const a b
Const forall (p :: * -> * -> *) a b. Default p a b => p a b
def
instance (Profunctor p, Default p a b) => Default p (Tagged s a) (Tagged s' b)
where
def :: p (Tagged s a) (Tagged s' b)
def = forall (p :: * -> * -> *) a b c d.
Profunctor p =>
(a -> b) -> (c -> d) -> p b c -> p a d
dimap (\(Tagged a
a) -> a
a) forall {k} (s :: k) b. b -> Tagged s b
Tagged forall (p :: * -> * -> *) a b. Default p a b => p a b
def