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

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Modulehedgehog-fn-1.1Haskell2010

Hedgehog.Function

The general procedure for generating functions of type A -> B looks something like this:

{-# language DeriveGeneric #-}
{-# language TypeApplications #-}

import Hedgehog
import Hedgehog.Function

data A = ...
  deriving (Generic, ...)

instance Arg A
instance Vary A

genB :: MonadGen m => m B
genB = ...

prop_test :: Property
prop_test =
  property $ do
    f <- forAllFn $ fn @A genB
    ...

Here's an example of how to use the library to test the "fmap composition" law.

ScopedTypeVariables and TypeApplications are recommended for ease of use. RankNTypes is only necessary for this example.

{-# language RankNTypes #-}
{-# language ScopedTypeVariables, TypeApplications #-}

import Hedgehog
import Hedgehog.Function
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range

map_compose
  :: forall f a b c
   . ( Functor f
     , Show (f a)
     , Show a, Arg a, Vary a
     , Show b, Arg b, Vary b
     , Show c
     , Eq (f c)
     , Show (f c)
     )
  => (forall x. Gen x -> Gen (f x))
  -> Gen a
  -> Gen b
  -> Gen c
  -> Property
map_compose genF genA genB genC =
  property $ do
    g <- forAllFn $ fn @a genB
    f <- forAllFn $ fn @b genC
    xs <- forAll $ genF genA
    fmap (f . g) xs === fmap f (fmap g xs)

prop_map_list :: Property
prop_map_list =
  map_compose
    (Gen.list (Range.constant 0 100))
    Gen.bool
    Gen.bool
    Gen.bool
  • 39 types
  • 10 classes
  • 28 values
  • Packagehedgehog-fn-1.1
  • Exports86
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceFunction.hs
datadata (:*:) (f :: k -> Type) (g :: k -> Type) (p :: k)
#

Products: encode multiple arguments to constructors

Constructors

  • f p :*: g pinfixr 6
Instances60GTraversable, GApplicative, GConstraints, GFunctor, GBare, Generic1, …
datadata (:+:) (f :: k -> Type) (g :: k -> Type) (p :: k)
#

Sums: encode choice between constructors

Constructors

Instances50GTraversable, GConstraints, GFunctor, GBare, Generic1, GNFData, …
newtypenewtype (:.:) (f :: k2 -> Type) (g :: k1 -> k2) (p :: k1)
#

Composition of functors

Constructors

Instances40Generic1, GNFData, GHashable, GEq1, GOrd1, GRead1Con, …
datadata Associativity
#

Datatype to represent the associativity of a constructor

Instances16Bounded, Enum, Eq, Data, Ord, Read, …
datadata C
#

Tag for M1: constructor

Instances1GDump
  • (GDump f, Constructor c) => GDump (M1 C c f)Defined in pretty-show-1.10 · Text.Show.PrettyVal
typetype C1 = M1 C
#

Type synonym for encoding meta-information for constructors

Instances10GSum, GRead1, GShow1, GSumGet, GSumPut, SumSize, …
  • GHashable arity a => GSum arity (C1 c a)Defined in hashable-1.5.1.0 · Data.Hashable.Generic.Instances
  • (Constructor c, GRead1Con v f, IsNullaryCon f) => GRead1 v (C1 c f)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • (Constructor c, GShow1Con v f, IsNullaryCon f) => GShow1 v (C1 c f)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GBinaryGet a => GSumGet (C1 c a)Defined in binary-0.8.9.3 · Data.Binary.Generic
  • GBinaryPut a => GSumPut (C1 c a)Defined in binary-0.8.9.3 · Data.Binary.Generic
  • SumSize (C1 c a)Defined in binary-0.8.9.3 · Data.Binary.Generic
  • SumSize (C1 c a)Defined in hashable-1.5.1.0 · Data.Hashable.Generic.Instances
  • IsNullaryDataType (C1 c f)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • (Constructor c, GReadCon (f p), IsNullaryCon f) => GRead (C1 c f p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • (Constructor c, GShowCon (f p), IsNullaryCon f) => GShow (C1 c f p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
classclass Constructor (c :: k) where
#

Class for datatypes that represent data constructors

Methods

Instances1Constructor
datadata D
#

Tag for M1: datatype

Instances1GDump
  • (GDump f, Datatype d) => GDump (M1 D d f)Defined in pretty-show-1.10 · Text.Show.PrettyVal
typetype D1 = M1 D
#

Type synonym for encoding meta-information for datatypes

Instances4GRead1, GShow1, GRead, GShow
  • (GRead1 v f, IsNullaryDataType f) => GRead1 v (D1 d f)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GShow1 v f => GShow1 v (D1 d f)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • (GRead (f p), IsNullaryDataType f) => GRead (D1 d f p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GShow (f p) => GShow (D1 d f p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
classclass Datatype (d :: k) where
#

Class for datatypes that represent datatypes

Methods

  • datatypeName :: t d f a -> [Char]

    The name of the datatype (unqualified)

  • moduleName :: t d f a -> [Char]

    The fully-qualified name of the module where the type is declared

  • packageName :: t d f a -> [Char]

    The package name of the module where the type is declared

  • isNewtype :: t d f a -> Bool

    Marks if the datatype is actually a newtype

Instances1Datatype
datadata DecidedStrictness
#

The strictness that GHC infers for a field during compilation. Whereas there are nine different combinations of SourceUnpackedness and SourceStrictness, the strictness that GHC decides will ultimately be one of lazy, strict, or unpacked. What GHC decides is affected both by what the user writes in the source code and by GHC flags. As an example, consider this data type:

data E = ExampleConstructor {-# UNPACK #-} !Int !Int Int
Instances16Bounded, Enum, Eq, Data, Ord, Read, …
datadata Fixity
#

Datatype to represent the fixity of a constructor. An infix | declaration directly corresponds to an application of Infix.

Instances7Eq, Data, Ord, Read, Show, Generic, …
datadata FixityI
#

This variant of Fixity appears at the type level.

Instances5SingKind, SingI, DemoteRep, Sing
  • SingKind FixityIDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • SingI 'PrefixIDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • (SingI a, KnownNat n) => SingI ('InfixI a n)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • type DemoteRep FixityI = FixityDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • data Sing
    • SPrefix :: R:SingFixityIa 'PrefixI
    • SInfix :: Sing a -> Integer -> R:SingFixityIa a
    Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
classclass Generic a where
#

Representable types of kind *. This class is derivable in GHC with the DeriveGeneric flag on.

A Generic instance must satisfy the following laws:

from . to ≡ Prelude.id
to . from ≡ Prelude.id

Associated types

  • type family Rep a :: Type -> Type

    Generic representation type

Methods

  • from :: a -> Rep a x

    Convert from the datatype to its representation

  • to :: Rep a x -> a

    Convert from the representation to the datatype

Instances245Generic, …
  • Generic CCFlagsDefined in base-4.23.0.0 · GHC.RTS.Flags
  • Generic ConcFlagsDefined in base-4.23.0.0 · GHC.RTS.Flags
  • Generic DebugFlagsDefined in base-4.23.0.0 · GHC.RTS.Flags
  • Generic DoCostCentresDefined in base-4.23.0.0 · GHC.RTS.Flags
  • Generic DoHeapProfileDefined in base-4.23.0.0 · GHC.RTS.Flags
  • Generic DoTraceDefined in base-4.23.0.0 · GHC.RTS.Flags
  • Generic GCFlagsDefined in base-4.23.0.0 · GHC.RTS.Flags
  • Generic GiveGCStatsDefined in base-4.23.0.0 · GHC.RTS.Flags
  • Generic HpcFlagsDefined in base-4.23.0.0 · GHC.RTS.Flags
  • Generic MiscFlagsDefined in base-4.23.0.0 · GHC.RTS.Flags
  • Generic ParFlagsDefined in base-4.23.0.0 · GHC.RTS.Flags
  • Generic ProfFlagsDefined in base-4.23.0.0 · GHC.RTS.Flags
  • Generic RTSFlagsDefined in base-4.23.0.0 · GHC.RTS.Flags
  • Generic TickyFlagsDefined in base-4.23.0.0 · GHC.RTS.Flags
  • Generic TraceFlagsDefined in base-4.23.0.0 · GHC.RTS.Flags
  • Generic GCDetailsDefined in base-4.23.0.0 · GHC.Stats
  • Generic RTSStatsDefined in base-4.23.0.0 · GHC.Stats
  • Generic ShortByteStringDefined in bytestring-0.12.2.0 · Data.ByteString.Short.Internal
  • Generic VoidDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic ByteOrderDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic ClosureTypeDefined in ghc-internal-10.0.0 · GHC.Internal.ClosureTypes
  • Generic AllDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic AnyDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic VersionDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic FingerprintDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic ForeignSrcLangDefined in ghc-internal-10.0.0 · GHC.Internal.ForeignSrcLang
  • Generic AssociativityDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic DecidedStrictnessDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic FixityDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic SourceStrictnessDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic SourceUnpackednessDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic PrimTypeDefined in ghc-internal-10.0.0 · GHC.Internal.Heap.Closures
  • Generic TsoFlagsDefined in ghc-internal-10.0.0 · GHC.Internal.Heap.Closures
  • Generic WhatNextDefined in ghc-internal-10.0.0 · GHC.Internal.Heap.Closures
  • Generic WhyBlockedDefined in ghc-internal-10.0.0 · GHC.Internal.Heap.Closures
  • Generic StgInfoTableDefined in ghc-internal-10.0.0 · GHC.Internal.Heap.InfoTable.Types
  • Generic CostCentreDefined in ghc-internal-10.0.0 · GHC.Internal.Heap.ProfInfo.Types
  • Generic CostCentreStackDefined in ghc-internal-10.0.0 · GHC.Internal.Heap.ProfInfo.Types
  • Generic IndexTableDefined in ghc-internal-10.0.0 · GHC.Internal.Heap.ProfInfo.Types
  • Generic StgTSOProfInfoDefined in ghc-internal-10.0.0 · GHC.Internal.Heap.ProfInfo.Types
  • Generic ExitCodeDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic ExtensionDefined in ghc-internal-10.0.0 · GHC.Internal.LanguageExtensions
  • Generic CCFlagsDefined in ghc-internal-10.0.0 · GHC.Internal.RTS.Flags
  • Generic ConcFlagsDefined in ghc-internal-10.0.0 · GHC.Internal.RTS.Flags
  • Generic DebugFlagsDefined in ghc-internal-10.0.0 · GHC.Internal.RTS.Flags
  • Generic DoCostCentresDefined in ghc-internal-10.0.0 · GHC.Internal.RTS.Flags
  • Generic DoHeapProfileDefined in ghc-internal-10.0.0 · GHC.Internal.RTS.Flags
  • Generic DoTraceDefined in ghc-internal-10.0.0 · GHC.Internal.RTS.Flags
  • Generic GCFlagsDefined in ghc-internal-10.0.0 · GHC.Internal.RTS.Flags
  • Generic GiveGCStatsDefined in ghc-internal-10.0.0 · GHC.Internal.RTS.Flags
  • Generic HpcFlagsDefined in ghc-internal-10.0.0 · GHC.Internal.RTS.Flags
  • Generic MiscFlagsDefined in ghc-internal-10.0.0 · GHC.Internal.RTS.Flags
  • Generic ParFlagsDefined in ghc-internal-10.0.0 · GHC.Internal.RTS.Flags
  • Generic ProfFlagsDefined in ghc-internal-10.0.0 · GHC.Internal.RTS.Flags
  • Generic RTSFlagsDefined in ghc-internal-10.0.0 · GHC.Internal.RTS.Flags
  • Generic TickyFlagsDefined in ghc-internal-10.0.0 · GHC.Internal.RTS.Flags
  • Generic TraceFlagsDefined in ghc-internal-10.0.0 · GHC.Internal.RTS.Flags
  • Generic SrcLocDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic GCDetailsDefined in ghc-internal-10.0.0 · GHC.Internal.Stats
  • Generic RTSStatsDefined in ghc-internal-10.0.0 · GHC.Internal.Stats
  • Generic AnnLookupDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic AnnTargetDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic BangDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic BndrVisDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic BodyDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic BytesDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic CallconvDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic ClauseDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic ConDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic DecDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic DecidedStrictnessDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic DerivClauseDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic DerivStrategyDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic DocLocDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic ExpDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic FamilyResultSigDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic FixityDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic FixityDirectionDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic ForeignDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic FunDepDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic GuardDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic InfoDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic InjectivityAnnDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic InlineDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic LitDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic LocDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic MatchDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic ModNameDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic ModuleDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic ModuleInfoDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic NameDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic NameFlavourDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic NameSpaceDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic NamespaceSpecifierDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic OccNameDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic OverlapDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic PatDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic PatSynArgsDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic PatSynDirDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic PhasesDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic PkgNameDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic PragmaDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic RangeDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic RoleDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic RuleBndrDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic RuleMatchDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic SafetyDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic SourceStrictnessDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic SourceUnpackednessDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic SpecificityDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic StmtDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic TyLitDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic TySynEqnDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic TypeDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic TypeFamilyHeadDefined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic BoolDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic OrderingDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic GeneralCategoryDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic OsCharDefined in os-string-2.0.11 · System.OsString.Internal.Types
  • Generic OsStringDefined in os-string-2.0.11 · System.OsString.Internal.Types
  • Generic PosixCharDefined in os-string-2.0.11 · System.OsString.Internal.Types
  • Generic PosixStringDefined in os-string-2.0.11 · System.OsString.Internal.Types
  • Generic WindowsCharDefined in os-string-2.0.11 · System.OsString.Internal.Types
  • Generic WindowsStringDefined in os-string-2.0.11 · System.OsString.Internal.Types
  • Generic ModeDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Generic StyleDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Generic TextDetailsDefined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Generic DocDefined in pretty-1.1.3.6 · Text.PrettyPrint.HughesPJ
  • Generic CalendarDiffDaysDefined in time-1.16.0.1 · Data.Time.Calendar.CalendarDiffDays
  • Generic DayDefined in time-1.16.0.1 · Data.Time.Calendar.Days
  • Generic MonthDefined in time-1.16.0.1 · Data.Time.Calendar.Month
  • Generic QuarterDefined in time-1.16.0.1 · Data.Time.Calendar.Quarter
  • Generic QuarterOfYearDefined in time-1.16.0.1 · Data.Time.Calendar.Quarter
  • Generic DayOfWeekDefined in time-1.16.0.1 · Data.Time.Calendar.Week
  • Generic SystemTimeDefined in time-1.16.0.1 · Data.Time.Clock.Internal.SystemTime
  • Generic UTCTimeDefined in time-1.16.0.1 · Data.Time.Clock.Internal.UTCTime
  • Generic UniversalTimeDefined in time-1.16.0.1 · Data.Time.Clock.Internal.UniversalTime
  • Generic CalendarDiffTimeDefined in time-1.16.0.1 · Data.Time.LocalTime.Internal.CalendarDiffTime
  • Generic LocalTimeDefined in time-1.16.0.1 · Data.Time.LocalTime.Internal.LocalTime
  • Generic TimeOfDayDefined in time-1.16.0.1 · Data.Time.LocalTime.Internal.TimeOfDay
  • Generic TimeZoneDefined in time-1.16.0.1 · Data.Time.LocalTime.Internal.TimeZone
  • Generic ZonedTimeDefined in time-1.16.0.1 · Data.Time.LocalTime.Internal.ZonedTime
  • Generic ()Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Complex a)Defined in base-4.23.0.0 · Data.Complex
  • Generic (First a)Defined in base-4.23.0.0 · Data.Semigroup
  • Generic (Last a)Defined in base-4.23.0.0 · Data.Semigroup
  • Generic (Max a)Defined in base-4.23.0.0 · Data.Semigroup
  • Generic (Min a)Defined in base-4.23.0.0 · Data.Semigroup
  • Generic (WrappedMonoid m)Defined in base-4.23.0.0 · Data.Semigroup
  • Generic (SCC vertex)Defined in containers-0.8 · Data.Graph
  • Generic (Digit a)Defined in containers-0.8 · Data.Sequence.Internal
  • Generic (Elem a)Defined in containers-0.8 · Data.Sequence.Internal
  • Generic (FingerTree a)Defined in containers-0.8 · Data.Sequence.Internal
  • Generic (Node a)Defined in containers-0.8 · Data.Sequence.Internal
  • Generic (ViewL a)Defined in containers-0.8 · Data.Sequence.Internal
  • Generic (ViewR a)Defined in containers-0.8 · Data.Sequence.Internal
  • Generic (PostOrder a)Defined in containers-0.8 · Data.Tree
  • Generic (Tree a)Defined in containers-0.8 · Data.Tree
  • Generic (NonEmpty a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Identity a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (First a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Last a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Down a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Dual a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Endo a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Product a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Sum a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (ZipList a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Par1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (GenClosure b)Defined in ghc-internal-10.0.0 · GHC.Internal.Heap.Closures
  • Generic (GenStackField b)Defined in ghc-internal-10.0.0 · GHC.Internal.Heap.Closures
  • Generic (GenStackFrame b)Defined in ghc-internal-10.0.0 · GHC.Internal.Heap.Closures
  • Generic (GenStgStackClosure b)Defined in ghc-internal-10.0.0 · GHC.Internal.Heap.Closures
  • Generic (Maybe a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (TyVarBndr flag)Defined in ghc-internal-10.0.0 · GHC.Internal.TH.Syntax
  • Generic (Doc a)Defined in pretty-1.1.3.6 · Text.PrettyPrint.Annotated.HughesPJ
  • Generic (Window a)Defined in terminal-size-0.3.4 · System.Console.Terminal.Common
  • Generic (Doc a)Defined in wl-pprint-annotated-0.1.0.2 · Text.PrettyPrint.Annotated.WL
  • Generic (SimpleDoc a)Defined in wl-pprint-annotated-0.1.0.2 · Text.PrettyPrint.Annotated.WL
  • Generic (a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic [a]Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Container b a)Defined in barbies-2.1.1.0 · Barbies.Internal.Containers
  • Generic (ErrorContainer b e)Defined in barbies-2.1.1.0 · Barbies.Internal.Containers
  • Generic (Unit f)Defined in barbies-2.1.1.0 · Barbies.Internal.Trivial
  • Generic (Void f)Defined in barbies-2.1.1.0 · Barbies.Internal.Trivial
  • Generic (WrappedMonad m a)Defined in base-4.23.0.0 · Control.Applicative
  • Generic (Arg a b)Defined in base-4.23.0.0 · Data.Semigroup
  • Generic (Either a b)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Proxy t)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (U1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (V1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Lift f a)Defined in transformers-0.6.3.0 · Control.Applicative.Lift
  • Generic (MaybeT m a)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Maybe
  • Generic (a, b)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (WrappedArrow a b c)Defined in base-4.23.0.0 · Control.Applicative
  • Generic (Kleisli m a b)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Arrow
  • Generic (Const a b)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Ap f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Alt f a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Rec1 f p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (URec Char p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (URec Double p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (URec Float p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (URec Int p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (URec Word p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (URec (Ptr ()) p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Tagged s b)Defined in tagged-0.8.11 · Data.Tagged
  • Generic (Backwards f a)Defined in transformers-0.6.3.0 · Control.Applicative.Backwards
  • Generic (AccumT w m a)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Accum
  • Generic (ExceptT e m a)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Except
  • Generic (IdentityT f a)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Identity
  • Generic (ReaderT r m a)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Reader
  • Generic (SelectT r m a)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Select
  • Generic (StateT s m a)Defined in transformers-0.6.3.0 · Control.Monad.Trans.State.Lazy
  • Generic (StateT s m a)Defined in transformers-0.6.3.0 · Control.Monad.Trans.State.Strict
  • Generic (WriterT w m a)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Writer.CPS
  • Generic (WriterT w m a)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Writer.Lazy
  • Generic (WriterT w m a)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Writer.Strict
  • Generic (Constant a b)Defined in transformers-0.6.3.0 · Data.Functor.Constant
  • Generic (Reverse f a)Defined in transformers-0.6.3.0 · Data.Functor.Reverse
  • Generic (a, b, c)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Product f g a)Defined in base-4.23.0.0 · Data.Functor.Product
  • Generic (Sum f g a)Defined in base-4.23.0.0 · Data.Functor.Sum
  • Generic (K1 i c p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (ContT r m a)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Cont
  • Generic ((:*:) f g p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic ((:+:) f g p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (a, b, c, d)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Compose f g a)Defined in base-4.23.0.0 · Data.Functor.Compose
  • Generic (M1 i c f p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (RWST r w s m a)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.CPS
  • Generic (RWST r w s m a)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.Lazy
  • Generic (RWST r w s m a)Defined in transformers-0.6.3.0 · Control.Monad.Trans.RWS.Strict
  • Generic ((:.:) f g p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e, f)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e, f, g)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e, f, g, h)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e, f, g, h, i)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e, f, g, h, i, j)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e, f, g, h, i, j, k)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e, f, g, h, i, j, k, l)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e, f, g, h, i, j, k, l, m)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
classclass Generic1 (f :: k -> Type) where
#

Representable types of kind * -> * (or kind k -> *, when PolyKinds is enabled). This class is derivable in GHC with the DeriveGeneric flag on.

A Generic1 instance must satisfy the following laws:

from1 . to1 ≡ Prelude.id
to1 . from1 ≡ Prelude.id

Associated types

  • type family Rep1 (f :: k -> Type) :: k -> Type

    Generic representation type

Methods

  • from1 :: f a -> Rep1 f a

    Convert from the datatype to its representation

  • to1 :: Rep1 f a -> f a

    Convert from the representation to the datatype

Instances78Generic1, …
  • Generic1 ComplexDefined in base-4.23.0.0 · Data.Complex
  • Generic1 FirstDefined in base-4.23.0.0 · Data.Semigroup
  • Generic1 LastDefined in base-4.23.0.0 · Data.Semigroup
  • Generic1 MaxDefined in base-4.23.0.0 · Data.Semigroup
  • Generic1 MinDefined in base-4.23.0.0 · Data.Semigroup
  • Generic1 WrappedMonoidDefined in base-4.23.0.0 · Data.Semigroup
  • Generic1 SCCDefined in containers-0.8 · Data.Graph
  • Generic1 DigitDefined in containers-0.8 · Data.Sequence.Internal
  • Generic1 ElemDefined in containers-0.8 · Data.Sequence.Internal
  • Generic1 FingerTreeDefined in containers-0.8 · Data.Sequence.Internal
  • Generic1 NodeDefined in containers-0.8 · Data.Sequence.Internal
  • Generic1 ViewLDefined in containers-0.8 · Data.Sequence.Internal
  • Generic1 ViewRDefined in containers-0.8 · Data.Sequence.Internal
  • Generic1 PostOrderDefined in containers-0.8 · Data.Tree
  • Generic1 TreeDefined in containers-0.8 · Data.Tree
  • Generic1 NonEmptyDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 IdentityDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 FirstDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 LastDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 DownDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 DualDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 ProductDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 SumDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 ZipListDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 Par1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 MaybeDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 SoloDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 WindowDefined in terminal-size-0.3.4 · System.Console.Terminal.Common
  • Generic1 []Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Functor m => Generic1 (MaybeT m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Maybe
  • Generic1 ProxyDefined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 U1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 V1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (WrappedMonad m)Defined in base-4.23.0.0 · Control.Applicative
  • Generic1 (Arg a)Defined in base-4.23.0.0 · Data.Semigroup
  • Generic1 (Either a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Tuple2 a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Lift f)Defined in transformers-0.6.3.0 · Control.Applicative.Lift
  • Functor m => Generic1 (ExceptT e m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Except
  • Generic1 (WrappedArrow a b)Defined in base-4.23.0.0 · Control.Applicative
  • Generic1 (Kleisli m a)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Arrow
  • Generic1 (Const a)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Ap f)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Alt f)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Rec1 f)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (URec Char)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (URec Double)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (URec Float)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (URec Int)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (URec Word)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (URec (Ptr ()))Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Tuple3 a b)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Tagged s)Defined in tagged-0.8.11 · Data.Tagged
  • Generic1 (Backwards f)Defined in transformers-0.6.3.0 · Control.Applicative.Backwards
  • Generic1 (IdentityT f)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Identity
  • Generic1 (ReaderT r m)Defined in transformers-0.6.3.0 · Control.Monad.Trans.Reader
  • Generic1 (Constant a)Defined in transformers-0.6.3.0 · Data.Functor.Constant
  • Generic1 (Reverse f)Defined in transformers-0.6.3.0 · Data.Functor.Reverse
  • Generic1 (Product f g)Defined in base-4.23.0.0 · Data.Functor.Product
  • Generic1 (Sum f g)Defined in base-4.23.0.0 · Data.Functor.Sum
  • Generic1 (K1 i c)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Tuple4 a b c)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (f :*: g)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (f :+: g)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Functor f => Generic1 (Compose f g)Defined in base-4.23.0.0 · Data.Functor.Compose
  • Functor f => Generic1 (f :.: g)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (M1 i c f)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Tuple5 a b c d)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Tuple6 a b c d e)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Tuple7 a b c d e f)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Tuple8 a b c d e f g)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Tuple9 a b c d e f g h)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Tuple10 a b c d e f g h i)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Tuple11 a b c d e f g h i j)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Tuple12 a b c d e f g h i j k)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Tuple13 a b c d e f g h i j k l)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Tuple14 a b c d e f g h i j k l m)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic1 (Tuple15 a b c d e f g h i j k l m n)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
