[GHC] #1338: base package breakup

GHC trac at galois.com
Tue Aug 25 14:54:28 EDT 2009


#1338: base package breakup
---------------------------------+------------------------------------------
    Reporter:  simonmar          |        Owner:                  
        Type:  task              |       Status:  new             
    Priority:  normal            |    Milestone:  6.12 branch     
   Component:  libraries/base    |      Version:  6.6.1           
    Severity:  normal            |   Resolution:                  
    Keywords:                    |   Difficulty:  Unknown         
    Testcase:                    |           Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |  
---------------------------------+------------------------------------------
Comment (by mokus):

 Replying to [comment:31 igloo]:
 > Unfortunately, this isn't as easy as you might expect. Exceptions
 require `Typeable`, which uses `unsafePerformIO` and `IORef`, which is
 enough to allow you to both `unsafePerformIO` (obviously) and
 `unsafeCoerce`.
 >
 > Of course, you could make them not be exported, but that's not as nice
 as them being completely absent.

 As far as I can tell, Typeable is safe as long as the end user cannot
 inject their own implementations of typeOf.  As a separate issue, if this
 is not correct I'm interested to know that as well ;).

 In my current implementation, I export Typeable with the class methods
 replaced by identically-typed functions, so that Typeable may be used but
 no 'tricky' implementations may be created.  It is still possible to
 derive instances as long as the class itself is in scope, and as far as I
 can tell this is sufficient to make Typeable both useful and safe.
 Likewise for Typeable1, Typeable2, and the rest, as well as Data and Ix
 just to be safe.

 I'm not requesting that unsafe operations not be present, only that they
 not be available to packages only importing the base package.  Clearly the
 unsafe operations should be exposed somehow, because they're just too darn
 useful not to provide.  Presently I do this by compiling against the un-
 wrapped version of base when building other "safe" packages like
 bytestring (similarly wrapped with a 'safe' version hiding its unsafe
 operations) that make use of unsafe interfaces but cleanly encapsulate
 them.  I expect that any practical strategy for achieving a safe base
 would either keep the whole unsafe base around, perhaps under a different
 name, or place the unsafe operations in separate package(s) depended-upon
 by base and other packages that need them.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1338#comment:32>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list