Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Support
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
    • Insights
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
    • Locked Files
  • Issues 3,631
    • Issues 3,631
    • List
    • Boards
    • Labels
    • Milestones
  • Merge Requests 203
    • Merge Requests 203
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Security & Compliance
    • Security & Compliance
    • Dependency List
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #9323

Closed
Open
Opened Jul 17, 2014 by Simon Peyton Jones@simonpj
  • Report abuse
  • New issue
Report abuse New issue

Confusing type error behaviour

Compile this example with GHC 7.8.3.

module Foo where

broken :: [Int]
broken = ()

ambiguous :: a -> String
ambiguous _ = show 0

You get

Foo.hs:4:10:
    Couldn't match expected type ‘[Int]’ with actual type ‘()’
    In the expression: ()
    In an equation for ‘broken’: broken = ()

Foo.hs:7:15:
    No instance for (Show a0) arising from a use of ‘show’
    The type variable ‘a0’ is ambiguous

(and a similar ambiguous (Num a0) error).

But if you comment out broken, the program compiles, using the defaulting rules to choose a0 = Integer.

This is obviously wrong.

Reported by Evan Laforge.

Edited Mar 09, 2019 by Simon Peyton Jones

Related issues

  • Discussion
  • Designs
Assignee
Assign to
7.10.1
Milestone
7.10.1
Assign milestone
Time tracking
None
Due date
None
4
Labels
bug P::normal Trac import typechecker
Assign labels
  • View project labels
Reference: ghc/ghc#9323