Haskell Extensions in various compilers (Cabal)

I've implemented a mapping[1] between compiler extensions and command-line flags in Cabal[2] for GHC, NHC98, and Hugs. Can some representatives from each take a look at these and let me know if I'm wrong about how any of them work, whether I missed support for any of the compilers, or what-have-you? Some notes & questions: - I gathered these by the rather error-prone process of copying them from the end-user documentation. If anyone notices anything that's missing, or can suggest some way I could discover missing items, please do. - I'm not including any non-standard modules, since maybe those will be handled by the packaging system. - Are the "hood debugging extensions" in NHC and Hugs compatible? Should they be included? - Do any of Hugs, GHC, and NHC disallow Long.Hierarchical.Module.Names by default? Can they all turn them off? - Should there be a "Force98" option or something which does "-98" in NHC, "+98" in Hugs, and forces no other extensions in GHC? Presumably, it would disallow other extensions for the other compilers as well. - Does anyone care to provide such a mapping for any other compiler flavors? peace, isaac [2] formerly LIP: http://www.haskell.org/cabal ------------------------------------------------------------ [1] data Extension = OverlappingInstances | RecursiveDo | ParallelListComp | MultiParamTypeClasses | NoMonomorphismRestriction | FunctionalDependencies | RankTwoTypes | PolymorphicComponents | ExistentialQuantification | PatternTypeAnnotations | ImplicitParams | FlexibleContexts | FlexibleInstances | TypeSynonymInstances | TemplateHaskell | ForeignFunctionInterface | AllowOverlappingInstances | AllowUndecidableInstances | AllowIncoherentInstances | InlinePhase | ContextStack | Arrows | Generics | NoImplicitPrelude | ExtensibleRecords | RestrictedTypeSynonyms | HereDocuments | HoodDebugging | UnsafeOverlappingInstances deriving (Show, Read, Eq) -- |GHC: Return the unsupported extensions, and the flags for the supported extensions extensionsToGHCFlag :: [ Extension ] -> ([Extension], [Opt]) extensionsToGHCFlag l = splitEither $ nub $ map extensionToGHCFlag l where extensionToGHCFlag :: Extension -> Either Extension String extensionToGHCFlag OverlappingInstances = Right "-fallow-overlapping-instances" extensionToGHCFlag TypeSynonymInstances = Right "-fglasgow-exts" extensionToGHCFlag TemplateHaskell = Right "-fth" extensionToGHCFlag ForeignFunctionInterface = Right "-ffi" extensionToGHCFlag NoMonomorphismRestriction = Right "-fno-monomorphism-restriction" extensionToGHCFlag AllowOverlappingInstances = Right "-fallow-overlapping-instances" extensionToGHCFlag AllowUndecidableInstances = Right "-fallow-undecidable-instances" extensionToGHCFlag AllowIncoherentInstances = Right "-fallow- incoherent-instances" extensionToGHCFlag InlinePhase = Right "-finline-phase" extensionToGHCFlag ContextStack = Right "-fcontext-stack" extensionToGHCFlag Arrows = Right "-farrows" extensionToGHCFlag Generics = Right "-fgenerics" extensionToGHCFlag NoImplicitPrelude = Right "-fno-implicit-prelude" extensionToGHCFlag ImplicitParams = Right "-fimplicit-params" extensionToGHCFlag RecursiveDo = Right "-fglasgow-exts" extensionToGHCFlag ParallelListComp = Right "-fglasgow-exts" extensionToGHCFlag MultiParamTypeClasses = Right "-fglasgow-exts" extensionToGHCFlag FunctionalDependencies = Right "-fglasgow-exts" extensionToGHCFlag RankTwoTypes = Right "-fglasgow-exts" extensionToGHCFlag PolymorphicComponents = Right "-fglasgow-exts" extensionToGHCFlag ExistentialQuantification = Right "-fglasgow-exts" extensionToGHCFlag PatternTypeAnnotations = Right "-fglasgow-exts" extensionToGHCFlag FlexibleContexts = Right "-fglasgow-exts" extensionToGHCFlag FlexibleInstances = Right "-fglasgow-exts" extensionToGHCFlag e@ExtensibleRecords = Left e extensionToGHCFlag e@RestrictedTypeSynonyms = Left e extensionToGHCFlag e@HereDocuments = Left e extensionToGHCFlag e@HoodDebugging = Left e extensionToGHCFlag e@UnsafeOverlappingInstances = Left e -- |NHC: Return the unsupported extensions, and the flags for the supported extensions extensionsToNHCFlag :: [ Extension ] -> ([Extension], [Opt]) extensionsToNHCFlag l = splitEither $ nub $ map extensionToNHCFlag l where extensionToNHCFlag NoMonomorphismRestriction = Right "" -- not implemented in NHC extensionToNHCFlag ForeignFunctionInterface = Right "" extensionToNHCFlag HoodDebugging = Right "" extensionToNHCFlag e = Left e -- |Hugs: Return the unsupported extensions, and the flags for the supported extensions extensionsToHugsFlag :: [ Extension ] -> ([Extension], [Opt]) extensionsToHugsFlag l = splitEither $ nub $ map extensionToHugsFlag l where extensionToHugsFlag OverlappingInstances = Right "+o" extensionToHugsFlag UnsafeOverlappingInstances = Right "+O" extensionToHugsFlag HereDocuments = Right "+H" extensionToHugsFlag RecursiveDo = Right "-98" extensionToHugsFlag ParallelListComp = Right "-98" extensionToHugsFlag MultiParamTypeClasses = Right "-98" extensionToHugsFlag FunctionalDependencies = Right "-98" extensionToHugsFlag RankTwoTypes = Right "-98" extensionToHugsFlag PolymorphicComponents = Right "-98" extensionToHugsFlag ExistentialQuantification = Right "-98" extensionToHugsFlag PatternTypeAnnotations = Right "-98" extensionToHugsFlag ImplicitParams = Right "-98" extensionToHugsFlag ExtensibleRecords = Right "-98" extensionToHugsFlag RestrictedTypeSynonyms = Right "-98" extensionToHugsFlag HoodDebugging = Right "-98" extensionToHugsFlag FlexibleContexts = Right "-98" extensionToHugsFlag FlexibleInstances = Right "-98" extensionToHugsFlag e = Left e splitEither :: [Either a b] -> ([a], [b]) splitEither l = ([a | Left a <- l], [b | Right b <- l]) type Opt = String

