
#9220: type roles for unboxed arrays -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Core | Version: 7.8.1 Libraries | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by ekmett): Ok, lets go through Array with a fine toothed comb: {{{ type role Array nominal representational type role IOArray nominal representational }}} That lets users case the element type in the array. This is safe because e.g. `instance IArray Array e` is fully polymorphic in `e` with no constraints. The index has to be nominal as it is tied to the semantics of the internal bounds, the underlying array size, etc. Users can coerce boxed arrays to change the element types. {{{ type role UArray nominal nominal type role IOUArray nominal nominal type role StorableArray nominal nominal }}} The index is nominal for the same reason as above, the element type is nominal because we'd otherwise silently be re-interpreting the bit representation of the underlying storables in the latter case, and the interpretation of the array size, etc. changes based on the same sort of information in `UArray` and `IOUArray`. {{{ type role STArray nominal nominal representational type role STUArray nominal nominal nominal }}} The region parameter is nominal lest users easily subvert `ST` safety, otherwise same as `Array` and `UArray` respectively. It turns out there isn't a lot of representational material here, just the element type in `Array`, `STArray` and `IOArray`. Every other role in the entire `array` package is necessarily `nominal`. Does that give enough to proceed? That should be every type used by the package, though, I think the bulk comes from `GHC.Arr`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9220#comment:26 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler