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,932
    • Issues 4,932
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 464
    • Merge requests 464
  • 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
  • #13530
Closed
Open
Created Apr 05, 2017 by Simon Peyton Jones@simonpjDeveloper

Horrible error message due to TypeInType

Consider this

{-# LANGUAGE MagicHash, UnboxedTuples #-}

module Foo where

import GHC.Exts

g :: Int -> (# Int#, a #)
g (I# y) = (# y, undefined #)

f :: Int -> (# Int#, Int# #)
f x = g x

With GHC 8 we get

Foo.hs:11:7: error:
    • Couldn't match a lifted type with an unlifted type
      Expected type: (# Int#, Int# #)
        Actual type: (# Int#, Int# #)

What a terrible error message!! It was much better in GHC 7.10:

Foo.hs:11:7:
    Couldn't match kind ‘*’ with ‘#’
    When matching types
      a0 :: *
      Int# :: #
    Expected type: (# Int#, Int# #)
      Actual type: (# Int#, a0 #)

What's going on?

The constraint solver sees

[W] alpha::TYPE LiftedRep  ~  Int#::TYPE IntRep

So it homogenises the kinds, and unifies alpha (this did not happen in GHC 7.10), thus

alpha := Int# |> TYPE co

[W] co :: LiftedRep ~ IntRep

Of course the new constraint fails. But since we have unified alpha, when we print out the types are are unifying they both look like (# Int#, Int# #) (there's a suppressed cast in the second component).

I'm not sure what to do here.

(I tripped over this when debugging #13509 (closed).)

Edited Mar 10, 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