[jhc] bracket_ issue and fix
Korcan Hussein
korcan_h at hotmail.com
Wed Jul 28 02:53:58 EDT 2010
Hello, I've been tyring to modify the Haskell SDL bindings from hackage to get it to work on jhc (people should not use Haskell extensions in binding libraries!!!) and I had a problem with a piece of code that was using bracket_ but I did find a solution, the error message was:
[1 of 1] Graphics.UI.SDL.General(.......................................jhc: user error (
What: failure
Why: boxyMatch failure: (Jhc.Prim.IO Jhc.Basics.()) (s629 -> Jhc.Prim.IO s630)
Where: on line 148 in General.hs
in the application
Control.Exception.bracket_
(Graphics.UI.SDL.General.init Graphics.UI.SDL.General.20_flags)
Graphics.UI.SDL.General.quit
Graphics.UI.SDL.General.21_action
in
Graphics.UI.SDL.General.withInit {- on line 148 -}
in the function binding
Graphics.UI.SDL.General.withInit Graphics.UI.SDL.General.20_flags
Graphics.UI.SDL.General.21_action
= Control.Exception.bracket_
(Graphics.UI.SDL.General.init Graphics.UI.SDL.General.20_flags)
Graphics.UI.SDL.General.quit
Graphics.UI.SDL.General.21_action {- on line 148 -})
My suspicion was that the type signature for bracket_ wasn't exactly the same as defined in Haskell98 so I copied from haddoc docs the defintion and made bracket2_ function:
bracket2_ :: IO a -> IO b -> IO c -> IO c
bracket2_ before after thing = bracket before (const after) (const thing)
Then it all works fine, when I was googling the problem I think someone else had it too so hopefully if another person gets it they can find this :)
More information about the jhc
mailing list