Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • 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,826
    • Issues 4,826
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 441
    • Merge requests 441
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #15845

Closed
Open
Created Nov 02, 2018 by Ryan Scott@RyanGlScottMaintainer

TH eta-reduces away explicit foralls in data family instances

Consider the following code:

{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
module Bug where

import Language.Haskell.TH

data family F1 a b
data instance F1 [a] b = MkF1

data family F2 a
data instance F2 a = MkF2

$(do i1 <- reify ''F1
     i2 <- reify ''F2
     runIO $ mapM_ (putStrLn . pprint) [i1, i2]
     pure [])
$ ~/Software/ghc2/inplace/bin/ghc-stage2 --interactive Bug.hs
GHCi, version 8.7.20181101: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug              ( Bug.hs, interpreted )
data family Bug.F1 (a_0 :: *) (b_1 :: *) :: *
data instance forall (a_2 :: *). Bug.F1 ([a_2]) b_3 = Bug.MkF1
data family Bug.F2 (a_0 :: *) :: *
data instance Bug.F2 a_1 = Bug.MkF2

The output here is quite baffling:

  • In the F1 instance, we have an explicit forall which quantifies a_2 but not b_3!
  • In the F2 instance, there isn't an explicit forall at all despite the fact that there ought to be one, since there is a type variable a_1 in this instance.

The culprit in both of the bullet points above is the fact that GHC eta-reduces its internal representation of data family instance axioms. This is the same thing which caused #9692 (closed) and #14179 (closed), in fact. Luckily, the same fix for those tickets will also work here.

Patch incoming.

Trac metadata
Trac field Value
Version 8.7
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
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