[Haskell-cafe] KiCS (Curry to Haskell interpreter) problem

2009-12-02 Thread Bernd Brassel
I am playing around with KiCS and I have a strange problem, when I evaluate a goal the variable bindings are not displayed, I see only the value of the expression. The idea is, that you decide yourself which bindings you want to see. For example, you write (let x free in (not x,x)) to get

[Haskell-cafe] How to add use custom preprocessor in cabal

2009-10-08 Thread Bernd Brassel
Hi folks, I am trying to integrate my own preprocessor into a cabal build process. But there are several points that I get stuck with. Could someone help me, please? A simplification of my problem: I have files Abc.foo and each of them should be transformed into Abc.hs by calling

[Haskell-cafe] Re: Converting typeset mathematics into Haskell ?

2009-08-24 Thread Bernd Brassel
Sometimes the synchronicity of events is eery. Incidentally I have just written a proposal for just such a project. You can have a look at it at http://www-ps.informatik.uni-kiel.de/~bbr/WebOfProofs.html Although not directly mentioned in the proposal, there will be a lot of Converting

Bug in deriving Data Typeable?

2009-03-12 Thread Bernd Brassel
Hi folks, I have been surprised by the derived instances of Data/Typeable when using the combinator ext1Q. First look at the following definition: useExt1 :: Data a = a - () useExt1 = undefined `ext1Q` (\ (Just _) - ()) testExt1 :: () testExt1 = useExt1 (Just ()) As I expected, testExt1

Re: Bug in deriving Data Typeable?

