Unbox sum types without fields
|Reported by:||tibbe||Owned by:|
|Type of failure:||None/Unknown||Test Case:|
|Related Tickets:||Differential Rev(s):|
In the new I/O manager we use newtyped
Ints instead of an ADT to squeeze out every drop of performance GHC can give us. It's a bit unfortunate that we have to make a choice between performance and safety here. Using an ADT have many benefits. For example, all possible values are grouped together neatly under the data type and the compiler can make sure we check all possible cases in case statements.
Pointer tagging helps quite a bit here, if you have fewer than 4 (or 8) constructors. If you have more you don't get the benefit.
Given a simple sum type like this:
data Color = Red | Green | Blue | Yellow
change its representation to an
Int, allowing it to be unboxed into data types.