[GHC] #981: implicit parameters, type synonyms, and $

GHC trac at galois.com
Sat Dec 9 06:15:05 EST 2006


#981: implicit parameters, type synonyms, and $
-----------------------------+----------------------------------------------
 Reporter:  jefb at galois.com  |          Owner:         
     Type:  bug              |         Status:  new    
 Priority:  normal           |      Milestone:         
Component:  Compiler         |        Version:  6.6    
 Severity:  normal           |     Resolution:         
 Keywords:                   |     Difficulty:  Unknown
 Testcase:                   |   Architecture:  Unknown
       Os:  MacOS X          |  
-----------------------------+----------------------------------------------
Comment (by benl):

 I don't think the type synonyms are the problem here.

 For the following code,
 {{{
 f c = g $ c

 g :: ((?env :: Int) => Char) -> ((?env :: Int) => Char)
 g d = d
 }}}

 6.4.1 infers
 {{{
 f :: (?env::Int) => Char -> Char
 }}}

 but 6.7 infers
 {{{
 f :: (?env::Int) => ((?env::Int) => Char) -> Char
 }}}

 If you add '''either''' sig to 6.4.1 then it's happy, but 6.7 chokes on
 both with

 {{{
     Couldn't match expected type `(?env::Int) => Char'
            against inferred type `Char'
     In the second argument of `($)', namely `c'
     In the expression: g $ c
     In the definition of `f': f c = g $ c
 }}}


 I'll need to think some more about whether it's a good idea to make these
 two equivalent ... but notice that if you change the type Char to (Char ->
 Char):

 {{{
 f :: ((?env :: Int) => (Char -> Char)) -> ((?env :: Int) => (Char ->
 Char))
 f c = g $ c

 g :: ((?env :: Int) => (Char -> Char)) -> ((?env :: Int) => (Char ->
 Char))
 g d = d
 }}}

 then 6.4.1 is still happy, but 6.7 gives

 {{{
     Couldn't match expected type `?env::Int'
            against inferred type `Char'
     Probable cause: `c' is applied to too many arguments
     In the second argument of `($)', namely `c'
     In the expression: g $ c
 }}}

 Now it's comparing the constraint for the implicit parameter with the type
 Char. Bad news methinks.

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


More information about the Glasgow-haskell-bugs mailing list