#4937: Remove indirections caused by sum types, such as Maybe ------------------------------+--------------------------------------------- Reporter: tibbe | Owner: Type: feature request | Status: new Priority: normal | Milestone: 7.4.1 Component: Compiler | Version: 7.0.1 Resolution: | Keywords: Testcase: | Blockedby: Difficulty: | Os: Unknown/Multiple Blocking: | Architecture: Unknown/Multiple Failure: None/Unknown | ------------------------------+---------------------------------------------
Comment(by simonmar): Replying to [comment:11 tibbe]: > Couldn't we represent a sum of pointers (e.g. `data Either a b = Left a | Right b`) as a new heap object, a sum-pointer object, which uses tag bits to distinguish the constructors? But `Either` already is a heap object, and we have tag bits to distinguish `Left` from `Right` in the pointer itself. > This, together with the optimization to distinguish nullary constructors, would allow this data type to be represented with a single pointer: > > {{{ > data Elem k v = Null | Key k | Value v | Subtree (Tree k v) > }}} So think about the representation of `Elem (Elem k v) v'`. You can't represent that with a single pointer, because you need two sets of tag bits. -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4937#comment:12> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs