HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleprimitive-unlifted-2.1.0.0Haskell2010

Data.Primitive.Unlifted.Box

Traditionally, there were only a few basic unlifted types available in GHC, all of them primitive. Now, with the UnliftedNewtypes and UnliftedDatatypes extensions, users are free to create as many as they like. However, many essential facilities, like the Monad class, still work only with lifted types, so users must wrap their unlifted types into lifted ones to use those. If the wrapped version of a type is likely to be used heavily on its own, it often makes sense to write a custom wrapper type for it. This module exports a general box for situations where the focus should be on the unlifted type rather than its wrapper.

  • 1 type
  • 2 values
datadata Box (a :: UnliftedType)
#

Turn an arbitrary unlifted type into a lifted one with a PrimUnlifted instance. For example, given

data UnliftedMaybe a :: UnliftedType where
  UnliftedNothing :: UnliftedMaybe a
  UnliftedJust :: a -> UnliftedMaybe a

we have

Box (UnliftedMaybe a) :: Type

Constructors

Instances2PrimUnlifted, Unlifted
  • PrimUnlifted (Box a)Defined in primitive-unlifted-2.1.0.0 · Data.Primitive.Unlifted.Box
  • type Unlifted (Box a) = aDefined in primitive-unlifted-2.1.0.0 · Data.Primitive.Unlifted.Box