Skip to content
GitLab
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 5,247
    • Issues 5,247
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 562
    • Merge requests 562
  • 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 CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #14319
Closed
Open
Issue created Oct 04, 2017 by David Feuer@treeowlReporter

Stuck type families can lead to lousy error messages

I first noticed this problem at the type level:

{-# language TypeFamilies, TypeInType, ScopedTypeVariables #-}

module ArityError where
import Data.Kind
import GHC.TypeLits
import Data.Proxy

type family F (s :: Symbol) :: Type
type family G (s :: Symbol) :: F s
type instance G "Hi" = Maybe

This produces the error message

ArityError.hs:10:24: error:
    • Expecting one more argument to ‘Maybe’
      Expected kind ‘F "Hi"’, but ‘Maybe’ has kind ‘* -> *’
    • In the type ‘Maybe’
      In the type instance declaration for ‘G’
   |
10 | type instance G "Hi" = Maybe
   |                        ^^^^^

This looks utterly bogus: F "Hi" is stuck, so we have no idea what arity it indicates.


I just realized we have a similar problem at the term level:

f :: forall (s :: Symbol). Proxy s -> F s
f _ _ = undefined

produces

ArityError.hs:14:1: error:
    • Couldn't match expected type ‘F s’ with actual type ‘p0 -> a0’
      The type variables ‘p0’, ‘a0’ are ambiguous
    • The equation(s) for ‘f’ have two arguments,
      but its type ‘Proxy s -> F s’ has only one
    • Relevant bindings include
        f :: Proxy s -> F s (bound at ArityError.hs:14:1)
   |
14 | f _ _ = undefined
   | ^^^^^^^^^^^^^^^^^

The claim that Proxy s -> F s has only one argument is bogus; we only know that it has at least one argument. The fix (I imagine) is to refrain from reporting arity errors when we don't know enough about the relevant arities.

Edited Mar 10, 2019 by David Feuer
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking