Proposal: Move primitive-Data.Primitive.Addr API into base

Sven Panne svenpanne at gmail.com
Tue Oct 30 17:21:58 UTC 2018


Am Di., 30. Okt. 2018 um 16:48 Uhr schrieb Andrew Martin <
andrew.thaddeus at gmail.com>:

> Look at the definition of SerializedCompact (in ghc-compact):
>
>     data SerializedCompact a = SerializedCompact
>       { serializedCompactBlockList :: [(Ptr a, Word)]
>       , serializedCompactRoot :: Ptr a
>       }
> [...]
>

I haven't used the ghc-compact or compact packages yet, so I can't really
comment on the details here. The question boils down to: Why does
Compact/SerializedCompact have a type parameter at all? Quickly browsing
over the Hadoock documentation of both packages doesn't make that clear to
me, but as I said: I can't comment on the design decision of someone else's
API if I don't fully understand the use cases and tradeoffs involved.

In any case: This example has exactly *nothing* to do with the proposal at
hand. If the API above uses "a" for some good reason/convenience etc. it's
perfectly OK, if not, it should better use "Ptr ()" or "Ptr Void". This is
perhaps an example of incomplete documentation and/or suboptimal API
design, but nothing more. Using Addr here wouldn't improve usability or
safety, it would just introduce a non-standard data type for nothing.

I could show you tons of APIs out in the wild where e.g. lists are used,
but where they are actually not really the right data structure for the
problem at hand. Nevertheless, this is not an argument against lists per
se, this is a problem of the API which abuses them.

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20181030/6ab831ac/attachment.html>


More information about the Libraries mailing list