[Haskell-cafe] AlternativePrelude extension

Sjur Gjøstein Karevoll sjurberengal at gmail.com
Sat Jan 16 18:09:38 EST 2010


Laurdag 16. januar 2010 22.40.17 skreiv Malcolm Wallace:
> > I'm thinking the syntax would be something like
> > AlternativePrelude="MyPrelude".
> 
> There is a general principle that the semantics of a program should be
> completely described by the source code itself, and not dependent on
> options that may or may not be specified elsewhere.  Hence, the idea
> of adding {-# LANGUAGE #-} pragmas, so that the source code is self-
> contained.
> 
> Specifying {-# LANGUAGE NoImplicitPrelude #-} together with "import
> MyPrelude" satisfies this principle, as does {-# LANGUAGE
> AlternativePrelude="MyPrelude" #-} in all files where it matters.  But
> the difference in usability is slight.
> 
> If you are suggesting that {-# LANGUAGE AlternativePrelude="MyPrelude"
> #-} should somehow escape the scope of the module it appears in, then
> I think we heading for less firm ground.
> 
> Regards,
>      Malcolm
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 

Having a LANGUAGE pragma, or indeed any pragma, escape the module it's used in 
would be pretty silly, wouldn't it?

In principle I'm a fan of the LANGUAGE pragmas. Self-contained source is 
usually much easier to read that source that depends on whatever command the 
author used to build the thing.

However, the option to set language extension globally is still available, 
either as an option to the compiler when building, or in the cabal file 
describing the package. Allowing an alternative prelude in this fashion makes 
it easier to switch out the standard for alternatives in existing projects 
just to see what might happen, how things are changed or just for giggles. It 
might not be advisable to do so in code you plan on unleashing on the world, 
but it would make experimenting with alternatives cheaper than it currently 
is.

-- 
Sjur Gjøstein Karevoll


More information about the Haskell-Cafe mailing list