For this program:
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE TemplateHaskellQuotes #-}
import GHC.Prim
import Language.Haskell.TH
ts :: [Name]
ts = ['void#]
GHC 9.12.1 complains:
$ ghci -package ghc-prim -package template-haskell a.hs
GHCi, version 9.12.1: https://www.haskell.org/ghc/ :? for help
[1 of 2] Compiling Main ( a.hs, interpreted )
a.hs:8:7: warning: [GHC-68441] [-Wdeprecations]
In the use of ‘void#’ (imported from GHC.Prim):
Deprecated: " Use an unboxed unit tuple instead "
|
8 | ts = ['void#]
| ^^^^^^
Ok, one module loaded.
How do I avoid this warning? I tried:
ts = ['(# #)]
but that results in:
*Main> :r
[1 of 2] Compiling Main ( a.hs, interpreted ) [Source file changed]
a.hs:8:11: error: [GHC-58481]
parse error on input ‘#’
|
8 | ts = ['(# #)]
| ^
Failed, no modules to be reloaded.
What's the proper syntax for indicating an unboxed unit tuple in GHC 9.12.1?
You'll need to enable {-# LANGUAGE UnboxedTuples #-}
for the syntax to be recognized. (And, incidentally, you'll no longer need MagicHash
.) Then it should work okay:
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE TemplateHaskellQuotes #-}
module UnitTuple where
import Language.Haskell.TH
ts :: [Name]
ts = ['(# #)]