Isaac Jones
I've implemented a mapping[1] between compiler extensions and command-line flags in Cabal[2] for GHC, NHC98, and Hugs. Can some representatives from each take a look at these and let me know if I'm wrong about how any of them work, whether I missed support for any of the compilers, or what-have-you?
RankTwoTypes could perhaps be RankNTypes? How about adding NamedFieldPuns, a feature of Haskell 1.4 removed in '98, but supported in nhc98 with the -puns flag?
- Are the "hood debugging extensions" in NHC and Hugs compatible? Should they be included?
The original HOOD, as supplied with nhc98, is just a library, written in H'98 + unsafePerformIO. The Hugs extension "builds in" the library. I don't think the HOOD functionality in Hugs is accessible by plain source code, so it doesn't really count as a language extension.
- Do any of Hugs, GHC, and NHC disallow Long.Hierarchical.Module.Names by default? Can they all turn them off?
nhc98 always permits Long.Module.Names with no mechanism to turn them off. -- |NHC: Return the unsupported extensions, and the flags for the supported extensions extensionsToNHCFlag :: [ Extension ] -> ([Extension], [Opt]) extensionsToNHCFlag l = splitEither $ nub $ map extensionToNHCFlag l where extensionToNHCFlag NoMonomorphismRestriction = Right "" -- not implemented in NHC extensionToNHCFlag ForeignFunctionInterface = Right "" + extensionToNHCFlag NamedFieldPuns = Right "-puns" + extensionToNHCFlag ExistentialQuantification = Right "" - extensionToNHCFlag HoodDebugging = Right "" extensionToNHCFlag e = Left e
participants (2)
-
Isaac Jones
-
Malcolm Wallace