-
--- These conditions come directly from what the DsCCall is capable of.
--- Totally grotesque. Green card should solve this.
-
-ccallable_type ty = isUnLiftedType ty || -- Allow CCallable Int# etc
- maybeToBool (maybeBoxedPrimType ty) || -- Ditto Int etc
- ty == stringTy ||
- byte_arr_thing
- where
- byte_arr_thing = case splitProductType_maybe ty of
- Just (tycon, ty_args, data_con, [data_con_arg_ty1, data_con_arg_ty2, data_con_arg_ty3]) ->
- maybeToBool maybe_arg3_tycon &&
- (arg3_tycon == byteArrayPrimTyCon ||
- arg3_tycon == mutableByteArrayPrimTyCon)
- where
- maybe_arg3_tycon = splitTyConApp_maybe data_con_arg_ty3
- Just (arg3_tycon,_) = maybe_arg3_tycon
-
- other -> False
-
-creturnable_type ty = maybeToBool (maybeBoxedPrimType ty) ||
- -- Or, a data type with a single nullary constructor
- case (splitAlgTyConApp_maybe ty) of
- Just (tycon, tys_applied, [data_con])
- -> isNullaryDataCon data_con
- other -> False