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,261
    • Issues 5,261
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 567
    • Merge requests 567
  • 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
  • #5012
Closed
Open
Issue created Mar 10, 2011 by Daniel Gorín@jcpetruzzaReporter

haskell 98 program does not typecheck when compiled with -XTypeFamilies

Consider the following valid Haskell 98 function:

f x =
  do let apply p r = mapM p (r x)
     a <- apply id     fst
     b <- apply return snd
     return (a ++ b)

It compiles fine with both ghc 6.12.x and ghc 7. However, if I add the -XTypeFamilies flag to ghc 7 it is rejected with:

mono.hs:5:17:
    Occurs check: cannot construct the infinite type: a0 = m0 a0
    Expected type: m0 a0 -> m0 a0
      Actual type: m0 a0 -> m0 (m0 a0)
    In the first argument of `apply', namely `return'
    In a stmt of a 'do' expression: b <- apply return snd

If one adds a type signature, the error message gets more intimidating.

A project of mine uses Type Families in some modules so TypeFamilies is listed as an extension in cabal's configuration file; therefore, it is being passed to every module. That is how I stumbled upon this problem.

Trac metadata
Trac field Value
Version 7.0.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
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