Re: [Haskell-cafe] Mutually recursive modules

2013-05-08 Thread Roman Cheplyaka
Ah yes, thank you! * Francesco Mazzoli [2013-05-08 08:51:12+0100] > At Wed, 8 May 2013 09:46:08 +0300, > Roman Cheplyaka wrote: > > > > I wonder whether it's always possible to break cycles using GHC's > > .hs-boot files. > > > > Consider the following schematic example: > > > > module A whe

Re: [Haskell-cafe] Mutually recursive modules

2013-05-08 Thread Francesco Mazzoli
At Wed, 8 May 2013 09:46:08 +0300, Roman Cheplyaka wrote: > > I wonder whether it's always possible to break cycles using GHC's > .hs-boot files. > > Consider the following schematic example: > > module A where > > import B > > data A > > f :: B -> A > f = undefined B.g > > modul

RE: [Haskell-cafe] Mutually recursive modules and google protocol-buffers

2008-07-16 Thread Sittampalam, Ganesh
Hi, > module A(A) where > data A > deriving Show I think you should use "instance Show A" rather than "deriving Show". All the boot file needs to do is say that the instance exists, not explain how it is constructed. Cheers, Ganesh

Re: [Haskell-cafe] Mutually recursive modules and google protocol-buffers

2008-07-16 Thread Chris Kuklewicz
Thanks Roberto! Roberto Zunino wrote: Chris Kuklewicz wrote: There is no way to create a "A.hs-boot" file that has all of (1) Allows A.hs-boot to be compiled without compiling B.hs first (2) Allows B.hs (with a {-# SOURCE #-} pragma) to be compiled after A.hs-boot (3) Allows A.hs to com

Re: [Haskell-cafe] Mutually recursive modules and google protocol-buffers

2008-07-15 Thread Jason Dusek
John Meacham <[EMAIL PROTECTED]> wrote: > Chris Kuklewicz wrote: > > I have reached an impasse in designing a Haskell API for the > > google's The messages in protobuf are defined in a namespace > > that nests in the usual hierarchical OO style that Java > > encourages. > > > To avoid namespace con

Re: [Haskell-cafe] Mutually recursive modules and google protocol-buffers

2008-07-15 Thread John Meacham
On Tue, Jul 15, 2008 at 12:21:16PM +0100, Chris Kuklewicz wrote: > I have reached an impasse in designing a Haskell API for the google's > The messages in protobuf are defined in a namespace that nests in the usual > hierarchical OO style that Java encourages. > > To avoid namespace conflicts, I ma

Re: [Haskell-cafe] Mutually recursive modules and google protocol-buffers

2008-07-15 Thread Stuart Cook
On Wed, Jul 16, 2008 at 12:54 AM, Henning Thielemann <[EMAIL PROTECTED]> wrote: > Sooner or later you want generalize your datatypes. Then you can define > data A b = A b > and you do not need to import B any longer. I do not know if this is a > generally applicable approach, but it helped me in

Re: [Haskell-cafe] Mutually recursive modules and google protocol-buffers

2008-07-15 Thread Sterling Clover
What about generating the verbose accessor/single module code, and then creating a hierarchical module space as well, all importing your Base module, and reexporting the data types you want as well as less verbosely named accessor functions? Of course, this will break record update syntax,

Re: [Haskell-cafe] Mutually recursive modules and google protocol-buffers

2008-07-15 Thread Roberto Zunino
Chris Kuklewicz wrote: There is no way to create a "A.hs-boot" file that has all of (1) Allows A.hs-boot to be compiled without compiling B.hs first (2) Allows B.hs (with a {-# SOURCE #-} pragma) to be compiled after A.hs-boot (3) Allows A.hs to compiled after A.hs-boot with a consistent

Re: [Haskell-cafe] Mutually recursive modules and google protocol-buffers

2008-07-15 Thread Henning Thielemann
On Tue, 15 Jul 2008, Chris Kuklewicz wrote: Consider these 3 files: A.hs: module A(A) where import B(B) data A = A B B.hs module B(B) where import A(A) data B = B A Main.hs module Main where import A import B main = return () Sooner or later you want generalize your datatypes. Then y

Re: [Haskell-cafe] Mutually recursive modules and google protocol-buffers

2008-07-15 Thread Chris Kuklewicz
Ah, a teachable moment. One of us is not entirely correct about what GHC can do with this example. Hopefully I am wrong, but my experiments... Max Bolingbroke wrote: And there is no way ghc can compile these in separate modules. I may be being redundant here, but you may not know that GHC a

Re: [Haskell-cafe] Mutually recursive modules and google protocol-buffers

2008-07-15 Thread Max Bolingbroke
> And there is no way ghc can compile these in separate modules. I may be being redundant here, but you may not know that GHC actually can compile mutually recursive modules. See http://www.haskell.org/ghc/docs/latest/html/users_guide/separate-compilation.html#mutual-recursion . Of course, this is

Re: [Haskell-cafe] Mutually Recursive Modules

2008-06-02 Thread ajb
G'day all. Quoting Isaac Dupree <[EMAIL PROTECTED]>: Luckily, it is very often the case that your code will be better off anyway if refactored to have less module recursion. (though not always.) Nonetheless, I prefer not to leave the robustness of my code to luck. Besides, if I liked structur

Re: [Haskell-cafe] Mutually Recursive Modules

2008-06-02 Thread Isaac Dupree
Richard Giraud wrote: Hello I'm using GHC 6.8.2 with mutally recursive modules. I'm familiar with how to do simple cases in GHC ({-# SOURCE #-} and .hs-boot files) but I can't figure out how to get it to work for a particular set of modules. Is it known (i.e., proven) that GHC 6.8.2 can com

Re: [Haskell-cafe] mutually recursive modules

2004-09-27 Thread Andrew Pimlott
On Mon, Sep 27, 2004 at 10:46:25AM -0700, Fergus Henderson wrote: > (2) Although most of the mutual recursion occurred only in the > intermediate stages of the refactoring, some of the mutual > recursion remained at the end of the refactoring, forcing > two modules with only the

Re: [Haskell-cafe] mutually recursive modules

2004-09-24 Thread ajb
G'day all. Quoting Henning Thielemann <[EMAIL PROTECTED]>: > Why can't GHC and Hugs go this way? As Alastair noted, the problem is that Haskell allows you to export symbols from a module whose types are unknown unless you type-check modules that it imports. Simple example: module A where

Re: [Haskell-cafe] mutually recursive modules

2004-09-24 Thread Alastair Reid
Alastair: > A crude approach is to assume the type (\forall a. a) for any > function with no prototype Andreas: > Huh? How can that ever be sound? You're right, it's not - my mistake. I guess that leaves two options: 1) Insist on a prototype for any exported function. 2) Insist on a prototype

Re: [Haskell-cafe] mutually recursive modules

2004-09-24 Thread Jan-Willem Maessen
An anecdotal note - hbcc (the front end to the pH and Eager Haskell compilers, and also of GRIN) contained several mutually recursive modules both in the compiler and in the prelude. One of the best things we ever did was get rid of the mutual recursion. The resulting refactoring helped us to gr

Re: [Haskell-cafe] mutually recursive modules

2004-09-24 Thread Henning Thielemann
On Fri, 24 Sep 2004, Malcolm Wallace wrote: > The main obstacle is that Haskell systems generally process one > file/module at a time. To extract an interface from each module > first, before further processing, would not only require a second > pass over the source files, but to load all of the

Re: [Haskell-cafe] mutually recursive modules

2004-09-24 Thread Andreas Rossberg
Alastair Reid wrote: Generating .hiboot files by just deleting function definitions fails if there is no prototype for an exported function. A crude approach is to assume the type (\forall a. a) for any function with no prototype but, although this is sound (I think), it will cause valid progra

Re: [Haskell-cafe] mutually recursive modules

2004-09-24 Thread Alastair Reid
The original Haskell design included interface files usually with names like Main.hi IIRC, Yale Haskell expected them to be hand-written while HBC and GHC machine-generated but allowed the careful user to write them by hand. Sometime around Haskell 1.4 or 98, they were dropped because Yale Haske

Re: [Haskell-cafe] mutually recursive modules

2004-09-24 Thread Malcolm Wallace
Henning Thielemann <[EMAIL PROTECTED]> writes: > >a situation which occurs only very rarely, and for which > > there is a relatively easy workaround. > > Namely? ... See below. > It's interesting how other languages solve this problem. In Modula-3 it > is solved by explicit module

Re: [Haskell-cafe] mutually recursive modules

2004-09-24 Thread Malcolm Wallace
Henning Thielemann <[EMAIL PROTECTED]> writes: > As far as can see neither Hugs or GHC really support them. Is this still > on the to-do list or is it almost dropped due to implementation > difficulties? Hugs doesn't support mutually-recursive modules at all. Ghc and nhc98 support them only if

Re: [Haskell-cafe] mutually recursive modules

2004-09-24 Thread Henning Thielemann
On Fri, 24 Sep 2004, Malcolm Wallace wrote: > Hugs doesn't support mutually-recursive modules at all. Ghc and nhc98 > support them only if you hand-write a .hi-boot file to bootstrap the > compilation. I would guess that better support from the mainstream > implementations is unlikely, because