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.6k
    • Issues 5.6k
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 664
    • Merge requests 664
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Model experiments
  • 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
  • #17485

Allow WARNING pragma on instances

Motivation

In a software project, some instances should maybe never be implemented, for instance Eq on very large data structures.

I can ensure this by giving a dummy implementation like:

instance Eq D where
  (==) = undefined

However, this gives me only a runtime error, but I wish to get a compile-time error if trying to use equality on D, just as if I hadn't implemented an instance in the first place.

I could get a compile-time alert if it was possible to attach WARNING or DEPRECATED pragmas to instances or method implementations.

Proposal

Allow WARNING and DEPRECATED on instances, e.g.:

instance Eq D {-# WARNING: "No equality on D!" #-} where
  (==) = undefined

The behavior should be similar to a missing implementation of Eq D, i.e., a warning generated during type-checking.

Maybe it is possible to throw a hard error also? (I did not find an ERROR pragma.)

Edited Nov 16, 2019 by Andreas Abel
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking