<div dir="ltr"><div>It's a primitive type.</div><div><a href="https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/prelude/primops.txt.pp#L1388">https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/prelude/primops.txt.pp#L1388</a></div><div><a href="https://gitlab.haskell.org/ghc/ghc/wikis/commentary/prim-ops">https://gitlab.haskell.org/ghc/ghc/wikis/commentary/prim-ops</a></div><div><br></div><div>Cheers,</div><div>Csaba<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 10, 2019 at 8:16 PM Shao, Cheng <<a href="mailto:cheng.shao@tweag.io">cheng.shao@tweag.io</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello devs,<br>
<br>
I've been trying to figure out how to pass lifted types as foreign<br>
types, then encountered the following code in the `DsCCall` module<br>
(<a href="https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/deSugar/DsCCall.hs#L172" rel="noreferrer" target="_blank">https://gitlab.haskell.org/ghc/ghc/blob/master/compiler/deSugar/DsCCall.hs#L172</a>):<br>
<br>
```<br>
  -- Byte-arrays, both mutable and otherwise; hack warning<br>
  -- We're looking for values of type ByteArray, MutableByteArray<br>
  --    data ByteArray          ix = ByteArray        ix ix ByteArray#<br>
  --    data MutableByteArray s ix = MutableByteArray ix ix<br>
(MutableByteArray# s)<br>
  | is_product_type &&<br>
    data_con_arity == 3 &&<br>
    isJust maybe_arg3_tycon &&<br>
    (arg3_tycon ==  byteArrayPrimTyCon ||<br>
     arg3_tycon ==  mutableByteArrayPrimTyCon)<br>
  = do case_bndr <- newSysLocalDs arg_ty<br>
       vars@[_l_var, _r_var, arr_cts_var] <- newSysLocalsDs data_con_arg_tys<br>
       return (Var arr_cts_var,<br>
               \ body -> Case arg case_bndr (exprType body) [(DataAlt<br>
data_con,vars,body)]<br>
              )<br>
```<br>
<br>
It seems we allow a "ByteArray" type as a foreign import argument, if<br>
the third field of the datacon is a ByteArray# or MutableByteArray#.<br>
But I can't find such a ByteArray type definition in today's common<br>
packages. What's the rationale for this piece of code?<br>
<br>
Cheers,<br>
Cheng<br>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div>