The type ForeignPtr represents references to objects that are
maintained in a foreign language, i.e., that are not part of the
data structures usually managed by the Haskell storage manager.
The essential difference between ForeignPtrs and vanilla memory
references of type Ptr a is that the former may be associated
with finalizers. A finalizer is a routine that is invoked when
the Haskell storage manager detects that - within the Haskell heap
and stack - there are no more references left that are pointing to
the ForeignPtr. Typically, the finalizer will, then, invoke
routines in the foreign language that free the resources bound by
the foreign object.
The ForeignPtr is parameterised in the same way as Ptr. The type argument of ForeignPtr should normally be an instance of class Storable.
Instances7Eq, Data, Ord, Show, HasGetter, HasSetter, …
Eq (ForeignPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ForeignPtrData a => Data (ForeignPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.DataOrd (ForeignPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ForeignPtrShow (ForeignPtr a)Defined in ghc-internal-9.1003.0 · GHC.Internal.ForeignPtrStorable a => HasGetter (ForeignPtr a) aDefined in StateVar-1.2.2 · Data.StateVarStorable a => HasSetter (ForeignPtr a) aDefined in StateVar-1.2.2 · Data.StateVarStorable a => HasUpdate (ForeignPtr a) a aDefined in StateVar-1.2.2 · Data.StateVar