[Haskell-cafe] What can be UNPACK'ed?
Tom Ellis
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Fri Jul 28 13:45:41 UTC 2017
What types can be UNPACK'ed? From my vague understanding of what UNPACK
does, it can only be types whose size is bounded by a known value, so whilst
data Foo = Foo {-# UNPACK #-} !Float {-# UNPACK #-} !Int
is fine, presumably
data Foo = Foo {-# UNPACK #-} ![Float]
is not fine. Or is it? Technically it could be possible to reserve enough
space in Foo to store either a [] or a (:) Float [Float]. And if that is
possible could we also UNPACK polymorphic fields?
data Storable a => Foo a = Foo {-# UNPACK #-} a
or
data Foo a where
Foo :: Storable a => {-# UNPACK #-} a -> Foo a
if either DatatypeContexts worked or my imaginary GADT UNPACK syntax worked
(I'm not sure if either does).
What are the limits of what we could reasonably get to UNPACK in GHC?
Thanks,
Tom
More information about the Haskell-Cafe
mailing list