[GHC] #10048: {-# UNPACK #-} support for size-indexed types
GHC
ghc-devs at haskell.org
Mon Feb 2 09:01:13 UTC 2015
#10048: {-# UNPACK #-} support for size-indexed types
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner:
Type: feature request | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 7.11
Resolution: invalid | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Blocked By: | Test Case:
Related Tickets: | Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by simonpj):
A difficulty is that in GHC today, each data constructor (such as `Cons`
above) has a single, fixed memory layout. So if we have
{{{
data T = MkT Bool {-# UNPACK !(Int, Int) #-}
}}}
we can decide to lay out `MkT` with a `Bool` field and two `Int` fields.
But if we don't know `l`, we don't know how `HList l` is represented, so
we can't do that.
It's not just an implementation matter. Suppose at an allocation site we
were allocating a `Cons` whose first arg was `'[Int,Bool]`. Then you
could imagine whizzing up a specialised `Cons` constructor. But then
`hlength` above would have to be able to consume that constructor!
I don't know any way to do this without monomorphising the code. Which is
often, ''but not always'' possible, so you'd also need an escape hatch for
the impossible case -- and it's not obvious how to build the hatch.
PhD thesis anyone?
Simon
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10048#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list