Haskell Extensions in various compilers (Cabal)
Isaac Jones
ijones at syntaxpolice.org
Mon Jul 26 21:28:15 EDT 2004
Isaac Jones <ijones at syntaxpolice.org> writes:
(snip)
> Malcolm Wallace <Malcolm.Wallace at cs.york.ac.uk> writes:
>
>> Or, if you mean something like
>> data Dummy a;
>> then how about EmptyDataDecls or VoidDataTypes?
>
> Yep, that's what I meant. I'll call them VoidDataTypes. Thanks!
Oops. I just changed my mind. I'll call them EmptyDataDecls, since I
think that's easier to undrestand, even though it's harder to say.
FWIW, Malcolm mentioned that it's implemented in nhc98 and can't be
turned off. The same seems to be true of Hugs. GHC, OTOH requires
-fglasgow-exts.
Just for fun, I'll provide the list again here, since this seems to be
the complete list of extensions, and how they are implemented by GHC,
NHC, and Hugs.
peace,
isaac
data Extension =
OverlappingInstances
| RecursiveDo
| ParallelListComp
| MultiParamTypeClasses
| NoMonomorphismRestriction
| FunctionalDependencies
| RankNTypes
| PolymorphicComponents
| ExistentialQuantification
| ScopedTypeVariables
| ImplicitParams
| FlexibleContexts
| FlexibleInstances
| EmptyDataDecls
| TypeSynonymInstances
| TemplateHaskell
| ForeignFunctionInterface
| AllowOverlappingInstances
| AllowUndecidableInstances
| AllowIncoherentInstances
| InlinePhase
| ContextStack
| Arrows
| Generics
| NoImplicitPrelude
| NamedFieldPuns
| ExtensibleRecords
| RestrictedTypeSynonyms
| HereDocuments
| 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 RankNTypes = Right "-fglasgow-exts"
extensionToGHCFlag PolymorphicComponents = Right "-fglasgow-exts"
extensionToGHCFlag ExistentialQuantification = Right "-fglasgow-exts"
extensionToGHCFlag ScopedTypeVariables = Right "-fglasgow-exts"
extensionToGHCFlag FlexibleContexts = Right "-fglasgow-exts"
extensionToGHCFlag FlexibleInstances = Right "-fglasgow-exts"
extensionToGHCFlag EmptyDataDecls = Right "-fglasgow-exts"
extensionToGHCFlag e at ExtensibleRecords = Left e
extensionToGHCFlag e at RestrictedTypeSynonyms = Left e
extensionToGHCFlag e at HereDocuments = Left e
extensionToGHCFlag e at UnsafeOverlappingInstances = Left e
extensionToGHCFlag e at NamedFieldPuns = 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 ExistentialQuantification = Right ""
extensionToNHCFlag EmptyDataDecls = Right ""
extensionToNHCFlag NamedFieldPuns = Right "-puns"
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 RankNTypes = Right "-98"
extensionToHugsFlag PolymorphicComponents = Right "-98"
extensionToHugsFlag ExistentialQuantification = Right "-98"
extensionToHugsFlag ScopedTypeVariables = Right "-98"
extensionToHugsFlag ImplicitParams = Right "-98"
extensionToHugsFlag ExtensibleRecords = Right "-98"
extensionToHugsFlag RestrictedTypeSynonyms = Right "-98"
extensionToHugsFlag FlexibleContexts = Right "-98"
extensionToHugsFlag FlexibleInstances = Right "-98"
extensionToHugsFlag EmptyDataDecls = Right ""
extensionToHugsFlag e = Left e
More information about the Libraries
mailing list