ByteArray# as a foreign import argument?
Sylvain Henry
sylvain at haskus.fr
Fri Oct 11 08:43:00 UTC 2019
Or better 98668305453ea1158c97c8a2c1a90c108aa3585a (2001):
From the commit message:
- finally, remove the last vestiges of ByteArray and MutableByteArray
from the core libraries. Deprecated implementations will be
available
in the lang compatibility package.
On 11/10/2019 10:32, Sylvain Henry wrote:
> > But I can't find such a ByteArray type definition in today's common
> packages. What's the rationale for this piece of code?
>
> Doing some archeology they seem to have been removed from
> ghc/lib/std/PrelArr.lhs in e921b2e307532e0f30eefa88b11a124be592bde4
> (1999):
>
> data Ix ix => Array ix elt = Array ix ix (Array# elt)
> -data Ix ix => ByteArray ix = ByteArray ix ix ByteArray#
> data Ix ix => MutableArray s ix elt = MutableArray ix ix
> (MutableArray# s elt)
> -data Ix ix => MutableByteArray s ix = MutableByteArray ix ix
> (MutableByteArray# s)
>
> So it's probably dead code since then.
>
> Cheers,
> Sylvain
>
>
> On 10/10/2019 21:15, Shao, Cheng wrote:
>> Hello devs,
>>
>> I've been trying to figure out how to pass lifted types as foreign
>> types, then encountered the following code in the `DsCCall` module
>> (https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/deSugar/DsCCall.hs#L172):
>>
>>
>> ```
>> -- Byte-arrays, both mutable and otherwise; hack warning
>> -- We're looking for values of type ByteArray, MutableByteArray
>> -- data ByteArray ix = ByteArray ix ix ByteArray#
>> -- data MutableByteArray s ix = MutableByteArray ix ix
>> (MutableByteArray# s)
>> | is_product_type &&
>> data_con_arity == 3 &&
>> isJust maybe_arg3_tycon &&
>> (arg3_tycon == byteArrayPrimTyCon ||
>> arg3_tycon == mutableByteArrayPrimTyCon)
>> = do case_bndr <- newSysLocalDs arg_ty
>> vars@[_l_var, _r_var, arr_cts_var] <- newSysLocalsDs
>> data_con_arg_tys
>> return (Var arr_cts_var,
>> \ body -> Case arg case_bndr (exprType body) [(DataAlt
>> data_con,vars,body)]
>> )
>> ```
>>
>> It seems we allow a "ByteArray" type as a foreign import argument, if
>> the third field of the datacon is a ByteArray# or MutableByteArray#.
>> But I can't find such a ByteArray type definition in today's common
>> packages. What's the rationale for this piece of code?
>>
>> Cheers,
>> Cheng
>> _______________________________________________
>> ghc-devs mailing list
>> ghc-devs at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
More information about the ghc-devs
mailing list