Skip to content

$(tupE [ [|x|] ]) /= Unit x

Summary

Today in #haskell http://tunes.org/~nef/logs/haskell/20.04.24

11:12:58 <mniip> ghc-prim:GHC.Tuple.Unit{(w) tc 42}  versus  ghc-prim:GHC.Tuple.Unit{tc rdRN}
11:14:39 <mniip> (w) indicating the wired in id (likely the name from the type sig)
11:22:10 <mniip> looks like a TH/renamer bug

Steps to reproduce

{-# LANGUAGE TemplateHaskell #-}
import Language.Haskell.TH
import GHC.Tuple

main = case $( tupE [ [| "ok" |] ] ) of Unit x -> putStrLn x
{-
runghc -dppr-debug unit.hs

unit.hs:5:41: error:
    • Couldn't match expected type ‘ghc-prim:GHC.Tuple.Unit{(w) tc 42}
                                      (ghc-prim:GHC.Types.[]{(w) tc 3Q}
                                         ghc-prim:GHC.Types.Char{(w) tc 3g})’
                  with actual type ‘ghc-prim:GHC.Tuple.Unit{tc rIJ}
                                      base:GHC.Base.String{tc rf1}’
      NB: ‘ghc-prim:GHC.Tuple.Unit{tc rIJ}’ is defined in ‘GHC.Tuple’
          ‘ghc-prim:GHC.Tuple.Unit{(w) tc 42}’ is defined in ‘GHC.Tuple’
    • In the pattern: ghc-prim:GHC.Tuple.Unit{d rIK} (x{v a2dg})
      In a case alternative:
          {unit.hs:5:41-46}
          ghc-prim:GHC.Tuple.Unit{d rIK} (x{v a2dg})
            -> {unit.hs:5:51-60}
               base:System.IO.putStrLn{v rt9}
                 {unit.hs:5:60}
                 x{v a2dg}
      In the expression:
        {unit.hs:5:8-60}
        case
            {unit.hs:5:13-36}
            (Unit {unit.hs:5:16-34}
                  "ok")
        of {
          {unit.hs:5:41-46}
          ghc-prim:GHC.Tuple.Unit{d rIK} (x{v a2dg})
            -> {unit.hs:5:51-60}
               base:System.IO.putStrLn{v rt9}
                 {unit.hs:5:60}
                 x{v a2dg} }
    • Relevant bindings include
        main:Main.main{v rOW} :: ghc-prim:GHC.Types.IO{tc 31Q}
                                   ghc-prim:GHC.Tuple.(){(w) tc 40}
          (bound at unit.hs:5:1)
  |
5 | main = case $( tupE [ [| "ok" |] ] ) of Unit x -> putStrLn x
  |                

-}

Expected behavior

It should print "ok"

Environment

  • GHC version used: 8.10.1

Optional:

  • Operating System:
  • System Architecture:
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information