I'm having trouble finding good resources that work for how to make my data types unboxed, for use in an unboxed vector. How would I make the data type
data Color = Yellow | Red | Green | Blue | Empty deriving (Show, Eq)
be an instance of Unbox?
Edit: after poking around a bit more, it seems that by forcing paramaters in some functions to be strict, I can convince GHC to unbox them automatically. If this applicable in my case? How do I know which paramaters to make strict?
Vector
,MVector
, andU.Unbox
are not derivable classes. Not to mention I don't really understand what is going on there, especially with theGeneralizedNewtypeDeriving
thing, and I'd like to understand things before I use them. – Intendantnewtype Color = Color Int
) instead of an enumerated data type. And then add helper functions for constructing/deconstructing instances. It's not very nice, but if performances is important, it could help. See Performance-Data types-Enumerations. – Cranwell