RE: Compiling mutually recursive modules involving instances
| The manual also says a new, better, higher level way for | dealing with mutually recursive modules is in the works. | Is there any chance it will be ready for the next release? I don't think so. The upcoming GHCi will be the next release and it indeed gives a much better chance of doing this stuff properly. Making recursive modules possible is a high priority. But making them easy isn't as high priority as lots of other things, I'm afraid. Simon ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Compiling mutually recursive modules involving instances
On Thu, Oct 26, 2000 at 01:50:30AM -0700, Simon Peyton-Jones wrote: > The best thing to do is never to put an instance > declaration in an hi-boot file. I don't think you ever really > need to. In contrast, mutual recursion of type declarations > is often unavoidable. I believe I can redesign the module structures in my project so that the instances will not need to be put in a hi-boot file. The body of some methods in these instances uses some names (type names and function names, possibly with infix status) defined in a module where the corresponding class __and__ a relevant set of its instances should be visible. Logicaly the instances do not belong to the same module as their class and the user of my library should be able to add new modules (with new instances of the class) to the system without the need to modify the source of the module containing the class definition. Particularly I am having a great difficult in find a good module design for my library, which is should be able to be extended by its user. I am missing some important features for that, like extensible data types and functions support in the language. By now I am basing it on the extensible union types shown in "Monad Transformers and Modular Interpreters", by Mark Jones and others. When I progress in that I would make some comments. > The manual should really say this The manual also says a new, better, higher level way for dealing with mutually recursive modules is in the works. Is there any chance it will be ready for the next release? > | From: José Romildo Malaquias [mailto:[EMAIL PROTECTED]] > | > | I am having difficulties in compiling mutually recursive > | modules involving classes and instances in GHC 4.08.1. > | Basicaly I am not finding how to write a .hi-boot where > | I want to put classes and instances. > | > | Consider a program with 3 modules: M1, M2 and Main. The > | sources are attached to the message. What should go > | into M2.hi-boot? Would anyone write M2.hi-boot for me > | so that I can learn it. Regards, Romildo -- Prof. José Romildo Malaquias <[EMAIL PROTECTED]> Departamento de Computação Universidade Federal de Ouro Preto Brasil ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: Compiling mutually recursive modules involving instances
The best thing to do is never to put an instance declaration in an hi-boot file. I don't think you ever really need to. In contrast, mutual recursion of type declarations is often unavoidable. The manual should really say this Simon | -Original Message- | From: José Romildo Malaquias [mailto:[EMAIL PROTECTED]] | Sent: 24 October 2000 16:00 | To: [EMAIL PROTECTED] | Subject: Compiling mutually recursive modules involving instances | | | Hello. | | I am having difficulties in compiling mutually recursive | modules involving classes and instances in GHC 4.08.1. | Basicaly I am not finding how to write a .hi-boot where | I want to put classes and instances. | | Consider a program with 3 modules: M1, M2 and Main. The | sources are attached to the message. What should go | into M2.hi-boot? Would anyone write M2.hi-boot for me | so that I can learn it. | | Thanks. | | Romildo | -- | Prof. José Romildo Malaquias <[EMAIL PROTECTED]> | Departamento de Computação | Universidade Federal de Ouro Preto | Brasil | ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Compiling mutually recursive modules involving instances
Hello. I am having difficulties in compiling mutually recursive modules involving classes and instances in GHC 4.08.1. Basicaly I am not finding how to write a .hi-boot where I want to put classes and instances. Consider a program with 3 modules: M1, M2 and Main. The sources are attached to the message. What should go into M2.hi-boot? Would anyone write M2.hi-boot for me so that I can learn it. Thanks. Romildo -- Prof. José Romildo Malaquias <[EMAIL PROTECTED]> Departamento de Computação Universidade Federal de Ouro Preto Brasil module M1 where import {-# SOURCE #-} M2 class C a where f :: a -> Bool instance C a => C [a] where f = or . map f test = f [ 1 .. 10::Int ] module M2 where import M1 ( C ) instance C Int where f x = mod x 3 == 0 module Main where import M1 (test) main = putStrLn (show test)