Or in unpacked vectors

I want to store something like any type in the Data.Vector.Unboxed.Unbox vector. I assume that I should create an Unbox instance for “Either b,” where a and b are Unbox (without taking into account the problems with the orphan at the moment). What is the best way to do this? Should I keep it the same as (Bool, a, b)? I am much more concerned about speed than space.

+4
source share
1 answer

To store the types of amounts in unpacked structures, you will need to use the product encoding. For example. as a tuple of a type tag and a pair of values.

So:

  Unbox a, Unbox b => Either a b
-->
  Unbox (Int, a, b)

With appropriate default values ​​for empty slots for a and b.

+1

Source: https://habr.com/ru/post/1528221/


All Articles