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,252
    • Issues 5,252
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 577
    • Merge requests 577
  • 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
  • #11599
Closed
Open
Issue created Feb 18, 2016 by Gabor Greif@ggreif💬Developer

Why is UndecidableInstances required for an obviously terminating type family?

In below (working) snippet

{-# LANGUAGE DataKinds, KindSignatures, TypeFamilies, UndecidableInstances #-}

type family Rev (acc :: [*]) (ts :: [*]) :: [*] where
  Rev acc '[] = acc
  Rev acc (t ': ts) = Rev (t ': acc) ts

type Reverse ts = Rev '[] ts

the Rev does an exhaustive pattern match on its second argument and recurses on strictly smaller data.

*Main> :kind! Reverse [Char, Bool, Float]
Reverse [Char, Bool, Float] :: [*]
= '[Float, Bool, Char]

So when I remove UndecidableInstances it is not clear to me why this would be rejected :-(

error:
      The type family application  Rev (a : acc) as 
        is no smaller than the instance head
      (Use UndecidableInstances to permit this)
      In the equations for closed type family  Rev 
      In the type family declaration for  Rev 
Failed, modules loaded: none.

I tried this on GHC v8.1.today, but older GHCs behave the same.

Trac metadata
Trac field Value
Version 8.1
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