HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulelinear-base-0.4.0Haskell2010

Data.Replicator.Linear.Internal

  • 1 type
  • 1 class
  • 12 values
datadata Replicator a where
#

Replicator is a stream-like data structure used to linearly duplicate values.

Constructors

Instances4Functor, Applicative, Consumable, Dupable
  • Functor ReplicatorDefined in linear-base-0.4.0 · Data.Replicator.Linear.Internal.Instances · orphan
  • Applicative ReplicatorDefined in linear-base-0.4.0 · Data.Replicator.Linear.Internal.Instances · orphan
  • Consumable (Replicator a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Consumable
  • Dupable (Replicator a)Defined in linear-base-0.4.0 · Data.Unrestricted.Linear.Internal.Dupable
classclass Elim (n :: Peano) a b where
#

Elim n a b is used to implement elim without recursion so that we can guarantee that elim will be inlined and unrolled.

Elim is solely used in the signature of elim.

Instances3Elim
  • Elim 'Z a bDefined in linear-base-0.4.0 · Data.Replicator.Linear.Internal
  • Elim ('S 'Z) a bDefined in linear-base-0.4.0 · Data.Replicator.Linear.Internal
  • Elim ('S n) a b => Elim ('S ('S n)) a bDefined in linear-base-0.4.0 · Data.Replicator.Linear.Internal
valueelim
  1. :: (Elim (NatToPeano n) a b, IsFunN a b f, f ~ FunN (NatToPeano n) a b, n ~ Arity b f)
  2. => f
  3. -> Replicator a
  4. -> b
#

Takes a function of type a %1 -> a %1 -> ... %1 -> a %1 -> b, and returns a b . The replicator is used to supply all the items of type a required by the function.

For instance:

elim @1 :: (a %1 -> b) %1 -> Replicator a %1 -> b
elim @2 :: (a %1 -> a %1 -> b) %1 -> Replicator a %1 -> b
elim @3 :: (a %1 -> a %1 -> a %1 -> b) %1 -> Replicator a %1 -> b

It is not always necessary to give the arity argument. It can be inferred from the function argument.

elim (,) :: Replicator a %1 -> (a, a)
elim (,,) :: Replicator a %1 -> (a, a, a)

About the constraints of this function (they won't get in your way):

  • Elim (NatToPeano n) a b provides the actual implementation of elim; there is an instance of this class for any (n, a, b)

  • IsFunN a b f, f ~ FunN (NatToPeano n) a b, n ~ Arity b f indicate the shape of f to the typechecker (see documentation of IsFunN).