Proposal: give Ptr a nominal role

Daniel Cartwright chessai1996 at
Thu Nov 1 19:37:24 UTC 2018

I am +1 on this change.

On Thu, Nov 1, 2018 at 3:33 PM Daniel Cartwright <chessai1996 at>

> i agree with carter regarding the Storable-Ptr relationship. It seems to
> me that Storable is tied to Ptr. Some concrete evidence of this is in the
> Data.Primitive.Ptr API
> On Thu, Nov 1, 2018 at 2:26 PM Carter Schonwald <
> carter.schonwald at> wrote:
>> phrased differnetly: storable provides one (c compatible) isomorphism
>> between fixed size values in haskell and c
>> the moment you want to talk about something that isn't fixed sized, like
>> a unicode character (which is a sequence of one or more code points, which
>> we call Char in haskell), storable doesn't apply.
>> On Thu, Nov 1, 2018 at 2:23 PM Carter Schonwald <
>> carter.schonwald at> wrote:
>>> ... Ptr *is not* tied to storable, Storable is a convenience for FFI
>>> integration .. storable is tied to ptr
>>> there are whole MOUNTAINS of haskell code that underly this, and we
>>> can't lawyer it away with some opinions
>>> On Thu, Nov 1, 2018 at 2:16 PM David Feuer <david.feuer at>
>>> wrote:
>>>> Indeed. I think the point is that Ptr should be thought of as tied to
>>>> Storable. If you want to use an Addr# for something else, then you
>>>> shouldn't be using Ptr!
>>>> On Thu, Nov 1, 2018, 2:13 PM Evan Laforge <qdunkan at wrote:
>>>>> On Thu, Nov 1, 2018 at 10:47 AM Carter Schonwald
>>>>> <carter.schonwald at> wrote:
>>>>> > a good example might be Ptr Char.  Is this a single location of a
>>>>> 32bit / utf32 code point, or an array of utf8 code points or utf32 code
>>>>> points?
>>>>> > is it null terminated vs there being an extra sequence length? These
>>>>> are all valid things that can be happening. And
>>>>> I'm not sure if it affects your point, but I sure hope a 'Ptr Char'
>>>>> points to a 4 byte haskell Char as it claims, and 'Ptr CChar' points
>>>>> to a 1 byte C char, as it claims.  Otherwise, sizeOf will be wrong and
>>>>> array indexing will go out of bounds.
>>>>> Of course, in the C case, whether or not there are further chars after
>>>>> that and if they are terminated and what is the encoding is all
>>>>> ambiguous, as it always is for C.
>>>>> _______________________________________________
>>>>> Libraries mailing list
>>>>> Libraries at
>>>> _______________________________________________
>> Libraries mailing list
>> Libraries at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list