[GHC] #14662: Partial type signatures + mutual recursion = confusion

GHC ghc-devs at haskell.org
Sat May 26 22:13:42 UTC 2018


#14662: Partial type signatures + mutual recursion = confusion
-------------------------------------+-------------------------------------
        Reporter:  goldfire          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.2
      Resolution:                    |             Keywords:
                                     |  PartialTypeSignatures
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by mnislaih):

 How about polymorphic recursion with a type wildcard only in the
 constraint ?

 The minimal failing example I have is:
 {{{
 data App a where
   Pure :: a -> App a
   App :: App (a -> b) -> App a -> App b

 f :: _ => App a -> Maybe a
 f (App a b) = f a <*> f b
 f (Pure x) = pure x
 f _ = Nothing
 }}}

 Fails in 8.2.x and 8.4.2 with:

 {{{
      • Occurs check: cannot construct the infinite type: a ~ a1 -> a
        Expected type: App a
          Actual type: App (a1 -> a)
      • In the first argument of ‘f’, namely ‘a’
        In the first argument of ‘(<*>)’, namely ‘f a’
        In the expression: f a <*> f b
      • Relevant bindings include
          b :: App a1
            (bound at /Users/pepe/scratch/debug/.stack-work/intero
 /intero19866fqh-TEMP.hs:13:10)
          a :: App (a1 -> a)
            (bound at /Users/pepe/scratch/debug/.stack-work/intero
 /intero19866fqh-TEMP.hs:13:8)
          f :: App a -> Maybe a
            (bound at /Users/pepe/scratch/debug/.stack-work/intero
 /intero19866fqh-TEMP.hs:13:1) (intero)
 }}}

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


More information about the ghc-tickets mailing list