scattervSend :: (SendFrom v1, RecvInto v2) => Comm
                -> Rank
                -> v1 -- ^ Value (vector) to send from
                -> StorableArray Int CInt -- ^ Length of each segment (in elements)
                -> StorableArray Int CInt -- ^ Offset of each segment from the beginning of @v1@ (in elements)
                -> v2
                -> IO ()
scattervSend comm root sendVal counts displacements recvVal  = do
   -- myRank <- commRank comm
   -- XXX: assert myRank == sendRank ?
   recvInto recvVal $ \recvPtr recvElements recvType ->
     sendFrom sendVal $ \sendPtr _ sendType->
       withStorableArray counts $ \countsPtr ->
         withStorableArray displacements $ \displPtr ->
           Internal.scatterv (castPtr sendPtr) countsPtr displPtr sendType
                             (castPtr recvPtr) recvElements recvType root comm

-- | Variant of 'scatterRecv', to be used with 'scattervSend'
scattervSend :: (SendFrom v1, RecvInto v2) => Comm
                -> Rank
                -> v1 -- ^ Value (vector) to send from
                -> StorableArray Int CInt -- ^ Length of each segment (in elements)
                -> StorableArray Int CInt -- ^ Offset of each segment from the beginning of @v1@ (in elements)
                -> v2
                -> IO ()
scattervSend comm root sendVal counts displacements recvVal  = do
   -- myRank <- commRank comm
   -- XXX: assert myRank == sendRank ?
   recvInto recvVal $ \recvPtr recvElements recvType ->
     sendFrom sendVal $ \sendPtr _ sendType->
       withStorableArray counts $ \countsPtr ->
         withStorableArray displacements $ \displPtr ->
           Internal.scatterv (castPtr sendPtr) countsPtr displPtr sendType
                             (castPtr recvPtr) recvElements recvType root comm

-- | Variant of 'scatterRecv', to be used with 'scattervSend'
scattervSend comm root sendVal counts displacements recvVal  = do
   -- myRank <- commRank comm
   -- XXX: assert myRank == sendRank ?
   recvInto recvVal $ \recvPtr recvElements recvType ->
     sendFrom sendVal $ \sendPtr _ sendType->
       withStorableArray counts $ \countsPtr ->
         withStorableArray displacements $ \displPtr ->
           Internal.scatterv (castPtr sendPtr) countsPtr displPtr sendType
                             (castPtr recvPtr) recvElements recvType root comm

-- | Variant of 'scatterRecv', to be used with 'scattervSend'