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
  • #11379
Closed
Open
Issue created Jan 08, 2016 by Ben Gamari@bgamari🐢Maintainer

Solver hits iteration limit in code without recursive constraints

This example (derived from xmonad-contrib) failed to compile with master,

{-# LANGUAGE ExistentialQuantification, RankNTypes, MultiParamTypeClasses,
             FunctionalDependencies, FlexibleInstances, FlexibleContexts #-}

module XMonad.Layout.MultiToggle where

import Data.Typeable

-- This appears to be the culprit
expand :: (HList ts a) => MultiToggleS ts l a -> MultiToggle ts l a
expand (MultiToggleS b ts) =
    resolve ts id
        (\x mt -> let g = transform' x in mt{ currLayout = g $ currLayout mt })
        (MultiToggle (EL b id) ts)

-- Removing the Typeable constraint here allows compilation to finish
class (Typeable t) => Transformer t a | t -> a where
    transform :: t
              -> l a
              -> (forall l'. l' a -> (l' a -> l a) -> b)
              -> b

data  EL l a = forall l'. EL (l' a) (l' a -> l a)

transform' :: (Transformer t a) => t -> EL l a -> EL l a
transform' t (EL l det) = undefined

data MultiToggleS ts l a = MultiToggleS (l a) ts
                         deriving (Read, Show)

data MultiToggle ts l a = MultiToggle{
    currLayout :: EL l a,
    transformers :: ts
}

class HList c a where
    resolve :: c -> b -> (forall t. (Transformer t a) => t -> b) -> b

failing during constraint solving with,,

XMonad/Layout/MultiToggle.hs:1:1: error:
    solveWanteds: too many iterations (limit = 4)
      Unsolved: WC {wc_simple =
                      [D] _ :: Transformer t a (CDictCan)
                      [D] _ :: a_aIoy ~ a (CNonCanonical)
                      [D] _ :: Typeable t (CDictCan)
                    wc_impl =
                      Implic {
                        TcLevel = 7
                        Skolems = (l :: * -> *)
                        No-eqs = True
                        Status = Unsolved
                        Given =
                        Wanted =
                          WC {wc_simple =
                                [W] $dTransformer_aIoM :: Transformer t a (CDictCan)}
                        Binds = Just EvBindsVar<aIoN>
                        the inferred type of g :: EL l_aIoL a_aIoK -> EL l_aIoL a_aIoK }}
      New superclasses found
      Set limit with -fconstraint-solver-iterations=n; n=0 for no limit

Lifting the solver iteration limit just results in a loop.

I suspect the issue may be in the Typeable solving logic, as removing the Typable constraint from Transformer's head allows compilation to proceed.

Edited Mar 10, 2019 by Ben Gamari
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking