Skip to content

Forall'd variable ‘$rcobox’ is not bound in RULE lhs

I tried to add this rule to the code of Data.Map:

{-# RULES
"mapKeysMonotonic/coerce" mapKeysMonotonic coerce = coerce
 #-}

but it would not go through:

libraries/containers/Data/Map/Base.hs:1800:1: warning:
    Forall'd variable $rcobox is not bound in RULE lhs
      Orig bndrs: [k2, a, $rcobox]
      Orig lhs: let {
                  cobox_ab8H :: Coercible k2 k2
                  [LclId, Str=DmdType]
                  cobox_ab8H =
                    MkCoercible @ * @ k2 @ k2 @~ (<k2>_R :: k2 ~R# k2) } in
                mapKeysMonotonic @ k2 @ k2 @ a (coerce @ k2 @ k2 cobox_ab8H)
      optimised lhs: mapKeysMonotonic
                       @ k2
                       @ k2
                       @ a
                       (\ (tpl_B2 :: k2) ->
                          case cobox_ab8H of _ [Occ=Dead] { MkCoercible tpl_B3 -> tpl_B2 })

The same syntax works for mapping the second parameter, i.e.

{-# RULES
"map/coerce" map coerce = coerce
 #-}

(this still Data.Map’s map).

This blocks https://github.com/haskell/containers/pull/163

I’ll see if I can produce a stand-alone testcase.

Trac metadata
Trac field Value
Version 7.11
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