[GHC] #14752: Unboxed sums documentation looks wrong

#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 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: -------------------------------------+------------------------------------- According to the documentation,
In the case of enumeration types (like `Bool`), the unboxed sum layout only has an `Int32` field (i.e. the whole thing is represented by an integer).
This does not actually seem to be true. {{{#!hs right :: Bool -> (# (# #) | Bool #) right x = (# | x #) test :: (# (# #) | Bool #) -> Bool test (# (# #) | #) = False test (# | _ #) -> True }}} If the documentation were correct, I would expect `test (right undefined)` to be `undefined`, but it is `True`. Either we should fix the documentation to match reality or the reality to match the documentation. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14752 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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

#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 dfeuer): osa1, everything is fine except the documentation I quoted. Perhaps it should refer to some `type Bool# = ...` instead of to `Bool`? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14752#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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): Ah, right. I have no objections to improving the documentation. Maybe we should say something like "Unboxed sums with no fields are represented as a single `Int32`". -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14752#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14752: Unboxed sums documentation looks wrong -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: patch 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): Phab:D4379 Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * status: new => patch * differential: => Phab:D4379 Comment: osa1, could you please review my patch and make sure I didn't get anything terribly wrong? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14752#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14752: Unboxed sums documentation looks wrong
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: (none)
Type: bug | Status: patch
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): Phab:D4379
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by David Feuer

#14752: Unboxed sums documentation looks wrong -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: merge 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): Phab:D4379 Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * status: patch => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14752#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14752: Unboxed sums documentation looks wrong -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: bug | Status: closed Priority: high | Milestone: 8.4.1 Component: Documentation | Version: 8.2.2 Resolution: fixed | Keywords: UnboxedSums Operating System: Unknown/Multiple | Architecture: Type of failure: Documentation | Unknown/Multiple bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4379 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed * milestone: 8.4.2 => 8.4.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14752#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC