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,268
    • Issues 4,268
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 408
    • Merge Requests 408
  • 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
  • #16115

Closed
Open
Opened Dec 31, 2018 by David Feuer@treeowlReporter

Missing associated type instance not reported with error

I noticed this SO question was caused by a warning disappearing as a result of the error it caused.

{-# language TypeFamilies, DataKinds #-}
module NoWarning where
data Nat = Zero | Succ Nat deriving Show
class FromList a where
  type Item a :: *
  fromList :: [Item a] -> a

instance FromList Nat where
  fromList [] = Zero
  fromList (a:as) = Succ (fromList as :: Nat)

fish :: Nat
fish = fromList [(),(),()]

If you delete fish, you get a nice warning:

NoWarning.hs:8:1: warning: [-Wmissing-methods]
    • No explicit associated type or default declaration for ‘Item’
    • In the instance declaration for ‘FromList Nat’
  |
8 | instance FromList Nat where
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^...

But with fish, all you get is

NoWarning.hs:13:18: error:
    • Couldn't match expected type ‘Item Nat’ with actual type ‘()’
    • In the expression: ()
      In the first argument of ‘fromList’, namely ‘[(), (), ()]’
      In the expression: fromList [(), (), ()]
   |
13 | fish = fromList [(),(),()]
   | 

That warning is the proper explanation of the problem, and it's just missing!

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