RE: Syntax extensions (was: RE: The Future of Haskell discussionat the Haskell Workshop)
{-# LANGUAGE <specification> #-}
where <specification> is one or more (if compatible) of keywords like
Haskell98 Pure Haskell 98, no extensions. SharedExtenisons (Haskell02???) A set of agreed-upon extensions implemented by all "major" Haskell systems. RecursiveDo ArrowSyntax TemplateHaskell OverlappingInstances UndecidableInstances FFI Foreign Function Interface MPTC Multi-parameter Type Classes
Looks fine to me. A few things to think about: - Some of the keywords specify an entire language (eg. Haskell98), whereas some are language modifiers (eg. FFI). We might want to make a distinction. Currently GHC supports only Haskell98 + modifiers. - Are extensions always additive? Are there any extensions which are incompatible? - There are features you might want to *disable*. eg. GHC lets you turn off the monomorphism restriction. Perhaps something like this: {-# LANGUAGE Haskell98 +FFI -MonomorphismRestriction #-}
(abbreviations used when three or more words).
The OPTION pragma would be used for compiler-specific options, although, in the interest of supporting portable code without having to resort to preprocessing using CPP, maybe it would make sense to provide
OPTIONS-GHC OPTIONS-Hugs OPTIONS-NHC ...
as well, the idea being that a compiler/interpreter then only would look at options pertinent to itself.
Yes, I've been meaning to rename GHC's version of the pragma to GHC_OPTIONS for some time. Cheers, Simon
Looks fine to me. A few things to think about:
- Some of the keywords specify an entire language (eg. Haskell98), whereas some are language modifiers (eg. FFI). We might want to make a distinction. Currently GHC supports only Haskell98 + modifiers.
Yes.
- Are extensions always additive?
Presumably not.
Are there any extensions which are incompatible?
Presumably yes. That's what I menat by "if compatible". Thiese issues needs to be clearly specified and agreed upon, of course.
- There are features you might want to *disable*. eg. GHC lets you turn off the monomorphism restriction.
Perhaps something like this:
{-# LANGUAGE Haskell98 +FFI -MonomorphismRestriction #-}
Nice! Hopefully, a common extended Haskell, supported by all major Haskell systems and including features that are very commonly used, can then be understood (for example) as follows: Haskell03 = Haskell98 +MPTC +FunctionalDependences +RankNPolymorphism -MonomorphismRestriction Thus, {-# LANGUAGE Haskell03 #-} would mean the same as {-# LANGUAGE Haskell98 +MPTC +FunctionalDependences +RankNPolymorphism -MonomorphismRestriction #-} saving typing in the common case. /Henrik -- Henrik Nilsson Yale University Department of Computer Science nilsson@cs.yale.edu
nilsson@cs.yale.edu writes:
- There are features you might want to *disable*. eg. GHC lets you turn off the monomorphism restriction.
"NoMonomorphismRestriction"?
Perhaps something like this: {-# LANGUAGE Haskell98 +FFI -MonomorphismRestriction #-}
Nice!
I feel pragmas embedded in comments are a bit hackish, and I'd rather have real syntax for this. Of course, that would be an extension in itself :-) -kzm -- If I haven't seen further, it is by standing in the footprints of giants
participants (3)
-
ketil@ii.uib.no -
nilsson@cs.yale.edu -
Simon Marlow