I think a more classic concrete example would be something like vectors or arrays. the vector package exports both boxed and unpacked vectors. While nested vectors can contain any Haskell type (including functions), non-positioned vectors require that its elements be an instance of a type class Unbox
. Although this implies a more efficient representation of packed memory without pointers, you can no longer define an instance Functor
for decompressed vectors, so it has a loss of generality.
If you used
fmap :: (a -> b) -> Vector a -> Vector b
in function type
f :: Functor f => f SomeType -> f SomeOtherType
a "", fmap
. , "Core", GHC, -ddump-simpl
. , arity f
.
GHC , . SPECIALIZE/INLINABLE/... pragmas, , , .
, , , . 100 ( SPECIALIZE), . , , , .