[GHC] #14752: Unboxed sums documentation looks wrong

GHC ghc-devs at haskell.org
Fri Feb 2 13:56:43 UTC 2018


#14752: Unboxed sums documentation looks wrong
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.4.2
       Component:  Documentation     |              Version:  8.2.2
      Resolution:                    |             Keywords:  UnboxedSums
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Documentation     |  Unknown/Multiple
  bug                                |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by osa1):

 If you generate STG and Cmm for this program:

 {{{
 {-# LANGUAGE UnboxedSums, UnboxedTuples, MagicHash #-}

 module Lib where

 type UnboxedBool = (# (# #) | (# #) #)

 unboxBool :: Bool -> UnboxedBool
 unboxBool True = (# (# #) | #)
 unboxBool False = (# | (# #) #)

 boxBool :: UnboxedBool -> Bool
 boxBool (# (# #) | #) = True
 boxBool (# | (# #) #) = False
 }}}

 you'll see that `UnboxedBool` is clearly represented as single integer.

 In your program, I don't understand why you expect your `Bool` to be
 unboxed. You can put bottom values in unboxed tuples/sums so everything
 seems fine here.

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


More information about the ghc-tickets mailing list