
Hi Thomas, I was able to modify the prelude before and add functions implemented in Haskell, with no trouble. Only when I try to define a *primitive* function, and touch Prelude.c and Primitive.hs does the build break. I removed all my changes to Prelude.hs, and it still gives the same error. My guess is that changing Prelude.c or Primitive.hs caused scons to recompile Word.hs, and that breaks. How do I get the build to work? Thanks. Thomas Shackell wrote:
Hi Kartik,
Unfortunately adding things to the prelude is a little more tricky than other modules. Indeed if at all possible I would recommend adding it to another module instead (perhaps your own module).
The problem is the compiler has a rather 'hacked' view of the Prelude (a carry-over from the nhc98 source code). This means that it doesn't quite generate quite the right .hi file for the Prelude. The problem you've most likely got is that you've generated a .hi file that is missing the Integral instance for Prelude.Integer. The best way to solve this is to take the old Prelude.hi and modify it by hand to add your new definitions. This is a little fiddly but the syntax should be fairly obvious by looking at other examples.
Alternatively if you add your functions to some module other than the Prelude then you don't get any of these problems at all and it all works as expected.
Hope that helps
Tom
-- Blogs: http://kartik-log.blogspot.com, http://randomkart.blogspot.com