Ticket #2653 (closed merge: fixed)

Opened 5 years ago

Last modified 5 years ago

Hugs does not like bracketOnError in Network.hs

Reported by: golubovsky Owned by:
Priority: normal Milestone:
Component: libraries/network Version: 6.8.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

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.

Attachments

network-hugs.patch Download (386 bytes) - added by golubovsky 5 years ago.
Suggested patch
network-hugs.2.patch Download (386 bytes) - added by golubovsky 5 years ago.
Suggested patch

Change History

Changed 5 years ago by golubovsky

Suggested patch

Changed 5 years ago by golubovsky

Suggested patch

Changed 5 years ago by golubovsky

PS Please consider patching the recenfly forked 6.10 branch as well.

Changed 5 years ago by ross

  • type changed from bug to merge

fixed in HEAD. This was yet another

#if GLASGOW_HASKELL < nnn

which also succeeds for non-GHCs, and should be

#if GLASGOW_HASKELL && GLASGOW_HASKELL < nnn

Please merge to 6.10, so that other impls can use the version released with GHC.

Changed 5 years ago by igloo

  • status changed from new to closed
  • difficulty set to Unknown
  • resolution set to fixed

network (extralibs) isn't forked, so no need to merge.

Note: See TracTickets for help on using tickets.