Generalized phase control for GHC

Roman Leshchinskiy rl at
Sat Jul 5 06:46:40 EDT 2008

Max Bolingbroke wrote:
> Hi Roman,
>> Three things. Firstly, what would lenient ordering be useful for? You
>> probably had a specific use case in mind?
> I suspect that when you have multiple plugins all specifying
> constraints on the phase ordering independently it is possible to end
> up in a situation where using each plugin individually results in a
> consistent phase ordering but a combination of multiple plugins causes
> a cycle to appear in the order. Hence it is useful to let plugin
> authors flag up dependencies they don't >need< to have so we can
> intellegently break the cycle using those constraints rather than just
> giving up. Admittedly I only have a superstition that this will be a
> practical problem.

If you don't need a dependency and it can be ignored anyway, why would 
you want to specify it in the first place? I just can't quite imagine a 
situation in which I would use this.

As to cycles, I think just aborting if they occur would be ok.

>> Secondly, I think it is quite
>> important to be able to specify dependencies for already declared phases.
>> That is, I (probably) want to be able to say in module C that phase X from
>> module A should come before phase Y from module B.
> This in interesting. You're right that it's not possible with this
> system: to support this you would need a more class + instance rather
> than single declaration flavour for phases. Do you have a practical
> example in mind of how you would use it?

Yeah, I'd prefer the class/instance model. An example: suppose you have 
two independent libraries which implement two optimisations and you want 
one of them to run before another. I think we really need this if we 
want to compose optimisations.

>> I suspect that's not
>> quite possible with your current design. Lastly, in addition to < and > I'd
>> also like to have = (i.e., phase X = phase Y which would make X an alias for
>> Y).
> Ah! This would also let you do what you wanted with your second point:
> module C where
> {-# PHASE XAlias = A.X, < B.Y #-}

True. It's a bit of a hack, though :-)


More information about the Glasgow-haskell-users mailing list