Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 5.5k
    • Issues 5.5k
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 636
    • Merge requests 636
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #21093
Closed
Open
Issue created Feb 16, 2022 by Bodigrim@BodigrimDeveloper

Rule with KnownNat constraint does not fire

Summary

{-# RULES "foo -> bar" forall (x :: KnownNat m => Proxy m). foo x = bar x #-} does not fire.

Steps to reproduce

{-# LANGUAGE DataKinds, PolyKinds, KindSignatures #-}
{-# OPTIONS_GHC -O2 -Wall -ddump-rule-firings #-}

module Main where

import Data.Proxy
import GHC.TypeNats

foo :: Proxy m -> Int
foo _ = 42
{-# NOINLINE foo #-}

bar :: KnownNat m => Proxy m -> Int
bar _ = 24

{-# RULES "foo -> bar" forall (x :: KnownNat m => Proxy m). foo x = bar x #-}

main :: IO ()
main = print $ foo (Proxy :: Proxy 1)
$ ghc-9.2 Modd.hs && ./Modd
[1 of 1] Compiling Main             ( Modd.hs, Modd.o )
Rule fired: Class op show (BUILTIN)
Linking Modd ...
42

Expected behavior

I'd expect to see rule foo -> bar fired and the program to return 24.

This example has been distilled from https://github.com/Bodigrim/mod/issues/14

Environment

  • GHC version used: 9.2.1
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking