Storable instance of () is broken
Roman Cheplyaka
roma at ro-che.info
Wed Jan 5 11:05:02 UTC 2022
On 05/01/2022 12.39, Georgi Lyubenov wrote:
> I have an additional question:
>
> It is true that in a strict/unboxed language, the type of () is
> sufficient to reproduce its value. However, here, trying to store
> undefined :: () is no different from trying to store () :: (). Is this
> difference in behaviour with other instances of Storable (where
> presumably trying to store undefined will blow up, as there is indeed
> some work to do there) intentionally ignored?
If you look at it from the strict-by-default point of view, it does
appear inconsistent with the other instances.
However, if you look at it from the non-strict-by-default point of view,
which is arguably more native to Haskell, then all instances follow the
same principle: they are maximally non-strict. It's just when you store
anything non-trivial, you are forced to be strict in order to fulfill
the task, but you never add any gratuitous strictness.
Roman
More information about the Libraries
mailing list