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,262
    • Issues 4,262
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 405
    • Merge Requests 405
  • 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
  • #18204

Closed
Open
Opened May 20, 2020 by John Ericson@Ericson2314Developer

Change GHC.Hs.* so boundary betwen function binds and pattern binds matches Haskell Report

@int-index described the issues better than myself in the thread for https://github.com/ghc-proposals/ghc-proposals/pull/254, so I will paraphrase.

The standard says:

  • x = 5 is a PatBind

  • x :: Int = 5 is a PatBind

The GHC implementation does not match this specification at the moment:

  • x = 5 is a FunBind (in GHC)

  • x :: Int = 5 is a PatBind (in GHC)

Why is that? Here are some comments from GHC sources:

Reason 1: Special case for type inference: see 'TcBinds.tcMonoBinds'.
Reason 2: Instance decls can only have FunBinds, which is convenient.
          If you change this, you'll need to change e.g. rnMethodBinds

When a signature is added to a variable binding, it is interpreted as a pattern binding, as function bindings cannot have signatures:

x :: Int = 5  -- accepted as PatBind, cannot be a FunBind due to the signature!

However, with Proposal 228 (tracking issue #18203) accepted, we do have signatures in function bindings, and it is a hard sell that x = 5 is a FunBind while x :: Int = 5 is a PatBind.

By making GHC match the spec, those can both be PatBinds. Then we could drop the strictness flag from FunBind, which frankly does not belong there.

However, we need to come up with solutions to the Reason 1 and Reason 2 from that GHC comment. Both of them sound more like engineering issues than something fundamental, so I think we can pull this off?

#1474 (closed) is a (currently stale) attempt at doing this.

Edited May 20, 2020 by John Ericson
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#18204