#4937: Remove indirections caused by sum types, such as Maybe
---------------------------------+------------------------------------------
Reporter: tibbe | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.0.1
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Comment(by tibbe):
Replying to [comment:4 simonmar]:
> then we've lost the tag bits (10) on Q, and we have no knowledge of V.
So then we have to fall back to untagged pointers, and that could hurt
performance a lot.
Does it make a difference (performance wise) if we use the field in a
polymorphic manner? The main use case I had in mind is something like this
(simplified):
{{{
data Collection a = C (Array (Maybe a))
member :: Eq a => a -> Collection a -> Bool
member k coll = ...
}}}
The example is somewhat contrived but I believe it represents my real use
case. `k` is used in a polymorphic manner: each element is tested to see
if it's `Just`/`Nothing` followed by an `==` comparison.
Note that if I didn't store a polymorphic value in the `Just` constructor
I could create my own version of `Maybe` that manually unpacks the value
into the constructor, like so:
{{{
data MaybeInt = NothingI | JustI {-# UNPACK #-} !Int
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4937#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs