Skip to content

Template Haskell thinks an unboxed tuple name is illegal to splice in

{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE UnboxedTuples #-}
module Bug where

import Language.Haskell.TH.Lib
import Language.Haskell.TH.Syntax

$(do let ubxTup = conT (unboxedTupleTypeName 2) `appT` conT ''Int
                                                `appT` conT ''Int
     x <- newName "x"
     y <- newName "y"

     [d| f :: $(ubxTup) -> $(ubxTup)
         f $(conP (unboxedTupleDataName 2) [varP x, varP y])
             = $(conE (unboxedTupleDataName 2) `appE` varE x
                                               `appE` varE y)
      |])
$ /opt/ghc/8.0.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )

Bug.hs:8:3: error:
    Illegal type constructor or class name: ‘(#,#)’
    When splicing a TH declaration:
      f_0 :: GHC.Tuple.(#,#) GHC.Types.Int GHC.Types.Int ->
       GHC.Tuple.(#,#) GHC.Types.Int GHC.Types.Int

Patch coming soon.

Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information