[GHC] #11526: unsafeLookupStaticPtr should not live in IO

GHC ghc-devs at haskell.org
Wed Feb 10 17:49:31 UTC 2016


#11526: unsafeLookupStaticPtr should not live in IO
-------------------------------------+-------------------------------------
        Reporter:  edsko             |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.0.1
       Component:  Core Libraries    |              Version:  8.0.1-rc1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by ekmett):

 Replying to [comment:8 mboes]:
 > I think a reasonable compromise here is simply to have:
 >
 > {{{
 > -- | Lookup in a static table constructed at compile time.
 > unsafeLookupStaticPtr :: StaticKey -> Maybe (StaticPtr a)
 >
 > -- | Lookup in the static table + an aux table that's initially empty
 but may grow if objects are dynamically loaded.
 > unsafeLookupStaticPtrDL :: StaticKey -> IO (Maybe (StaticPtr a))
 > }}}

 This is the approach we take in the `OpenGLRaw` package for detecting
 extensions. Yes, technically you ''might'' switch OpenGL contexts and
 change which ones are available over the life of a program, it isn't the
 common case, while branching on them is very common and is made nigh
 unusable, and needlessly slow, since they can't memoize this information
 if they are stuck in IO.

 One of hundreds of such examples:

 http://hackage.haskell.org/package/OpenGLRaw-3.1.0.0/docs/Graphics-GL-ARB-
 CullDistance.html

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


More information about the ghc-tickets mailing list