Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,867
    • Issues 4,867
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 457
    • Merge requests 457
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • 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 Compiler
  • GHCGHC
  • Issues
  • #18529
Closed
Open
Created Aug 03, 2020 by Richard Eisenberg@raeDeveloper

GHC fails to infer type with FlexibleContexts

If I say

{-# LANGUAGE MultiParamTypeClasses, FlexibleContexts #-}

module Bug where

class C a b where
  op :: a -> b -> ()

-- foo :: (C a Integer) => a -> ()
foo x = op x 3

then GHC complains that the variable b0 in the type of foo is ambiguous, because it tries to produce C a b => a -> () as the type of foo. Instead, it shouldn't quantify b, letting it default to Integer.

The solution is to use oclose instead of growThetaTyVars in decideQuantifiedTyVars. This will respect functional dependencies, quantifying over b only when a fundep exists from a to b.

I will fix in ongoing work (in the wip/derived-refactor branch).

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