Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,273
    • Issues 4,273
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 413
    • Merge Requests 413
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #17879

Closed
Open
Opened Feb 26, 2020 by Bryan R@chreekat

Better error message for attempt to use : with operator declarations

Motivation

If a user is unfamiliar with the restriction on : , the message can lead them pretty far astray.

Example 1:

Prelude> let (:=) :: Show a => String -> a -> String

<interactive>:3:5:error:
    Invalid type signature: (:=) :: ...
    Should be of form <variable> :: <type>

Example 2:

> let (:=) a b = undefined

<interactive>:2:5: error:
    Not in scope: data constructor ‘:=’
    Perhaps you meant one of these:
      variable ‘>=’ (imported from Prelude),
      variable ‘==’ (imported from Prelude),
      variable ‘/=’ (imported from Prelude)
> data Foo a b = a := b
> 

Proposal

Less a proposal, and more a hypothesis. Example 2 above could maybe look like

> let (:=) a b = undefined

<interactive>:2:5: error:
    Syntax restriction: ':' is reserved for data constructor operators

I say "more a hypothesis" because I'm not sure that message is precise enough.

Edited Feb 26, 2020 by Bryan R
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#17879