[GHC] #14542: Renamer / typechecker hang (UndecidableSuperClasses)

GHC ghc-devs at haskell.org
Tue Nov 28 22:21:10 UTC 2017


#14542: Renamer / typechecker hang (UndecidableSuperClasses)
-------------------------------------+-------------------------------------
           Reporter:  Iceland_jack   |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.3
           Keywords:                 |  Operating System:  Unknown/Multiple
  UndecidableSuperClasses            |
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Adapted from [https://gist.github.com/ekmett/b26363fc0f38777a637d hask],
 this does not look like a normal superclass loop. Loop is avoided by
 removing `instance (Category p, Category q) => Category (Nat p q)`.

 {{{#!hs
 {-# language KindSignatures #-}
 {-# language PolyKinds #-}
 {-# language DataKinds #-}
 {-# language TypeFamilies #-}
 {-# language RankNTypes #-}
 {-# language NoImplicitPrelude #-}
 {-# language FlexibleContexts #-}
 {-# language MultiParamTypeClasses #-}
 {-# language GADTs #-}
 {-# language ConstraintKinds #-}
 {-# language FlexibleInstances #-}
 {-# language TypeOperators #-}
 {-# language ScopedTypeVariables #-}
 {-# language DefaultSignatures #-}
 {-# language FunctionalDependencies #-}
 {-# language UndecidableSuperClasses #-}
 {-# language UndecidableInstances #-}
 {-# language TypeInType #-}

 import GHC.Types (Constraint, Type)

 type Cat i = i -> i -> Type

 newtype Y p a b = Y { getY :: p b a }

 class (Functor p, Dom p ~ Op p, Cod p ~ Nat p (->), Ob (Op p) ~ Ob p) =>
 Category (p :: Cat i) where
   type Op p :: Cat i
   type Op p = Y p

   type Ob p :: i -> Constraint

 class (Category (Dom f), Category (Cod f)) => Functor (f :: i -> j) where
   type Dom f :: Cat i
   type Cod f :: Cat j

 data Nat :: Cat i -> Cat j -> Cat (i -> j)

 instance (Category p, Category q) => Category (Nat p q)
 }}}

 I get

 {{{
 $ ghci2 -ignore-dot-ghci -v /tmp/Hangs.hs
 GHCi, version 8.3.20171122: http://www.haskell.org/ghc/  :? for help
 Glasgow Haskell Compiler, Version 8.3.20171122, stage 2 booted by GHC
 version 8.2.1
 ...
 Loading package integer-gmp-1.0.1.0 ... linking ... done.
 Loading package base-4.11.0.0 ... linking ... done.
 *** Parser [source]:
 !!! Parser [source]: finished in 0.66 milliseconds, allocated 0.136
 megabytes
 *** Desugar:
 *** Simplify [expr]:
 !!! Simplify [expr]: finished in 0.43 milliseconds, allocated 0.233
 megabytes
 *** CorePrep [expr]:
 !!! CorePrep [expr]: finished in 0.23 milliseconds, allocated 0.167
 megabytes
 *** ByteCodeGen [Ghci1]:
 !!! ByteCodeGen [Ghci1]: finished in 0.35 milliseconds, allocated 0.284
 megabytes
 *** Parser [source]:
 !!! Parser [source]: finished in 0.21 milliseconds, allocated 0.197
 megabytes
 *** Desugar:
 *** Simplify [expr]:
 !!! Simplify [expr]: finished in 0.52 milliseconds, allocated 0.268
 megabytes
 *** CorePrep [expr]:
 !!! CorePrep [expr]: finished in 0.23 milliseconds, allocated 0.113
 megabytes
 *** ByteCodeGen [Ghci1]:
 !!! ByteCodeGen [Ghci1]: finished in 0.46 milliseconds, allocated 0.334
 megabytes
 *** Chasing dependencies:
 Chasing modules from:
 !!! Chasing dependencies: finished in 0.14 milliseconds, allocated 0.047
 megabytes
 Stable obj: []
 Stable BCO: []
 unload: retaining objs []
 unload: retaining bcos []
 Ready for upsweep []
 Upsweep completely successful.
 *** Deleting temp files:
 Deleting:
 *** Chasing dependencies:
 Chasing modules from: */tmp/Hangs.hs
 !!! Chasing dependencies: finished in 6.10 milliseconds, allocated 10.504
 megabytes
 Stable obj: []
 Stable BCO: []
 unload: retaining objs []
 unload: retaining bcos []
 Ready for upsweep
   [NONREC
       ModSummary {
          ms_hs_date = 2017-11-28 22:14:57.810561584 UTC
          ms_mod = Main,
          ms_textual_imps = [(Nothing, GHC.Types)]
          ms_srcimps = []
       }]
 *** Deleting temp files:
 Deleting:
 compile: input file /tmp/Hangs.hs
 *** Checking old interface for Main (use -ddump-hi-diffs for more
 details):
 [1 of 1] Compiling Main             ( /tmp/Hangs.hs, interpreted )
 *** Parser [Main]:
 !!! Parser [Main]: finished in 2.63 milliseconds, allocated 4.821
 megabytes
 *** Renamer/typechecker [Main]:
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14542>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list