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,828
    • Issues 4,828
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 446
    • Merge requests 446
  • 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
  • #19042

Closed
Open
Created Dec 09, 2020 by Ryan Scott@RyanGlScottMaintainer

Regression: HEAD incurs a reduction stack overflow on program involving type equality

Originally observed in a head.hackage build here.

The following code, minimized from the plots-0.1.1.2 library, fails to typecheck on GHC HEAD (I tried using commit 62ed6957) but does typecheck with GHC 8.10.2 and 9.0.1-alpha1:

{-# LANGUAGE GADTs               #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies        #-}
{-# LANGUAGE TypeOperators       #-}
module Plots.Types where

import Data.Functor
import Data.Typeable

type family N a

data StyledPlot n where
  StyledPlot :: Typeable p => p -> StyledPlot (N p)

styledPlot :: forall p f.
              (Typeable p, Applicative f)
           => (p -> f p)
           -> StyledPlot (N p) -> f (StyledPlot (N p))
styledPlot f s@(StyledPlot p) =
  case eq p of
    Just Refl -> f p <&> \p' -> StyledPlot p'
    Nothing   -> pure s
  where eq :: Typeable a => a -> Maybe (a :~: p)
        eq _ = eqT

On HEAD, this produces the following error:

$ ~/Software/ghc2/inplace/bin/ghc-stage2 Bug.hs
[1 of 1] Compiling Plots.Types      ( Bug.hs, Bug.o )

Bug.hs:21:33: error:
    • Reduction stack overflow; size = 201
      When simplifying the following type: N p1
      Use -freduction-depth=0 to disable this check
      (any upper bound you could choose might fail unpredictably with
       minor updates to GHC, so disabling the check is recommended if
       you're sure that type checking should terminate)
    • In the expression: StyledPlot p'
      In the second argument of ‘(<&>)’, namely ‘\ p' -> StyledPlot p'’
      In the expression: f p <&> \ p' -> StyledPlot p'
   |
21 |     Just Refl -> f p <&> \p' -> StyledPlot p'
   |                                 ^^^^^^^^^^^^^
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking