[GHC] #14806: Officially sanction certain unsafeCoerce applications with unboxed unary tuples

GHC ghc-devs at haskell.org
Tue Apr 24 23:25:00 UTC 2018


#14806: Officially sanction certain unsafeCoerce applications with unboxed unary
tuples
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Documentation     |              Version:  8.2.2
      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 simonpj):

 > `unsafeCoerce :: (A -> B) -> A -> (# B #)`

 I think you are right that this is ok.  But the reverse is not
 {{{
 unsafeCoerce :: (A -> {# B #)) -> A -> B
 }}}
 because the argument function may return an unevaluated `B`, while the
 returned function is supposed to guaranteed to return an evaluated `B`.
 Tricky.

 > The first version in particular would be very useful for reducing both
 source code and generated code size in libraries supporting both strict
 and lazy operations.

 Would you care to explain your use-case?

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


More information about the ghc-tickets mailing list