最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

haskell - Referring to unboxed unit tuple type - Stack Overflow

programmeradmin0浏览0评论

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: /  :? 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?

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./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?

Share Improve this question asked Mar 12 at 21:49 aliasalias 30.6k2 gold badges29 silver badges48 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

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 = ['(# #)]
发布评论

评论列表(0)

  1. 暂无评论