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,393
    • Issues 4,393
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 379
    • Merge Requests 379
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #11458

Closed
Open
Opened Jan 19, 2016 by Simon Peyton Jones@simonpjDeveloper

Terrible failure of type inference in visible type application

Consider

-- optIntArg :: (Maybe Int -> t2) -> (t2,t2)
optIntArg f = (f Nothing, f (Just True))

This is rejected (by HEAD)

T11379a.hs:5:30: error:
    * Couldn't match type `a' with `Bool'
      `a' is a rigid type variable bound by
        a type expected by the context:
          forall a. Maybe a
        at T11379a.hs:5:30
      Expected type: forall a. Maybe a
        Actual type: Maybe Bool
    * In the first argument of `f', namely `(Just True)'
      In the expression: f (Just True)
      In the expression: (f Nothing, f (Just True))

but if you put the tuple components the other way round, it works fine

optIntArg f = (f (Just True), f Nothing)

Adding the commented-out signature also makes it work fine.

I'm almost certain that this is caused by visible type application; perhaps Nothing gets delayed instantiation, and then f's type becomes forall a. Maybe a. Utterly bogus.

I suspect it'll be fixed by Richards ReturnTv work, but let's make sure it is. We can't release this!!

Trac metadata
Trac field Value
Version 7.10.3
Type Bug
TypeOfFailure OtherFailure
Priority highest
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
8.0.1
Milestone
8.0.1 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#11458