conditional code, was: Template haskell instance checking
Christian Maeder
maeder at tzi.de
Thu Mar 2 05:26:45 EST 2006
heatsink wrote:
> Is there a way, in template haskell, to find out what instance
> declarations exist? I'm not trying to accomplish anything specific
> right now, but I can see two potential uses for this. One is to emit
> compile-time error messages from TH code which would be more informative
> than the typechecker's output. The other is to produce TH functions
> that conditionally generate code depending on the instances satisfied by
> their arguments.
Apologies for becoming off-topic now, I've got nothing against template
haskell (TH), on the contrary, it is a great device to increase genericity.
But I want to warn about conditional code, because this may become a
nightmare to maintain. I.e. we (at Bremen) have (few) bits in TH that
check if we run under windows or unix (but no one knows if the windows
part is still working). Furthermore we support a few older (still
recent) ghc versions with conditional code (like ghc itself can be
bootstrapped with different older version).
Plugging in various libraries using Cabal is a nice feature, but imagine
if you would start to program depending on the currently installed
packages (and visible instances)! (Fortunately, this would be hard to do
currently.)
So (despite cabal and the desire for a minimal kernel) I hope that ghc
will continue to supply a large number of more or less "standard"
packages or modules that can safely be expected to exist in (almost)
every installation. (Therefore I've suggested to keep Data.Set and
Data.Map in the base package, but another "standard" package may be
fine, too). Otherwise truly application specific 3rd party cabal
packages may all come with their own "Prelude extensions" rather than
reusing increasingly solidified Haskell basics (that are hopefully not
disputed too much by the design of Haskell-Prime).
If you agree with me, great, ignore this posting.
Respectfully Christian
More information about the Libraries
mailing list