#1749: forall type gives "not polymorphic enough" error incorrectly
--------------------------------------+-------------------------------------
  Reporter:  guest                    |          Owner:         
      Type:  bug                      |         Status:  new    
  Priority:  normal                   |      Milestone:         
 Component:  Compiler (Type checker)  |        Version:  6.6.1  
  Severity:  normal                   |       Keywords:         
Difficulty:  Unknown                  |             Os:  Windows
  Testcase:                           |   Architecture:  x86    
--------------------------------------+-------------------------------------
 > type SFST s a b = a -> ST s b
 > newtype SF a b = SF { runSF :: forall s. ST s (SFST s a b) }

 When making this into an instance of Arrow, compose works beautifully:

 > sfCompose :: SF b c -> SF c d -> SF b d
 > sfCompose bc cd = SF sf where
 >   sf = do
 >     runBc <- runSF bc
 >     runCd <- runSF cd
 >     return $ \b -> runBc b >>= runCd

 but pure gives an odd message:

 > sfPure :: (b -> c) -> SF b c
 > sfPure f = SF sf where
 >     sf = return $ \b -> return (f b)

 frp_typebug.lhs:20:12:
     Inferred type is less polymorphic than expected
       Quantified type variable `s' is mentioned in the environment:
         sf :: ST s (b -> ST s c) (bound at frp_typebug.lhs:21:5)
     In the first argument of `SF', namely `sf'
     In the expression: SF sf
     In the definition of `sfPure':
         sfPure f = SF sf
                  where
                      sf = return $ (\ b -> return (f b))

 This can be worked around using scoped type variables:
 > sfPure2 :: (b -> c) -> SF b c
 > sfPure2 (f :: b -> c) = SF sf where
 >     sf :: forall s. ST s (SFST s b c)
 >        = return $ \b -> return (f b)

 but it's ugly.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1749>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to