#2239: lack of improvement/reduction with TFs
----------------------------------------+-----------------------------------
    Reporter:  claus                    |        Owner:              
        Type:  bug                      |       Status:  new         
    Priority:  low                      |    Milestone:  6.14.1      
   Component:  Compiler (Type checker)  |      Version:  6.12.3      
    Keywords:  TF FD                    |   Difficulty:  Unknown     
          Os:  Unknown/Multiple         |     Testcase:              
Architecture:  Unknown/Multiple         |      Failure:  None/Unknown
----------------------------------------+-----------------------------------
Changes (by claus):

  * keywords:  TF vs FD => TF FD
  * failure:  => None/Unknown
  * version:  6.9 => 6.12.3


Comment:

 Though there was no recorded activity on this ticket, there seem to have
 been some changes (using 6.12.3). Perhaps this ticket should be brought to
 the attention of whoever is working in that area?-)

 Good news: the `tf A` and `tf B` examples now seem to work.

 Not so good news: there are still examples where improvement differs
 between TFs and FDs (see below); also, without comment it is not clear
 whether the progress is accidental.

 Here is another example that still shows a difference with 6.12.3. We
 define an FD-based type equality and a couple of examples
 {{{
 {-# LANGUAGE NoMonomorphismRestriction #-}
 {-# LANGUAGE FunctionalDependencies #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
 {-# LANGUAGE FlexibleInstances #-}

 class MyEq a b | a->b, b->a
 instance MyEq a a

 simpleFD = id :: (forall b. MyEq b Bool => b->b)

 simpleTF = id :: (forall b. b~Bool => b->b)

 complexFD = id :: (forall b. MyEq b Bool => b->b)
                -> (forall b. MyEq b Bool => b->b)

 {- doesn't typecheck:
 complexTF = id :: (forall b. b~Bool => b->b)
                -> (forall b. b~Bool => b->b)
  -}
 }}}
 and then both the TF and the FD type equality work for the simple case,
 but only the FD one works for the complex one
 {{{
 *Main> :t simpleFD
 simpleFD :: Bool -> Bool
 *Main> :t simpleTF
 simpleTF :: Bool -> Bool
 *Main> :t complexFD
 complexFD :: (forall b. (MyEq b Bool) => b -> b) -> Bool -> Bool
 }}}
 (though even with `complexFD`, the inner `forall b` does not get
 instantiated). Reloading the module with complexTF included leads to
 {{{
 C:\Users\claus\Desktop\tmp\show-eq.hs:17:12:
     Couldn't match expected type `forall b. (b ~ Bool) => b -> b'
            against inferred type `forall b. (b ~ Bool) => b -> b'
       Expected type: forall b. (b ~ Bool) => b -> b
       Inferred type: forall b. (b ~ Bool) => b -> b
     In the expression:
           id ::
             (forall b. (b ~ Bool) => b -> b)
             -> (forall b. (b ~ Bool) => b -> b)
     In the definition of `complexTF':
         complexTF = id ::
                       (forall b. (b ~ Bool) => b -> b)
                       -> (forall b. (b ~ Bool) => b -> b)
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2239#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to