[Haskell-cafe] GHCi infers a type but refuses it as type signature
wren ng thornton
wren at freegeek.org
Wed Jun 24 22:35:36 EDT 2009
Luke Palmer wrote:
> On Tue, Jun 23, 2009 at 2:20 AM, <papa.eric at free.fr> wrote:
>
>>> Simple: the definition of MonadState uses those extensions.
>> Thanks, yes it helps and explains all. :^)
>>
>> I suppose then that if -XFlexibleContexts is indeed required by the
>> standard libraries, it is a "safe" extension, meaning supported by all
>> compilers? Are many such extensions de-facto standard that anyone can enable
>> by default?
>
> Now to answer your question, with 50% less idealistic ranting!
>
> There is definitely a canon of "safe" extensions in the community.
> Hierarchical libraries (that's not even an -X flag, it's just on),
> multiparam typeclasses, fundeps are among them. I can't say whether
> FlexibleContexts is.
I wouldn't say that fundeps are "safe". They're well supported on GHC
and Hugs, but they're hard to implement and can be tricky to reason
about. Also the haskell' committee isn't too fond of them.
Hierarchical modules and the FFI are "safe" in that they're really old
amendments to the H98 report; so they're as good as H98 for most folks.
CPP isn't blessed thus, but it's ubiquitous and easy to support. It's
worth noting here that most Haskell compilers other than GHC and Hugs
don't have full H98 support (even though that is the goal).
Other extensions which shouldn't cause anyone to bat an eyelash are
TypeSynonymInstances, FlexibleContexts, FlexibleInstances,
NoMonomorphismRestriction, NoImplicitPrelude. Some of these only make
sense with MPTCs. MPTCs may cause certain folks to bat an eyelash (once)
because they're flagrantly non-H98 and aren't widely supported; but they
are widely used, most implementations want them, and haskell' likes
them. The Flexible* extensions are almost required to make interesting
use of MPTCs.
The OverlappingInstances extension should make one wonder if there's a
better way to implement things, but it's supported by both Hugs and GHC
and it can make MPTCs do some really fun things. If you start needing
IncoherentInstances, then you should become concerned and start looking
for another way.
Rank2Types, RankNTypes, ExistentialQuantification, ScopedTypeVariables,
and GADTs are fairly benign ---though this is where you start loosing
compatibility with non-GHC compilers. Arrows would be benign except that
the syntax keeps changing. Fundeps are also in this category I'd say:
not widely supported, but fairly well known. UndecidableInstances could
also go here, though it should always make one cautious.
Anything else (TypeFamilies, TemplateHaskell,...) puts you firmly in
GHC-only land which is perilous to portability/maintainability.
--
Live well,
~wren
More information about the Haskell-Cafe
mailing list