HORIZON HASKELLDocslts/ghc-10.0.x8c2f8e82026-10-19Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8c2f8e8 · 2026-10-19

Moduleproduct-profunctors-0.11.1.1Haskell2010

Data.Profunctor.Product.Default

For some ProductProfunctors p and types a, a' there is a unique most sensible value of p a a'. Default exists to automatically generate that unique most sensible value for a product given unique most sensible values for the base types. If the unique most sensible values of type p a a', p b b' and p c c' are

sensible_a :: p a a'
sensible_b :: p b b'
sensible_c :: p c c'

then the unique most sensible value of type p (a, b, c) (a', b', c') is

p3 (sensible_a, sebsible_b, sensible_c)
     :: p (a, b, c) (a', b', c')
 

Therefore there is an instance

instance
  ( Default p a a'
  , Default p b b'
  , Default p c c'
  )
=> Default p (a, b, c) (a', b', c')
    where def = p3 (def, def, def)

which can be read as "if the unique most sensible values of types ... are ... then the unique most sensible value of the 3-tuple is given by composing them with p3". Naturally each different product type has a different composition function.

  • 5 types
  • 2 classes
  • 1 value
classclass Default (p :: Type -> Type -> Type) a b where
#

Methods

Instances131Default, …
typetype DefaultFields' (p :: Type -> Type -> Type) a = DefaultFields p a a
#

Default constraints on the fields of a Generic datatype.

For a type like

data Foo = Bar { a :: Int, b :: String }
         | Baz Bool

we get the following constraints

DefaultFields' p Foo =
  ( Default p Int Int
  , Default p String String
  , Default p Bool Bool
  )
typetype DefaultPConstraints (p :: Type -> Type -> Type) a = GDefPCnstr p (Rep a)
#

DefaultPConstraints p a expands to the minimal combination of Profunctor p, ProductProfunctor p, SumProfunctor p needed to implement the instance Default p a a for a Generic datatype a.

DefaultPConstraints p Foo =
  ( ProductProfunctor p      -- because Foo has a constructor Bar with many fields
  , SumProfunctor p          -- because Foo has multiple constructors
  )
DefaultConstraints p (a, b) =
  ( ProductProfunctor p      -- (a, b) has a single constructor with two fields
  )
familytype family Defaults (as :: [Type]) :: Constraint
#

A list of Default constraints.

Defaults '[p a a', p b b', p c c'] =
  (Default p a a', Default p b b', Default p c c')
Instances2Defaults
  • type Defaults '[] = ()Defined in product-profunctors-0.11.1.1 · Data.Profunctor.Product.Default.Class
  • type Defaults (p a a' ': as) = (Default p a a', Defaults as)Defined in product-profunctors-0.11.1.1 · Data.Profunctor.Product.Default.Class
familytype family GDefCnstr (p :: Type -> Type -> Type) (f :: Type -> Type) (g :: Type -> Type) :: Constraint
#
Instances5GDefCnstr
  • type GDefCnstr p U1 U1 = ()Defined in product-profunctors-0.11.1.1 · Data.Profunctor.Product.Default.Class
  • type GDefCnstr p (K1 i c) (K1 i c') = Default p c c'Defined in product-profunctors-0.11.1.1 · Data.Profunctor.Product.Default.Class
  • type GDefCnstr p (M1 i c f) (M1 i c g) = GDefCnstr p f gDefined in product-profunctors-0.11.1.1 · Data.Profunctor.Product.Default.Class
  • type GDefCnstr p (f :*: g) (f' :*: g') = (GDefCnstr p f f', GDefCnstr p g g')Defined in product-profunctors-0.11.1.1 · Data.Profunctor.Product.Default.Class
  • type GDefCnstr p (f :+: g) (f' :+: g') = (GDefCnstr p f f', GDefCnstr p g g')Defined in product-profunctors-0.11.1.1 · Data.Profunctor.Product.Default.Class
familytype family GDefPCnstr (p :: Type -> Type -> Type) (f :: Type -> Type) :: Constraint
#
Instances5GDefPCnstr
classclass GDefault (p :: Type -> Type -> Type) (f :: Type -> Type) (g :: Type -> Type) where
#

Associated types

Methods

Instances5GDefault

Orphan instances

127 instances