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,346
    • Issues 5,346
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 566
    • Merge requests 566
  • 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
  • #9323
Closed
Open
Issue created Jul 17, 2014 by Simon Peyton Jones@simonpjDeveloper

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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking