A newtype-friendly wrapper for
Suppose you define a newtype for
Int and want to store them in an unboxed vector.
newtype Foo = Foo Int generate 10 (\i -> Foo i) :: Vector Foo
Data.Vector.Unboxed, you either write two dozen of lines of code to get it work, or resort to Template Haskell (
Data.Vector.Unboxing, the code you write is just two lines:
instance Data.Vector.Unboxing.Unboxable Foo where type Underlying Foo = Int
Note that the vector type provided by this package (
Data.Vector.Unboxing.Vector) is different from
Data.Vector.Unboxed.Vector, although the former is a newtype for the latter.