Re: Control.Exception
I think the best way to get backwards compatibility is to flesh out and use the extensible-exceptions package that Ian started, which models extensible exceptions on top of the old exception mechanism. Alternatively, you can decide not to use extensible exceptions and have your package depend on base-3 instead of base-4. For a library, however, I don't think there's a good solution, since most of the time changing the exception mechanism for the library will make the library incompatible with existing clients. I guess the best way to deal with this is to properly use the package versioning policy and hope that clients specify their dependencies precisely. 2008/11/2 Sigbjorn Finne [EMAIL PROTECTED]: (+1) to that request - what is the best practices for portable exception handling code that straddles version 6.10, i.e. that compiles with compilers at either side with minimal fuss? I can imagine a couple of alternatives, but would like to hear what others are doing here. thanks --sigbjorn likes backward code compatibility On 11/1/2008 18:15, Jason Dagit wrote: On Wed, Oct 8, 2008 at 1:19 AM, Simon Marlow [EMAIL PROTECTED] wrote: Johannes Waldmann wrote: with 6.10, the following does not typecheck: foo `Control.Exception.catch` \ _ - return bar Ambiguous type variable `e' in the constraint: `Control.Exception.Exception e' It is probably bad programming style anyway but what is the workaround? As long as you're aware that it is bad programming style. We deliberately didn't include an easy way to do this, because we want people to think about why they need to catch *all* exceptions (most of the time it's a bug). Since the above is bad form, what should I be doing? Could someone please provide some examples or point me at the list of exceptions that I can catch? What about catching multiple types of exceptions? Thanks, Jason ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Control.Exception
On Sat, 2008-11-01 at 19:09 -0700, Sigbjorn Finne wrote: (+1) to that request - what is the best practices for portable exception handling code that straddles version 6.10, i.e. that compiles with compilers at either side with minimal fuss? I can imagine a couple of alternatives, but would like to hear what others are doing here. As far as I know there is no nice easy way to be compatible with both models. There's no subset you can stick to that works with both. In libraries like Cabal and other libs we've done things like: catchIO :: IO a - (Exception.IOException - IO a) - IO a #ifdef BASE4 catchIO = Exception.catch #else catchIO = Exception.catchJust Exception.ioErrors #endif catchExit :: IO a - (ExitCode - IO a) - IO a #ifdef BASE4 catchExit = Exception.catch #else catchExit = ... etc ... #endif The point is, the old catch deals with just one exception type, while the new one works with various kinds of specific exception types. So you'd need one of these ifdefs for each type of exception you're catching. The other alternative is to just keep using the base 3 exceptions for a while and switch next time your lib makes a major api change. If you need to switch to base 4 for other reasons you can use the Control.OldExceptions if you don't want to switch to the new exceptions at the same time. I don't know much about the extensible-exceptions package, I'll let someone else explain about that. I was initially rather annoyed that the api has changed to much that it was not possible to make code work nicely without using cpp. On the other hand, the new exceptions api is a good deal nicer to use and is much more easily extensible. The old dynamic exceptions stuff was horrible. We used it in gtk2hs to implement the detailed exceptions that glib/gtk throws, but it constantly confused users. The new api also encourages you not to do silly things like catching all exceptions, known and unknown like the previous api did. This is important now that we have things like ^C being exceptions. Duncan ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: ANNOUNCE: GHC 6.10.1 RC 1
Ian Lynagh [EMAIL PROTECTED] wrote: I thought all your problems boiled down to binaries not being able to find libgmp.so at runtime? So I think this should fix them all. Yes, but then I wouldn't be able to find and fix the commands that are missing SRC_HC_OPTS. :) So I'm holding off on that for now. Below is a patch for the ones I've found so far. With those changes, and without setting LD_LIBRARY_PATH, the build stops here: Preprocessing library hpc-0.5.0.2... dist-bootstrapping/build/Trace/Hpc/Reflect_hsc_make: error while loading shared libraries: libgmp.so.3: cannot open shared object file: No such file or directory running dist-bootstrapping/build/Trace/Hpc/Reflect_hsc_make failed command was: dist-bootstrapping/build/Trace/Hpc/Reflect_hsc_make dist-bootstrapping/build/Trace/Hpc/Reflect.hs My BUILD_FLAGS includes --ghc-option=-optl... and --ld-option=... flags which would take care of it, if they were being used, so apparently they're not. libraries/hpc/Trace/Hpc/Reflect.hsc produces libraries/hpc/dist-bootstrapping/build/Trace/Hpc/Reflect_hsc_make.c, which is compiled and linked to make libraries/hpc/dist-bootstrapping/build/Trace/Hpc/Reflect_hsc_make. Is there anything I can add to the cabal-bin command line to inject linker flags into that link command? --- libraries/Makefile 2008-10-07 15:30:24.0 -0400 +++ libraries/Makefile 2008-10-31 11:58:25.0 -0400 @@ -131,21 +131,21 @@ cabal-bin: cabal-bin.hs -mkdir bootstrapping - $(GHC) $(BOOTSTRAPPING_FLAGS) --make cabal-bin -o cabal-bin + $(GHC) $(BOOTSTRAPPING_FLAGS) $(SRC_HC_OPTS) --make cabal-bin -o cabal-bin bootstrapping.conf: cabal-bin echo [] [EMAIL PROTECTED] -cd filepath $(CABAL) clean --distpref=dist-bootstrapping cd filepath $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --with-hc-pkg=$(GHC_PKG) --package-db=$(HERE_ABS)/[EMAIL PROTECTED] - cd filepath $(CABAL) build --distpref=dist-bootstrapping + cd filepath $(CABAL) build --distpref=dist-bootstrapping $(BUILD_FLAGS) cd filepath $(CABAL) install --distpref=dist-bootstrapping --inplace -cd Cabal $(CABAL) clean --distpref=dist-bootstrapping cd Cabal $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --with-hc-pkg=$(GHC_PKG) --package-db=$(HERE_ABS)/[EMAIL PROTECTED] - cd Cabal $(CABAL) build --distpref=dist-bootstrapping + cd Cabal $(CABAL) build --distpref=dist-bootstrapping $(BUILD_FLAGS) cd Cabal $(CABAL) install --distpref=dist-bootstrapping --inplace -cd hpc $(CABAL) clean --distpref=dist-bootstrapping cd hpc $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --with-hc-pkg=$(GHC_PKG) --package-db=$(HERE_ABS)/[EMAIL PROTECTED] - cd hpc $(CABAL) build --distpref=dist-bootstrapping + cd hpc $(CABAL) build --distpref=dist-bootstrapping $(BUILD_FLAGS) cd hpc $(CABAL) install --distpref=dist-bootstrapping --inplace mv [EMAIL PROTECTED] $@ @@ -154,9 +154,9 @@ mkdir ifBuildable $(CP) ifBuildable.hs ifBuildable/ ifeq $(stage) 2 - cd ifBuildable ../$(HC) -Wall --make ifBuildable -o ifBuildable + cd ifBuildable ../$(HC) -Wall $(SRC_HC_OPTS) --make ifBuildable -o ifBuildable else - cd ifBuildable $(GHC) -Wall --make ifBuildable -o ifBuildable + cd ifBuildable $(GHC) -Wall $(SRC_HC_OPTS) --make ifBuildable -o ifBuildable endif .PHONY: all build configure ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users