Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#2473 closed bug (fixed)

Data.Array.IO.Internals hidden in GHC6.8 for no good reason

Reported by: ryani Owned by: igloo
Priority: normal Milestone:
Component: libraries (other) Version: 6.8.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I had some fast array modification code in C to modify the contents of an IOUArray, because I couldn't get my Haskell performance up to snuff. Now that module is hidden in the array package and it doesn't seem possible to unhide it.

The code compiled & worked quite well in GHC6.6. I understand that by going into the internals I may have to update the code as the internals change, but it doesn't seem to be possible to do so at all at this point. The only workaround I can think of is to figure out the internal type from the source, re-declare it locally, and use unsafeCoerce# shenanigans to extract the data. That seems terrible, since future changes to the internals could cause the code to start crashing without any compile-time warning at all.

Bitmap.hs:

{-# OPTIONS_GHC -fffi -fglasgow-exts #-}
{-# INCLUDE "bitmap_operations.h" #-}
module Bitmap(clearBitmap) where

import Data.Array.Base
import Data.Array.IO.Internals
import GHC.Exts
import Data.Word

foreign import ccall unsafe clear_bitmap
  :: MutableByteArray# RealWorld -> Word32 -> Word32 -> IO ()

{-# INLINE unsafeGetMutableArray# #-}
unsafeGetMutableArray# :: IOUArray Int Word32 -> MutableByteArray# RealWorld
unsafeGetMutableArray# (IOUArray (STUArray _ _ array#)) = array#

clearBitmap :: IOUArray Int Word32 -> Word32 -> Word32 -> IO ()
clearBitmap a c sz = clear_bitmap (unsafeGetMutableArray# a) c sz

bitmap_operations.h:

#include "HsFFI.h"

void clear_bitmap(void* p, HsWord32 color, HsWord32 size);

Change History (5)

comment:1 Changed 6 years ago by igloo

  • Difficulty set to Unknown
  • Owner set to igloo

It was hidden by:

Sat Nov 11 11:32:48 GMT 2006  Ross Paterson <ross@soi.city.ac.uk>
  * hide Data.Array.IO.Internals
  
  It's hidden from haddock, and everything it exports is re-exported by
  Data.Array.IO.

which isn't quite accurate, as Data.Array.IO re-exports IOArray and IOUArray abstractly.

I think that .Internal modules aren't really part of the API, so I'll just re-expose it.

comment:2 Changed 6 years ago by ryani

Thanks!

comment:3 Changed 6 years ago by igloo

  • Resolution set to fixed
  • Status changed from new to closed

Done!

comment:4 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:5 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.