[GHC] #15617: Unboxed tuples/sum error message on `a = show 5` in expression evaluation and interactive modes

GHC ghc-devs at haskell.org
Thu Sep 13 10:30:53 UTC 2018


#15617: Unboxed tuples/sum error message on `a = show 5` in expression evaluation
and interactive modes
-------------------------------------+-------------------------------------
        Reporter:  ChaiTRex          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.6.1-beta1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Poor/confusing    |  Unknown/Multiple
  error message                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by osa1):

 * cc: simonpj (added)


Comment:

 This is because the simplifier introduces a call to a worker function that
 returns an unboxed tuple.

 This is the original expression:

 {{{
 -- RHS size: {terms: 3, types: 1, coercions: 0, joins: 0/0}
 a :: String
 [LclIdX]
 a = show @ Integer GHC.Show.$fShowInteger 5
 }}}

 The simplifier transforms this to

 {{{
 -- RHS size: {terms: 4, types: 1, coercions: 0, joins: 0/0}
 a :: String
 [LclIdX,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,
          WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 140 0}]
 a = GHC.Show.$fShowInteger_$cshowsPrec
       GHC.Show.$fShow(,)1 5 (GHC.Types.[] @ Char)
 }}}

 and then

 {{{
 -- RHS size: {terms: 9, types: 11, coercions: 0, joins: 0/0}
 a :: String
 [LclIdX,
  Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,
          WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 160 30}]
 a = case GHC.Show.$w$cshowsPrec4 0# 5 (GHC.Types.[] @ Char) of
     { (# ww3_a1Xd, ww4_a1Xe #) ->
     GHC.Types.: @ Char ww3_a1Xd ww4_a1Xe
     }
 }}}

 Here the scrutinee returns an unboxed tuple, and we can't compile this
 expression to bytecode.

 Some ideas:

 - Ignore optimization settings in GHCi and always compile things with all
   optimizations disabled, to avoid introducing unboxed tuples and sums as
 a
   result of inlining worker functions etc.

 - Somehow teach simplifier to not introduce unboxed tuples/sums (seems
 like too
   much work, we may be able to implement unboxed tuple/sum support with
 same
   effort).

 - Implement unboxed tuple and sum support for GHCi.

 - Improve error message and mention that this may happen as a result of
   optimizations (maybe only show this if optimizations are enabled).

 Any other ideas?

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


More information about the ghc-tickets mailing list