Skip to content

Should ‘coerce’ be levity polymorphic?

I'm not able to write coerce @Int# @Int# or coerce :: Double# -> Double#, just checking to see if its intentional or not

>>> :set -XTypeApplications
>>> :set -XMagicHash

>>> import Data.Coerce
>>> import GHC.Exts

>>>> :t coerce @Int
coerce @Int :: Coercible b Int => Int -> b
>>> :t coerce @Int#

<interactive>:1:1: error:
    Couldn't match a lifted type with an unlifted type
    When matching types
      b :: *
      Int# :: TYPE 'IntRep

<interactive>:1:9: error:
    • Expecting a lifted type, but ‘Int#’ is unlifted
    • In the type ‘Int#’
      In the expression: coerce @Int#

This was needed for #13592.

Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
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