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,248
    • Issues 5,248
    • 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
  • #9211
Closed
Open
Issue created Jun 16, 2014 by Simon Peyton Jones@simonpjDeveloper

Untouchable type variable (regression from 7.6)

Oleg says: what used to type check in GHC 7.4.1 (and I think in 7.6.2, although I no longer have access to that version) fails in GHC 7.8.2.

The following program type-checks with GHC 7.4.1 and GHC 7.8.2:

{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}

module T where

foo :: (forall f g. (Functor f) => f a -> f b) -> [a] -> [b]
-- foo :: (forall f g. (Functor f, g ~ f) => g a -> g b) -> [a] -> [b]
foo tr x = tr x

t = foo (fmap not) [True]

The following code (which differs only in the signature of foo)

{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}

module T where

-- foo :: (forall f g. (Functor f) => f a -> f b) -> [a] -> [b]
foo :: (forall f g. (Functor f, g ~ f) => g a -> g b) -> [a] -> [b]
foo tr x = tr x

t = foo (fmap not) [True]

type-checks with 7.4.1 but not with 7.8.2. The latter reports the error

    Couldn't match type `b' with `Bool'
      `b' is untouchable
        inside the constraints (Functor f, g ~ f)
        bound by a type expected by the context:
                   (Functor f, g ~ f) => g Bool -> g b
        at /tmp/t.hs:12:5-25
      `b' is a rigid type variable bound by
          the inferred type of t :: [b] at /tmp/t.hs:12:1
    Expected type: Bool -> b
      Actual type: Bool -> Bool
    Relevant bindings include t :: [b] (bound at /tmp/t.hs:12:1)
    In the first argument of `fmap', namely `not'
    In the first argument of `foo', namely `(fmap not)'

Giving t the type signature [Bool] fixes the problem. Alas, I come across the similar untouchable error in situations where giving the type signature is quite difficult (in local bindings, with quite large types).

Trac metadata
Trac field Value
Version 7.8.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking