[GHC] #12977: Template Haskell: unboxedTupleTypeName doesn't handle unboxed 0- and 1-tuples

GHC ghc-devs at haskell.org
Wed Dec 14 16:40:13 UTC 2016


#12977: Template Haskell: unboxedTupleTypeName doesn't handle unboxed 0- and
1-tuples
-------------------------------------+-------------------------------------
           Reporter:  RyanGlScott    |             Owner:  RyanGlScott
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Template       |           Version:  8.0.1
  Haskell                            |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 GHC has a notion of unboxed 0-tuples and 1-tuples:

 {{{
 λ> :set -XUnboxedTuples
 λ> :k (##)
 (##) :: TYPE 'GHC.Types.VoidRep
 λ> :k (# Int #)
 (# Int #) :: TYPE 'GHC.Types.UnboxedTupleRep
 }}}

 But it is impossible to acquire the `Name`s of these type constructors
 using `unboxedTupleTypeName` from `template-haskell`:

 {{{
 λ> :set -XTemplateHaskell
 λ> :m + Language.Haskell.TH Language.Haskell.TH.Syntax
 λ> :k $(conT (unboxedTupleTypeName 0))

 <interactive>:1:1: error:
     • Exception when trying to run compile-time code:
         unboxedTupleTypeName 0
 CallStack (from HasCallStack):
   error, called at libraries/template-
 haskell/Language/Haskell/TH/Syntax.hs:1179:26 in template-
 haskell:Language.Haskell.TH.Syntax
       Code: conT (unboxedTupleTypeName 0)
     • In the untyped splice: $(conT (unboxedTupleTypeName 0))
 λ> :k $(conT (unboxedTupleTypeName 1))

 <interactive>:1:1: error:
     • Exception when trying to run compile-time code:
         unboxedTupleTypeName 1
 CallStack (from HasCallStack):
   error, called at libraries/template-
 haskell/Language/Haskell/TH/Syntax.hs:1180:26 in template-
 haskell:Language.Haskell.TH.Syntax
       Code: conT (unboxedTupleTypeName 1)
     • In the untyped splice: $(conT (unboxedTupleTypeName 1))
 }}}

 And similarly for `unboxedTupleDataName`.

 This is because of
 [http://git.haskell.org/ghc.git/blob/9c9a2229fe741c55a8fb8d0c6380ec066a77722b:/libraries
 /template-haskell/Language/Haskell/TH/Syntax.hs#l1184 silly restrictions]
 put in place on the definitions of `unboxedTupleTypeName` and
 `unboxedTupleDataName` within `template-haskell`:

 {{{#!hs
 -- Unboxed tuple data and type constructors
 -- | Unboxed tuple data constructor
 unboxedTupleDataName :: Int -> Name
 -- | Unboxed tuple type constructor
 unboxedTupleTypeName :: Int -> Name

 unboxedTupleDataName 0 = error "unboxedTupleDataName 0"
 unboxedTupleDataName 1 = error "unboxedTupleDataName 1"
 unboxedTupleDataName n = mk_unboxed_tup_name (n-1) DataName

 unboxedTupleTypeName 0 = error "unboxedTupleTypeName 0"
 unboxedTupleTypeName 1 = error "unboxedTupleTypeName 1"
 unboxedTupleTypeName n = mk_unboxed_tup_name (n-1) TcClsName
 }}}

 It should be possible to lift this restriction. I'll work on this.

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


More information about the ghc-tickets mailing list