#2653: Hugs does not like bracketOnError in Network.hs
---------------------------------+------------------------------------------
    Reporter:  golubovsky        |       Owner:                   
        Type:  bug               |      Status:  new              
    Priority:  normal            |   Component:  libraries/network
     Version:  6.8.3             |    Severity:  major            
    Keywords:                    |    Testcase:                   
Architecture:  Unknown/Multiple  |          Os:  Unknown/Multiple 
---------------------------------+------------------------------------------
 Currently network/Network.hs has this:

 {{{
 -- Utils

 #if __GLASGOW_HASKELL__ < 606
 -- Like bracket, but only performs the final action if there was an
 -- exception raised by the middle bit.
 bracketOnError
         :: IO a         -- ^ computation to run first (\"acquire
 resource\")
         -> (a -> IO b)  -- ^ computation to run last (\"release
 resource\")
         -> (a -> IO c)  -- ^ computation to run in-between
         -> IO c         -- returns the value from the in-between
 computation
 bracketOnError before after thing =
   Exception.block (do
     a <- before
     r <- Exception.catch
            (Exception.unblock (thing a))
            (\e -> do { after a; Exception.throw e })
     return r
  )
 #else
 bracketOnError = Exception.bracketOnError
 #endif

 }}}

 So Hugs gets the <606 definition which it does not like (type error
 printed on bracketOnError).

 {{{
 runhugs: Error occurred
 ERROR "/home2/dima/install/hugs98/hugsdir/packages/network/Network.hs":511
 - Cannot justify constraints in explicitly typed binding
 *** Expression    : bracketOnError
 *** Type          : IO a -> (a -> IO b) -> (a -> IO c) -> IO c
 *** Given context : ()
 *** Constraints   : Exception d
 }}}

 This can be fixed by adding `&& !__HUGS__` to the #if line.

 That is (darcs whatsnew),

 {{{
 {
 hunk ./Network.hs 378
 -#if __GLASGOW_HASKELL__ < 606
 +#if __GLASGOW_HASKELL__ < 606 && !__HUGS__
 }
 }}}

 so Hugs gets the second definition (redirected to
 Exception.bracketOnError) which works.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2653>
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