newtypenewtype Generically a
#

A datatype whose instances are defined generically, using the Generic representation. Generically1 is a higher-kinded version of Generically that uses Generic1.

Generic instances can be derived via Generically A using -XDerivingVia.

{-# LANGUAGE DeriveGeneric      #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DerivingVia        #-}

import GHC.Generics (Generic)

data V4 a = V4 a a a a
  deriving stock Generic

  deriving (Semigroup, Monoid)
  via Generically (V4 a)

This corresponds to Semigroup and Monoid instances defined by pointwise lifting:

instance Semigroup a => Semigroup (V4 a) where
  (<>) :: V4 a -> V4 a -> V4 a
  V4 a1 b1 c1 d1 <> V4 a2 b2 c2 d2 =
    V4 (a1 <> a2) (b1 <> b2) (c1 <> c2) (d1 <> d2)

instance Monoid a => Monoid (V4 a) where
  mempty :: V4 a
  mempty = V4 mempty mempty mempty mempty

Historically this required modifying the type class to include generic method definitions (-XDefaultSignatures) and deriving it with the anyclass strategy (-XDeriveAnyClass). Having a /via type/ like Generically decouples the instance from the type class.

Constructors

Instances2Semigroup, Monoid
newtypenewtype Generically1 (f :: k -> Type) (a :: k) where
#

A type whose instances are defined generically, using the Generic1 representation. Generically1 is a higher-kinded version of Generically that uses Generic.

Generic instances can be derived for type constructors via Generically1 F using -XDerivingVia.

{-# LANGUAGE DeriveGeneric      #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE DerivingVia        #-}

import GHC.Generics (Generic)

data V4 a = V4 a a a a
  deriving stock (Functor, Generic1)

  deriving Applicative
  via Generically1 V4

This corresponds to Applicative instances defined by pointwise lifting:

instance Applicative V4 where
  pure :: a -> V4 a
  pure a = V4 a a a a

  liftA2 :: (a -> b -> c) -> (V4 a -> V4 b -> V4 c)
  liftA2 (·) (V4 a1 b1 c1 d1) (V4 a2 b2 c2 d2) =
    V4 (a1 · a2) (b1 · b2) (c1 · c2) (d1 · d2)

Historically this required modifying the type class to include generic method definitions (-XDefaultSignatures) and deriving it with the anyclass strategy (-XDeriveAnyClass). Having a /via type/ like Generically1 decouples the instance from the type class.

Constructors

Instances7Functor, Applicative, Alternative, Eq1, Ord1, Eq, …
newtypenewtype K1 i c (p :: k)
#

Constants, additional parameters and recursion of kind *

Constructors

Instances50GDeciding, Generic1, GNFData, GBinaryGet, GBinaryPut, GHashable, …
  • q p => GDeciding q (K1 i p)Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
  • Generic1 (K1 i c)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • NFData a => GNFData arity (K1 i a)Defined in deepseq-1.5.2.0 · Control.DeepSeq
  • Binary a => GBinaryGet (K1 i a)Defined in binary-0.8.9.3 · Data.Binary.Generic · orphan
  • Binary a => GBinaryPut (K1 i a)Defined in binary-0.8.9.3 · Data.Binary.Generic · orphan
  • Hashable a => GHashable arity (K1 i a)Defined in hashable-1.5.1.0 · Data.Hashable.Generic.Instances · orphan
  • q p => GDeciding1 q (K1 i p)Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
  • Eq c => GEq1 v (K1 i c)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Ord c => GOrd1 v (K1 i c)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Read c => GRead1Con v (K1 i c)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Show c => GShow1Con v (K1 i c)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Bifoldable (K1 i)Defined in base-4.23.0.0 · Data.Bifoldable
  • Bifunctor (K1 i)Defined in base-4.23.0.0 · Data.Bifunctor
  • Bitraversable (K1 i)Defined in base-4.23.0.0 · Data.Bitraversable
  • Functor (K1 i c)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Monoid c => Applicative (K1 i c)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Foldable (K1 i c)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Traversable (K1 i c)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Eq c => Eq1 (K1 i c)Defined in base-4.23.0.0 · Data.Functor.Classes
  • Ord c => Ord1 (K1 i c)Defined in base-4.23.0.0 · Data.Functor.Classes
  • Read c => Read1 (K1 i c)Defined in base-4.23.0.0 · Data.Functor.Classes
  • Show c => Show1 (K1 i c)Defined in base-4.23.0.0 · Data.Functor.Classes
  • Contravariant (K1 i c)Defined in base-4.23.0.0 · Data.Functor.Contravariant
  • Uniform a => GUniform (K1 i a)Defined in random-1.3.1 · System.Random.Internal
  • UniformRange a => GUniformRange (K1 i a)Defined in random-1.3.1 · System.Random.Internal
  • Finite a => GFinite (K1 _x a)Defined in random-1.3.1 · System.Random.GFinite
  • GG (K1 i c)Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
  • IsNullaryCon (K1 i c)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Absurd c => GAbsurd (K1 i c)Defined in boring-0.2.2.1 · Data.Boring
  • Boring c => GBoring (K1 i c)Defined in boring-0.2.2.1 · Data.Boring
  • PrettyVal a => GDump (K1 t a)Defined in pretty-show-1.10 · Text.Show.PrettyVal
  • Arg b => GArg (K1 a b)Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Vary b => GVary (K1 a b)Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Eq c => Eq (K1 i c p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • (Typeable i, Data p, Data c) => Data (K1 i c p)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Data
  • Ord c => Ord (K1 i c p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Read c => Read (K1 i c p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Show c => Show (K1 i c p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (K1 i c p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Semigroup c => Semigroup (K1 i c p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Monoid c => Monoid (K1 i c p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Eq c => GEq (K1 i c p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Ord c => GOrd (K1 i c p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Read c => GReadCon (K1 i c p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Show c => GShowCon (K1 i c p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Absurd c => Absurd (K1 i c p)Defined in boring-0.2.2.1 · Data.Boring
  • Boring c => Boring (K1 i c p)Defined in boring-0.2.2.1 · Data.Boring
  • type Rep (K1 i c p) = D1 ('MetaData "K1" "GHC.Internal.Generics" "ghc-internal" 'True) (C1 ('MetaCons "K1" 'PrefixI 'True) (S1 ('MetaSel ('Just "unK1") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 c)))Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • type Rep1 (K1 i c) = D1 ('MetaData "K1" "GHC.Internal.Generics" "ghc-internal" 'True) (C1 ('MetaCons "K1" 'PrefixI 'True) (S1 ('MetaSel ('Just "unK1") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 c)))Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • type Swizzle (K1 i c) = K1 i cDefined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
newtypenewtype M1 i (c :: Meta) (f :: k -> Type) (p :: k)
#

Meta-information (constructor names, etc.)

Constructors

Instances61GTraversable, GApplicative, GConstraints, GFunctor, GDeciding, GBare, …
  • GTraversable n f g bf bg => GTraversable n f g (M1 i c bf) (M1 i c bg)Defined in barbies-2.1.1.0 · Barbies.Generics.Traversable
  • GApplicative n f g repf repg repfg => GApplicative n f g (M1 i c repf) (M1 i c repg) (M1 i c repfg)Defined in barbies-2.1.1.0 · Barbies.Generics.Applicative
  • GConstraints n c f repbx repbf repbdf => GConstraints n c f (M1 i k4 repbx) (M1 i k4 repbf) (M1 i k4 repbdf)Defined in barbies-2.1.1.0 · Barbies.Generics.Constraints
  • GFunctor n f g bf bg => GFunctor n f g (M1 i c bf) (M1 i c bg)Defined in barbies-2.1.1.0 · Barbies.Generics.Functor
  • GDistributive n f bg bfg => GDistributive n f (M1 i c bg) (M1 i c bfg)Defined in barbies-2.1.1.0 · Barbies.Generics.Distributive
  • GDeciding q f => GDeciding q (M1 i c f)Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
  • GBare n repbi repbb => GBare n (M1 i k2 repbi) (M1 i k2 repbb)Defined in barbies-2.1.1.0 · Barbies.Generics.Bare
  • Generic1 (M1 i c f)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • GNFData arity a => GNFData arity (M1 i c a)Defined in deepseq-1.5.2.0 · Control.DeepSeq
  • GBinaryGet a => GBinaryGet (M1 i c a)Defined in binary-0.8.9.3 · Data.Binary.Generic · orphan
  • GBinaryPut a => GBinaryPut (M1 i c a)Defined in binary-0.8.9.3 · Data.Binary.Generic · orphan
  • GHashable arity a => GHashable arity (M1 i c a)Defined in hashable-1.5.1.0 · Data.Hashable.Generic.Instances · orphan
  • GDeciding1 q f => GDeciding1 q (M1 i c f)Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
  • GEq1 v f => GEq1 v (M1 i c f)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd1 v f => GOrd1 v (M1 i c f)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Monad f => Monad (M1 i c f)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Functor f => Functor (M1 i c f)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • MonadFix f => MonadFix (M1 i c f)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.Fix
  • Applicative f => Applicative (M1 i c f)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Foldable f => Foldable (M1 i c f)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Traversable f => Traversable (M1 i c f)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Alternative f => Alternative (M1 i c f)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • MonadPlus f => MonadPlus (M1 i c f)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • MonadZip f => MonadZip (M1 i c f)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.Zip
  • Foldable1 f => Foldable1 (M1 i c f)Defined in base-4.23.0.0 · Data.Foldable1
  • Eq1 f => Eq1 (M1 i c f)Defined in base-4.23.0.0 · Data.Functor.Classes
  • Ord1 f => Ord1 (M1 i c f)Defined in base-4.23.0.0 · Data.Functor.Classes
  • Read1 f => Read1 (M1 i c f)Defined in base-4.23.0.0 · Data.Functor.Classes
  • Show1 f => Show1 (M1 i c f)Defined in base-4.23.0.0 · Data.Functor.Classes
  • Contravariant f => Contravariant (M1 i c f)Defined in base-4.23.0.0 · Data.Functor.Contravariant
  • GUniform f => GUniform (M1 i c f)Defined in random-1.3.1 · System.Random.Internal
  • GUniformRange f => GUniformRange (M1 i c f)Defined in random-1.3.1 · System.Random.Internal
  • GFinite a => GFinite (M1 _x _y a)Defined in random-1.3.1 · System.Random.GFinite
  • Distributive f => Distributive (M1 i c f)Defined in distributive-0.6.3 · Data.Distributive
  • GDistributive f => GDistributive (M1 i c f)Defined in distributive-0.6.3 · Data.Distributive.Generic
  • Decidable f => Decidable (M1 i c f)Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Divisible
  • Divisible f => Divisible (M1 i c f)Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Divisible
  • GG f => GG (M1 i c f)Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
  • GAbsurd f => GAbsurd (M1 i c f)Defined in boring-0.2.2.1 · Data.Boring
  • GBoring f => GBoring (M1 i c f)Defined in boring-0.2.2.1 · Data.Boring
  • (GDump f, Constructor c) => GDump (M1 C c f)Defined in pretty-show-1.10 · Text.Show.PrettyVal
  • (GDump f, Datatype d) => GDump (M1 D d f)Defined in pretty-show-1.10 · Text.Show.PrettyVal
  • (GDump f, Selector s) => GDump (M1 S s f)Defined in pretty-show-1.10 · Text.Show.PrettyVal
  • GArg c => GArg (M1 a b c)Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • GVary c => GVary (M1 a b c)Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Eq (f p) => Eq (M1 i c f p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • (Data p, Data (f p), Typeable c, Typeable i, Typeable f) => Data (M1 i c f p)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Data
  • Ord (f p) => Ord (M1 i c f p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Read (f p) => Read (M1 i c f p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Show (f p) => Show (M1 i c f p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (M1 i c f p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Semigroup (f p) => Semigroup (M1 i c f p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Monoid (f p) => Monoid (M1 i c f p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • GEq (f p) => GEq (M1 i c f p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd (f p) => GOrd (M1 i c f p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Absurd (f p) => Absurd (M1 i c f p)Defined in boring-0.2.2.1 · Data.Boring
  • Boring (f p) => Boring (M1 i c f p)Defined in boring-0.2.2.1 · Data.Boring
  • type Rep (M1 i c f p) = D1 ('MetaData "M1" "GHC.Internal.Generics" "ghc-internal" 'True) (C1 ('MetaCons "M1" 'PrefixI 'True) (S1 ('MetaSel ('Just "unM1") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (f p))))Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • type Rep1 (M1 i c f) = D1 ('MetaData "M1" "GHC.Internal.Generics" "ghc-internal" 'True) (C1 ('MetaCons "M1" 'PrefixI 'True) (S1 ('MetaSel ('Just "unM1") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 f)))Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • type Swizzle (M1 i c f) = M1 i c (Swizzle f)Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
  • type GAll n c (M1 i k2 repbf) = GAll n c repbfDefined in barbies-2.1.1.0 · Barbies.Generics.Constraints
datadata Meta
#

Datatype to represent metadata associated with a datatype (MetaData), constructor (MetaCons), or field selector (MetaSel).

  • In MetaData n m p nt, n is the datatype's name, m is the module in which the datatype is defined, p is the package in which the datatype is defined, and nt is 'True if the datatype is a newtype.

  • In MetaCons n f s, n is the constructor's name, f is its fixity, and s is 'True if the constructor contains record selectors.

  • In MetaSel mn su ss ds, if the field uses record syntax, then mn is Just the record name. Otherwise, mn is Nothing. su and ss are the field's unpackedness and strictness annotations, and ds is the strictness that GHC infers for the field.

Instances3Constructor, Datatype, Selector
newtypenewtype Par1 p
#

Used for marking occurrences of the parameter

Constructors

Instances41Monad, Functor, MonadFix, Applicative, Foldable, Traversable, …
  • Monad Par1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Functor Par1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • MonadFix Par1Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.Fix
  • Applicative Par1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Foldable Par1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Traversable Par1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • MonadZip Par1Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.Zip
  • Foldable1 Par1Defined in base-4.23.0.0 · Data.Foldable1
  • Eq1 Par1Defined in base-4.23.0.0 · Data.Functor.Classes
  • Ord1 Par1Defined in base-4.23.0.0 · Data.Functor.Classes
  • Read1 Par1Defined in base-4.23.0.0 · Data.Functor.Classes
  • Show1 Par1Defined in base-4.23.0.0 · Data.Functor.Classes
  • Distributive Par1Defined in distributive-0.6.3 · Data.Distributive
  • GDistributive Par1Defined in distributive-0.6.3 · Data.Distributive.Generic
  • GG Par1Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
  • IsNullaryCon Par1Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Generic1 Par1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • GNFData One Par1Defined in deepseq-1.5.2.0 · Control.DeepSeq
  • GHashable One Par1Defined in hashable-1.5.1.0 · Data.Hashable.Generic.Instances · orphan
  • GDeciding1 q Par1Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
  • GEq1 NonV4 Par1Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd1 NonV4 Par1Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GRead1Con NonV4 Par1Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GShow1Con NonV4 Par1Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Eq p => Eq (Par1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Data p => Data (Par1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Data
  • Ord p => Ord (Par1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Read p => Read (Par1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Show p => Show (Par1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (Par1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Semigroup p => Semigroup (Par1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Monoid p => Monoid (Par1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Eq p => GEq (Par1 p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Ord p => GOrd (Par1 p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Read p => GReadCon (Par1 p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Show p => GShowCon (Par1 p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Absurd p => Absurd (Par1 p)Defined in boring-0.2.2.1 · Data.Boring
  • Boring p => Boring (Par1 p)Defined in boring-0.2.2.1 · Data.Boring
  • type Rep (Par1 p) = D1 ('MetaData "Par1" "GHC.Internal.Generics" "ghc-internal" 'True) (C1 ('MetaCons "Par1" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPar1") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 p)))Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • type Rep1 Par1 = D1 ('MetaData "Par1" "GHC.Internal.Generics" "ghc-internal" 'True) (C1 ('MetaCons "Par1" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPar1") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • type Swizzle Par1 = Par1Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
datadata R
#

Tag for K1: recursion (of kind Type)

typetype Rec0 = K1 R
#

Type synonym for encoding recursion (of kind Type)

newtypenewtype Rec1 (f :: k -> Type) (p :: k)
#

Recursive calls of kind * -> * (or kind k -> *, when PolyKinds is enabled)

Constructors

Instances46Generic1, GNFData, GHashable, GDeciding1, GEq1, GOrd1, …
familytype family Rep a :: Type -> Type
#

Generic representation type

Instances245Rep, …
familytype family Rep1 (f :: k -> Type) :: k -> Type
#

Generic representation type

Instances78Rep1, …
datadata S
#

Tag for M1: record selector

Instances1GDump
  • (GDump f, Selector s) => GDump (M1 S s f)Defined in pretty-show-1.10 · Text.Show.PrettyVal
typetype S1 = M1 S
#

Type synonym for encoding meta-information for record selectors

Instances5GRead1Con, GShow1Con, IsNullaryCon, GReadCon, GShowCon
  • (Selector s, GRead1Con v f) => GRead1Con v (S1 s f)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • (Selector s, GShow1Con v f) => GShow1Con v (S1 s f)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • IsNullaryCon f => IsNullaryCon (S1 s f)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • (Selector s, GReadCon (f p)) => GReadCon (S1 s f p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • (Selector s, GShowCon (f p)) => GShowCon (S1 s f p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
classclass Selector (s :: k) where
#

Class for datatypes that represent records

Methods

Instances1Selector
  • (SingI mn, SingI su, SingI ss, SingI ds) => Selector ('MetaSel mn su ss ds)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
datadata SourceStrictness
#

The strictness of a field as the user wrote it in the source code. For example, in the following data type:

data E = ExampleConstructor Int ~Int !Int

The fields of ExampleConstructor have NoSourceStrictness, SourceLazy, and SourceStrict, respectively.

Instances16Bounded, Enum, Eq, Data, Ord, Read, …
datadata SourceUnpackedness
#

The unpackedness of a field as the user wrote it in the source code. For example, in the following data type:

data E = ExampleConstructor     Int
           {-# NOUNPACK #-} Int
           {-#   UNPACK #-} Int

The fields of ExampleConstructor have NoSourceUnpackedness, SourceNoUnpack, and SourceUnpack, respectively.

Instances16Bounded, Enum, Eq, Data, Ord, Read, …
datadata U1 (p :: k)
#

Unit: used for constructors without arguments

Instances60GTraversable, GApplicative, GConstraints, GFunctor, GDeciding, GBare, …
  • GTraversable n f g U1 U1Defined in barbies-2.1.1.0 · Barbies.Generics.Traversable
  • GApplicative n f g U1 U1 U1Defined in barbies-2.1.1.0 · Barbies.Generics.Applicative
  • GConstraints n c f U1 U1 U1Defined in barbies-2.1.1.0 · Barbies.Generics.Constraints
  • GFunctor n f g U1 U1Defined in barbies-2.1.1.0 · Barbies.Generics.Functor
  • Functor f => GDistributive n f U1 U1Defined in barbies-2.1.1.0 · Barbies.Generics.Distributive
  • GDeciding q U1Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
  • GBare n U1 U1Defined in barbies-2.1.1.0 · Barbies.Generics.Bare
  • Generic1 U1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • GNFData arity U1Defined in deepseq-1.5.2.0 · Control.DeepSeq
  • GBinaryGet U1Defined in binary-0.8.9.3 · Data.Binary.Generic · orphan
  • GBinaryPut U1Defined in binary-0.8.9.3 · Data.Binary.Generic · orphan
  • GHashable arity U1Defined in hashable-1.5.1.0 · Data.Hashable.Generic.Instances · orphan
  • GDeciding1 q U1Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
  • GEq1 v U1Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd1 v U1Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GRead1Con v U1Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GShow1Con v U1Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Monad U1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Functor U1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Applicative U1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Foldable U1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Traversable U1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Alternative U1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • MonadPlus U1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • MonadZip U1Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.Zip
  • Eq1 U1Defined in base-4.23.0.0 · Data.Functor.Classes
  • Ord1 U1Defined in base-4.23.0.0 · Data.Functor.Classes
  • Read1 U1Defined in base-4.23.0.0 · Data.Functor.Classes
  • Show1 U1Defined in base-4.23.0.0 · Data.Functor.Classes
  • Contravariant U1Defined in base-4.23.0.0 · Data.Functor.Contravariant
  • GUniform U1Defined in random-1.3.1 · System.Random.Internal
  • GUniformRange U1Defined in random-1.3.1 · System.Random.Internal
  • GFinite U1Defined in random-1.3.1 · System.Random.GFinite
  • Distributive U1Defined in distributive-0.6.3 · Data.Distributive
  • GDistributive U1Defined in distributive-0.6.3 · Data.Distributive.Generic
  • Decidable U1Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Divisible
  • Divisible U1Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Divisible
  • GG U1Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
  • IsNullaryCon U1Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GBoring U1Defined in boring-0.2.2.1 · Data.Boring
  • GDump U1Defined in pretty-show-1.10 · Text.Show.PrettyVal
  • GArg U1Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • GVary U1Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Eq (U1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Data p => Data (U1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Data
  • Ord (U1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Read (U1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Show (U1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (U1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Semigroup (U1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Monoid (U1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • GEq (U1 p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd (U1 p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GReadCon (U1 p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GShowCon (U1 p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Boring (U1 p)Defined in boring-0.2.2.1 · Data.Boring
  • type Rep (U1 p) = D1 ('MetaData "U1" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "U1" 'PrefixI 'False) U1)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • type Rep1 U1 = D1 ('MetaData "U1" "GHC.Internal.Generics" "ghc-internal" 'False) (C1 ('MetaCons "U1" 'PrefixI 'False) U1)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • type Swizzle U1 = U1Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
  • type GAll n c U1 = ()Defined in barbies-2.1.1.0 · Barbies.Generics.Constraints
typetype UAddr = URec (Ptr ())
#

Type synonym for URec Addr#

Instances7GEq1, GOrd1, Eq1, Ord1, Show1, GEq, …
  • GEq1 v UAddrDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd1 v UAddrDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Eq1 UAddrDefined in base-4.23.0.0 · Data.Functor.Classes
  • Ord1 UAddrDefined in base-4.23.0.0 · Data.Functor.Classes
  • Show1 UAddrDefined in base-4.23.0.0 · Data.Functor.Classes
  • GEq (UAddr p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd (UAddr p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
typetype UChar = URec Char
#

Type synonym for URec Char#

Instances10GEq1, GOrd1, GShow1Con, Eq1, Ord1, Show1, …
  • GEq1 v UCharDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd1 v UCharDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GShow1Con v UCharDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Eq1 UCharDefined in base-4.23.0.0 · Data.Functor.Classes
  • Ord1 UCharDefined in base-4.23.0.0 · Data.Functor.Classes
  • Show1 UCharDefined in base-4.23.0.0 · Data.Functor.Classes
  • IsNullaryCon UCharDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GEq (UChar p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd (UChar p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GShowCon (UChar p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
typetype UDouble = URec Double
#

Type synonym for URec Double#

Instances10GEq1, GOrd1, GShow1Con, Eq1, Ord1, Show1, …
  • GEq1 v UDoubleDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd1 v UDoubleDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GShow1Con v UDoubleDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Eq1 UDoubleDefined in base-4.23.0.0 · Data.Functor.Classes
  • Ord1 UDoubleDefined in base-4.23.0.0 · Data.Functor.Classes
  • Show1 UDoubleDefined in base-4.23.0.0 · Data.Functor.Classes
  • IsNullaryCon UDoubleDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GEq (UDouble p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd (UDouble p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GShowCon (UDouble p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
typetype UFloat = URec Float
#

Type synonym for URec Float#

Instances10GEq1, GOrd1, GShow1Con, Eq1, Ord1, Show1, …
  • GEq1 v UFloatDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd1 v UFloatDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GShow1Con v UFloatDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Eq1 UFloatDefined in base-4.23.0.0 · Data.Functor.Classes
  • Ord1 UFloatDefined in base-4.23.0.0 · Data.Functor.Classes
  • Show1 UFloatDefined in base-4.23.0.0 · Data.Functor.Classes
  • IsNullaryCon UFloatDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GEq (UFloat p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd (UFloat p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GShowCon (UFloat p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
typetype UInt = URec Int
#

Type synonym for URec Int#

Instances10GEq1, GOrd1, GShow1Con, Eq1, Ord1, Show1, …
  • GEq1 v UIntDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd1 v UIntDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GShow1Con v UIntDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Eq1 UIntDefined in base-4.23.0.0 · Data.Functor.Classes
  • Ord1 UIntDefined in base-4.23.0.0 · Data.Functor.Classes
  • Show1 UIntDefined in base-4.23.0.0 · Data.Functor.Classes
  • IsNullaryCon UIntDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GEq (UInt p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd (UInt p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GShowCon (UInt p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
data familydata family URec a (p :: k)
#

Constants of unlifted kinds

Instances67Generic1, GNFData, Foldable, Traversable, Functor, Eq, …
typetype UWord = URec Word
#

Type synonym for URec Word#

Instances10GEq1, GOrd1, GShow1Con, Eq1, Ord1, Show1, …
  • GEq1 v UWordDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd1 v UWordDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GShow1Con v UWordDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Eq1 UWordDefined in base-4.23.0.0 · Data.Functor.Classes
  • Ord1 UWordDefined in base-4.23.0.0 · Data.Functor.Classes
  • Show1 UWordDefined in base-4.23.0.0 · Data.Functor.Classes
  • IsNullaryCon UWordDefined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GEq (UWord p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd (UWord p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GShowCon (UWord p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
datadata V1 (p :: k)
#

Void: used for datatypes without constructors

Instances46GTraversable, GConstraints, GFunctor, GDeciding, GBare, Generic1, …
  • GTraversable n f g V1 V1Defined in barbies-2.1.1.0 · Barbies.Generics.Traversable
  • GConstraints n c f V1 V1 V1Defined in barbies-2.1.1.0 · Barbies.Generics.Constraints
  • GFunctor n f g V1 V1Defined in barbies-2.1.1.0 · Barbies.Generics.Functor
  • GDeciding q V1Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
  • GBare n V1 V1Defined in barbies-2.1.1.0 · Barbies.Generics.Bare
  • Generic1 V1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • GNFData arity V1Defined in deepseq-1.5.2.0 · Control.DeepSeq
  • GBinaryGet V1Defined in binary-0.8.9.3 · Data.Binary.Generic · orphan
  • GBinaryPut V1Defined in binary-0.8.9.3 · Data.Binary.Generic · orphan
  • GHashable arity V1Defined in hashable-1.5.1.0 · Data.Hashable.Generic.Instances · orphan
  • GDeciding1 q V1Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
  • GEq1 v V1Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd1 v V1Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GRead1 v V1Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GShow1 v V1Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Functor V1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Foldable V1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Traversable V1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Foldable1 V1Defined in base-4.23.0.0 · Data.Foldable1
  • Eq1 V1Defined in base-4.23.0.0 · Data.Functor.Classes
  • Ord1 V1Defined in base-4.23.0.0 · Data.Functor.Classes
  • Read1 V1Defined in base-4.23.0.0 · Data.Functor.Classes
  • Show1 V1Defined in base-4.23.0.0 · Data.Functor.Classes
  • Contravariant V1Defined in base-4.23.0.0 · Data.Functor.Contravariant
  • GFinite V1Defined in random-1.3.1 · System.Random.GFinite
  • GG V1Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
  • IsNullaryDataType V1Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GAbsurd V1Defined in boring-0.2.2.1 · Data.Boring
  • GArg V1Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • GVary V1Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Eq (V1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Data p => Data (V1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Data.Data
  • Ord (V1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Read (V1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Show (V1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Generic (V1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • Semigroup (V1 p)Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • GEq (V1 p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GOrd (V1 p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GRead (V1 p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • GShow (V1 p)Defined in transformers-compat-0.7.2 · Data.Functor.Classes.Generic.Internal
  • Absurd (V1 p)Defined in boring-0.2.2.1 · Data.Boring
  • type Rep (V1 p) = D1 ('MetaData "V1" "GHC.Internal.Generics" "ghc-internal" 'False) V1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • type Rep1 V1 = D1 ('MetaData "V1" "GHC.Internal.Generics" "ghc-internal" 'False) V1Defined in ghc-internal-10.0.0 · GHC.Internal.Generics
  • type Swizzle V1 = V1Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Generic
  • type GAll n c V1 = ()Defined in barbies-2.1.1.0 · Barbies.Generics.Constraints
datadata Fn a b
#

The type of randomly-generated functions

Instances1Show
  • (Show a, Show b) => Show (Fn a b)Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal

Generation

4 declarations
valueapply :: Fn a b -> a -> b
#

Evaluate an Fn

valuefnWith :: Arg a => CoGen a -> Gen b -> Gen (Fn a b)
#

Generate a function using the user-supplied co-generator

Building

4 declarations
valuevia :: Arg b => (a -> b) -> (b -> a) -> (a -> c) -> a :-> c
#

Reify a function via an isomorphism.

If your function's domain has no instance of Generic then you can still reify it using an isomorphism to a better domain type. For example, the Arg instance for Integral uses an isomorphism from Integral a => a to (Bool, [Bool]), where the first element is the sign, and the second element is the bit-string.

Note: via f g will only be well-behaved if g . f = id and f . g = id

classclass Arg a where
#

instance Arg A where allows functions which take As to be reified

Methods

Instances14Arg, …
  • Arg VoidDefined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Arg IntegerDefined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Arg Int16Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Arg Int32Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Arg Int64Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Arg Int8Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Arg BoolDefined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Arg IntDefined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Arg OrderingDefined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Arg ()Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Arg a => Arg (Maybe a)Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Arg a => Arg [a]Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • (Arg a, Arg b) => Arg (Either a b)Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • (Arg a, Arg b) => Arg (a, b)Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal

Varying

24 declarations
value($<) :: Contravariant f => f b -> b -> f a
#

This is >$ with its arguments flipped.

valuephantom :: (Functor f, Contravariant f) => f a -> f b
#

If f is both Functor and Contravariant then by the time you factor in the laws of each of those classes, it can't actually use its argument in any meaningful capacity.

This method is surprisingly useful. Where both instances exist and are lawful we have the following laws:

fmap      f ≡ phantom
contramap f ≡ phantom
newtypenewtype Comparison a
#

Defines a total ordering on a type as per compare.

This condition is not checked by the types. You must ensure that the supplied values are valid total orderings yourself.

Constructors

Instances5Contravariant, Decidable, Divisible, Semigroup, Monoid
  • Contravariant ComparisonDefined in base-4.23.0.0 · Data.Functor.Contravariant

    A Comparison is a Contravariant Functor, because contramap can apply its function argument to each input of the comparison function.

  • Decidable ComparisonDefined in contravariant-1.5.6 · Data.Functor.Contravariant.Divisible
  • Divisible ComparisonDefined in contravariant-1.5.6 · Data.Functor.Contravariant.Divisible
  • Semigroup (Comparison a)Defined in base-4.23.0.0 · Data.Functor.Contravariant

    (<>) on comparisons combines results with (<>) @Ordering. Without newtypes this equals liftA2 (liftA2 (<>)).

    (<>) :: Comparison a -> Comparison a -> Comparison a
    Comparison cmp <> Comparison cmp' = Comparison a a' ->
      cmp a a' <> cmp a a'
    
  • Monoid (Comparison a)Defined in base-4.23.0.0 · Data.Functor.Contravariant

    mempty on comparisons always returns EQ. Without newtypes this equals pure (pure EQ).

    mempty :: Comparison a
    mempty = Comparison _ _ -> EQ
    
classclass Contravariant (f :: Type -> Type) where
#

The class of contravariant functors.

Whereas in Haskell, one can think of a Functor as containing or producing values, a contravariant functor is a functor that can be thought of as consuming values.

As an example, consider the type of predicate functions a -> Bool. One such predicate might be negative x = x < 0, which classifies integers as to whether they are negative. However, given this predicate, we can re-use it in other situations, providing we have a way to map values to integers. For instance, we can use the negative predicate on a person's bank balance to work out if they are currently overdrawn:

newtype Predicate a = Predicate { getPredicate :: a -> Bool }

instance Contravariant Predicate where
  contramap :: (a' -> a) -> (Predicate a -> Predicate a')
  contramap f (Predicate p) = Predicate (p . f)
                                         |   `- First, map the input...
                                         `----- then apply the predicate.

overdrawn :: Predicate Person
overdrawn = contramap personBankBalance negative

Any instance should be subject to the following laws:

Identity

contramap id = id

Composition

contramap (g . f) = contramap f . contramap g

Note, that the second law follows from the free theorem of the type of contramap and the first law, so you need only check that the former condition holds.

Methods

  • contramap :: (a' -> a) -> f a -> f a'
  • (>$) :: b -> f b -> f ainfixl 4

    Replace all locations in the output with the same value. The default definition is contramap . const, but this may be overridden with a more efficient version.

Instances35Contravariant, …
newtypenewtype Equivalence a
#

This data type represents an equivalence relation.

Equivalence relations are expected to satisfy three laws:

Reflexivity

getEquivalence f a a = True

Symmetry

getEquivalence f a b = getEquivalence f b a

Transitivity

If

getEquivalence f a b

and

getEquivalence f b c

are both

True

then so is

getEquivalence f a c

.

The types alone do not enforce these laws, so you'll have to check them yourself.

Constructors

Instances5Contravariant, Decidable, Divisible, Semigroup, Monoid
  • Contravariant EquivalenceDefined in base-4.23.0.0 · Data.Functor.Contravariant

    Equivalence relations are Contravariant, because you can apply the contramapped function to each input to the equivalence relation.

  • Decidable EquivalenceDefined in contravariant-1.5.6 · Data.Functor.Contravariant.Divisible
  • Divisible EquivalenceDefined in contravariant-1.5.6 · Data.Functor.Contravariant.Divisible
  • Semigroup (Equivalence a)Defined in base-4.23.0.0 · Data.Functor.Contravariant

    (<>) on equivalences uses logical conjunction (&&) on the results. Without newtypes this equals liftA2 (liftA2 (&&)).

    (<>) :: Equivalence a -> Equivalence a -> Equivalence a
    Equivalence equiv <> Equivalence equiv' = Equivalence a b ->
      equiv a b && equiv' a b
    
  • Monoid (Equivalence a)Defined in base-4.23.0.0 · Data.Functor.Contravariant

    mempty on equivalences always returns True. Without newtypes this equals pure (pure True).

    mempty :: Equivalence a
    mempty = Equivalence _ _ -> True
    
newtypenewtype Op a b
#

Dual function arrows.

Constructors

Instances9Category, Contravariant, Decidable, Divisible, Floating, Fractional, …
  • Category OpDefined in base-4.23.0.0 · Data.Functor.Contravariant
  • Contravariant (Op a)Defined in base-4.23.0.0 · Data.Functor.Contravariant
  • Monoid r => Decidable (Op r)Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Divisible
  • Monoid r => Divisible (Op r)Defined in contravariant-1.5.6 · Data.Functor.Contravariant.Divisible
  • Floating a => Floating (Op a b)Defined in base-4.23.0.0 · Data.Functor.Contravariant
  • Fractional a => Fractional (Op a b)Defined in base-4.23.0.0 · Data.Functor.Contravariant
  • Num a => Num (Op a b)Defined in base-4.23.0.0 · Data.Functor.Contravariant
  • Semigroup a => Semigroup (Op a b)Defined in base-4.23.0.0 · Data.Functor.Contravariant

    (<>) @(Op a b) without newtypes is (<>) @(b->a) = liftA2 (<>). This lifts the Semigroup operation (<>) over the output of a.

    (<>) :: Op a b -> Op a b -> Op a b
    Op f <> Op g = Op a -> f a <> g a
    
  • Monoid a => Monoid (Op a b)Defined in base-4.23.0.0 · Data.Functor.Contravariant

    mempty @(Op a b) without newtypes is mempty @(b->a) = _ -> mempty.

    mempty :: Op a b
    mempty = Op _ -> mempty
    
newtypenewtype Predicate a
#

Constructors

Instances5Contravariant, Decidable, Divisible, Semigroup, Monoid
  • Contravariant PredicateDefined in base-4.23.0.0 · Data.Functor.Contravariant

    A Predicate is a Contravariant Functor, because contramap can apply its function argument to the input of the predicate.

    Without newtypes contramap f equals precomposing with f (= (. f)).

    contramap :: (a' -> a) -> (Predicate a -> Predicate a')
    contramap f (Predicate g) = Predicate (g . f)
    
  • Decidable PredicateDefined in contravariant-1.5.6 · Data.Functor.Contravariant.Divisible
  • Divisible PredicateDefined in contravariant-1.5.6 · Data.Functor.Contravariant.Divisible
  • Semigroup (Predicate a)Defined in base-4.23.0.0 · Data.Functor.Contravariant

    (<>) on predicates uses logical conjunction (&&) on the results. Without newtypes this equals liftA2 (&&).

    (<>) :: Predicate a -> Predicate a -> Predicate a
    Predicate pred <> Predicate pred' = Predicate a ->
      pred a && pred' a
    
  • Monoid (Predicate a)Defined in base-4.23.0.0 · Data.Functor.Contravariant

    mempty on predicates always returns True. Without newtypes this equals pure True.

    mempty :: Predicate a
    mempty = _ -> True
    
classclass Divisible f => Decidable (f :: Type -> Type) where
#

A Decidable contravariant functor is the contravariant analogue of Alternative.

Noting the superclass constraint that f must also be Divisible, a Decidable functor has the ability to "fan out" input, under the intuition that contravariant functors consume input.

In the discussion for Divisible, an example was demonstrated with Serializers, that turn as into ByteStrings. Divisible allowed us to serialize the product of multiple values by concatenation. By making our Serializer also Decidable- we now have the ability to serialize the sum of multiple values - for example different constructors in an ADT.

Consider serializing arbitrary identifiers that can be either Strings or Ints:

data Identifier = StringId String | IntId Int

We know we have serializers for Strings and Ints, but how do we combine them into a Serializer for Identifier? Essentially, our Serializer needs to scrutinise the incoming value and choose how to serialize it:

identifier :: Serializer Identifier
identifier = Serializer $ \identifier ->
  case identifier of
    StringId s -> runSerializer string s
    IntId i -> runSerializer int i

It is exactly this notion of choice that Decidable encodes. Hence if we add an instance of Decidable for Serializer...

instance Decidable Serializer where
  lose f = Serializer $ \a -> absurd (f a)
  choose split l r = Serializer $ \a ->
    either (runSerializer l) (runSerializer r) (split a)

Then our identifier Serializer is

identifier :: Serializer Identifier
identifier = choose toEither string int where
  toEither (StringId s) = Left s
  toEither (IntId i) = Right i

Methods

Instances27Decidable, …
classclass Contravariant f => Divisible (f :: Type -> Type) where
#

A Divisible contravariant functor is the contravariant analogue of Applicative.

Continuing the intuition that Contravariant functors consume input, a Divisible contravariant functor also has the ability to be composed "beside" another contravariant functor.

Serializers provide a good example of Divisible contravariant functors. To begin let's start with the type of serializers for specific types:

newtype Serializer a = Serializer { runSerializer :: a -> ByteString }

This is a contravariant functor:

instance Contravariant Serializer where
  contramap f s = Serializer (runSerializer s . f)

That is, given a serializer for a (s :: Serializer a), and a way to turn bs into as (a mapping f :: b -> a), we have a serializer for b: contramap f s :: Serializer b.

Divisible gives us a way to combine two serializers that focus on different parts of a structure. If we postulate the existance of two primitive serializers - string :: Serializer String and int :: Serializer Int, we would like to be able to combine these into a serializer for pairs of Strings and Ints. How can we do this? Simply run both serializers and combine their output!

data StringAndInt = StringAndInt String Int

stringAndInt :: Serializer StringAndInt
stringAndInt = Serializer $ \(StringAndInt s i) ->
  let sBytes = runSerializer string s
      iBytes = runSerializer int i
  in sBytes <> iBytes

divide is a generalization by also taking a contramap like function to split any a into a pair. This conveniently allows you to target fields of a record, for instance, by extracting the values under two fields and combining them into a tuple.

To complete the example, here is how to write stringAndInt using a Divisible instance:

instance Divisible Serializer where
  conquer = Serializer (const mempty)

  divide toBC bSerializer cSerializer = Serializer $ \a ->
    case toBC a of
      (b, c) ->
        let bBytes = runSerializer bSerializer b
            cBytes = runSerializer cSerializer c
        in bBytes <> cBytes

stringAndInt :: Serializer StringAndInt
stringAndInt =
  divide (\(StringAndInt s i) -> (s, i)) string int

Methods

  • divide :: (a -> (b, c)) -> f b -> f c -> f a
  • conquer :: f a

    Conquer acts as an identity for combining Divisible functors.

Instances31Divisible, …
newtypenewtype CoGenT (m :: Type -> Type) a
#

A CoGenT m a is used to perturb a GenT m b based on the value of the a. This way, the generated function will have a varying (but still deterministic) right hand side.

Co-generators can be built using Divisible and Decidable, but it is recommended to derive Generic and use the default instance of the Vary type class.

CoGenT m ~ Data.Functor.Contravariabe.Op (Endo (GenT m b))
Instances3Contravariant, Decidable, Divisible
classclass Vary a where
#

Vary provides a canonical co-generator for a type.

While technically there are many possible co-generators for a given type, we don't get any benefit from caring.

Methods

Instances15Vary, …
  • Vary VoidDefined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Vary IntegerDefined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Vary Int16Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Vary Int32Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Vary Int64Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Vary Int8Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Vary BoolDefined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Vary IntDefined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Vary OrderingDefined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Vary Word8Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Vary ()Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Vary a => Vary (Maybe a)Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • Vary a => Vary [a]Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • (Vary a, Vary b) => Vary (Either a b)Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal
  • (Vary a, Vary b) => Vary (a, b)Defined in hedgehog-fn-1.1 · Hedgehog.Function.Internal