2009-03-12 Thread Bernd Brassel
José Pedro Magalhães wrote: Hi Bernd, I guess this might be the same issue reported some time ago ( http://thread.gmane.org/gmane.comp.lang.haskell.generics/53/focus=54): the derived instances of Data do not define dataCast1. If you define your own instance of Data for MyMaybe and add the

Re: -optc-O2 considered useful

2008-05-20 Thread Bernd Brassel
I think it would be nice to have some speedy optimizations turned on by default in ghc. Might even be good to win new users. But I also think that much hacking for and around ghc+tool support needs a way to achieve what -O0 does today. So, how about an -O(-1) or flag?

Re: Optimization beyond the Module Border

2008-03-20 Thread Bernd Brassel
I suspect that if all modules are compiled -O0, then you recompile one module with -O2, high up in the dependency graph (i.e. it depends on many lower-level modules), plus all things that in turn depend on it (--make), you will not get the good performance you expect. None of the lower-level

Re: Optimization beyond the Module Border

2008-03-20 Thread Bernd Brassel
Don Stewart wrote: You almost always want to profile with full optimisations on. Otherwise its not even close to measuring the kind of code you're actually running. Ian Lynagh wrote: This should work, for the reasons that you give. Did you use options like +RTS -p when running the program?

Optimization beyond the Module Border

2008-03-19 Thread Bernd Brassel
Hi all, I have noticed that there is a great difference between optimizing modules separately and all at once, e.g., with -fforce-recomp. I have had examples factors up to 15 in run time (and even different behavior in context with unsafePerformIO). Is there any option that makes ghc write out

Re: Optimization beyond the Module Border

2008-03-19 Thread Bernd Brassel
Simon Peyton-Jones wrote: GHC does a lot of cross-module inlining already, and *does* write stuff into interface files, provided you use -O. I used -O4. Is that the bad thing? I'm always interested in performance differences of a factor of 15 though! Can you supply an example (as small

Shared Libraries in ghci

2008-02-08 Thread Bernd Brassel
Sorry to ask a C question here, but I could not find an answer on the net. How do I create a library that can be used in ghci? This is the situation: I have a c file coracle.c. I do /tmp$ cc -c -o coracle.o coracle.c /tmp$ ar rc libcoracle.a coracle.o /tmp$ ranlib libcoracle.a and then I the

Re: What does unsafePerformIO do to the stack

2008-02-08 Thread Bernd Brassel
Simon Marlow wrote: Perhaps there are some trivial examples of unshared thunks that we could spot, though. The sharing analysis in the interpreter is also very simple and inexpensive. But the gain is frequent. Maybe giving it a try would be worthwhile. Thanks again for all your answers! Bernd

Re: Shared Libraries in ghci

2008-02-08 Thread Bernd Brassel
Simon Marlow wrote: Normally it's done like this: $ gcc -fPIC -c foo.c $ gcc -shared -o libfoo.so foo.o Hope this helps. Right away! Big Thanks! Bernd ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org

Re: Shared Libraries in ghci

2008-02-08 Thread Bernd Brassel
Simon Peyton-Jones wrote: Any chance of documenting your experience on the GHC user documentation page? http://haskell.org/haskellwiki/GHC (under collaborative documentation) A kind of how-to that worked for you, with pointers to relevant manual parts etc. Simon Is this

Re: What does unsafePerformIO do to the stack

2008-02-07 Thread Bernd Brassel
I have got around the problem by defining my unsafe actions by the foreign function interface. But I still think there is a bug concerning stack use in unsafePerformIO in ghc. And I also think that this bug potentially concerns every use of unsafe. Or did I just not get the point of your argument

Re: What does unsafePerformIO do to the stack

2008-02-07 Thread Bernd Brassel
Simon Marlow wrote: So the upshot is: you can use unsafeDupablePerformIO right now, or you can wait until I've tested and committed this patch to get tail-recursion with unsafePerformIO. Wow, thank you for the detailed answer! That was really interesting. I've no idea how it works in Hugs,

Re: What does unsafePerformIO do to the stack

2008-02-07 Thread Bernd Brassel
There is another point that makes me wonder now. If the update frame for the recursive call is the problem then my solution with foreign C functions would produce a bad stack also. But this is not the case. The code looks now like this: sim [] = True sim (_:xs) = yags (sim xs) ref =

Re: What does unsafePerformIO do to the stack

2008-02-01 Thread Bernd Brassel
Thanks for your answer Simon. Simon Marlow wrote: Bernd Brassel wrote: Consider the following program: module Stack where import System.IO.Unsafe main = print (sim (replicate 1299959 ())) sim [] = True sim (_:xs) = goodStack (sim xs) goodStack x = fromJust (Just x

What does unsafePerformIO do to the stack

2008-01-31 Thread Bernd Brassel
Consider the following program: module Stack where import System.IO.Unsafe main = print (sim (replicate 1299959 ())) sim [] = True sim (_:xs) = goodStack (sim xs) goodStack x = fromJust (Just x) --no stack overflow badStack x = unsafePerformIO (return x) --stack overflow

Hugs faster than GHC

2007-12-14 Thread Bernd Brassel
The following program reveals a performance bug in ghc 6.6 module HCBenchmark where type M1 a = () type M2 a = M1 a type M3 a = M2 a type M4 a = M3 a type M5 a = M4 a type M a = M4 a -- use M5 for 10 times the compile time and M3 for 1/10 f :: M (M (M (M (M (M (M (M (M (M x) f = ()

Re: Hugs faster than GHC

2007-12-14 Thread Bernd Brassel
Simon Peyton-Jones schrieb: It's a perf bug in 6.6, happily fixed in 6.8.1 Great news! Thank you! ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

C Preprocessor

2007-12-06 Thread Bernd Brassel
Is it already a known problem that the preprocessor cannot cope with the whole set of possible string declarations? $ cat long1.hs {-# OPTIONS -cpp #-} s = abc\ \defg main = putStrLn s $ ghc long1.hs long1.hs:3:14: lexical error in string/character literal at character 'e' $ cat

Prevent optimization from tempering with unsafePerformIO

2007-10-18 Thread Bernd Brassel
Hello to all who have given me hints an suggestions about this topic whether directly by mail or over the mailing list. I do now have a much more concrete idea of how to optimize my programs. Thanks for your time! Bernd ___ Glasgow-haskell-users mailing

Re: Prevent optimization from tempering with unsafePerformIO

2007-10-17 Thread Bernd Brassel
Hi Stefan! Thanks for your answer. Stefan O'Rear wrote: Might I suggest, that the problem is your use of unsafePerformIO? Yes you might. And you are surely right. But not using it in this way is not an alternative. why do you want to do this unsafely, instead of just using 'length'?

Prevent optimization from tempering with unsafePerformIO

2007-10-17 Thread Bernd Brassel
Hi David, thank you! This is really useful information! I think it's the let floating (out) together with common subexpression elimination: ghc --make -O2 -no-recomp -fno-cse -o curry-no-cse curry.hs [1 of 1] Compiling Main ( curry.hs, curry.o ) Linking curry-no-cse ...

Prevent optimization from tempering with unsafePerformIO

2007-10-17 Thread Bernd Brassel
May I suggest a third route that has the advantages of both your approaches. The backside is of course that it takes a bit of work. My suggestion is to do an effect analysis of your curry programs to identify the purely functional parts and compile them directly to pure Haskell. The rest of

Prevent optimization from tempering with unsafePerformIO

2007-10-17 Thread Bernd Brassel
I think you'll find it useful to be explicit about what you are relying on. Yes, good point. For example I think that if your program contains two calls unsafePerformIO e1 unsafePerformIO e2 then * You don't care about the *order* in which these are performed Right, the

Re: Prevent optimization from tempering with unsafePerformIO

2007-10-16 Thread Bernd Brassel
Hi Neil, hi Don! Nice meeting you at ICFP by the way. Can you give a specific example of what you have tried to do, and how it failed? I have attached a short synopsis of what our Curry to Haskell conceptually does. I could explain what all the parts mean and why they are defined this way, if

Re: Prevent optimization from tempering with unsafePerformIO

2007-10-16 Thread Bernd Brassel
Neil Mitchell schrieb: It varies by each piece of code, can you post a code fragment that gets optimised in the wrong way? Sorry for posting this twice! I have added the code to the other thread. Thanks! Bernd ___ Glasgow-haskell-users mailing list

Prevent optimization from tempering with unsafePerformIO

2007-10-15 Thread Bernd Brassel
time to invoke the no-inline pragmata, but they seem to have no effect at all. Recently at ICFP, Neil Mitchell told me that there definitely is a way to avoid this problem. But does anybody know how? Thanks for your help! Bernd Brassel ___ Glasgow-haskell

Confusing Typing Problem

2005-11-18 Thread Bernd Brassel
I am a bit confused by GHC behaviour for the following variants of a program: data A = A (Int - A) f = A g g _ = f h = g 'c' ghc: Error: Couldn't match `Int' against `Char' The problem is that a small change ommits the error: data A = A (Int - A) f = A g where g _ = f h = g 'c'