Type families and type inference - a question

Daniel Fischer daniel.is.fischer at web.de
Mon Jan 11 02:45:08 EST 2010


Am Montag 11 Januar 2010 05:08:30 schrieb Dmitry Tsygankov:
> 2010/1/10 Yitzchak Gale
>
> > IMHO, the monomorphism restriction does not make sense at the
> > GHCi prompt in any case, no matter what you have or haven't
> > loaded, and no matter what your opinion of MR in general.
>
> Looks reasonable to me, that's why I intuitively expected
> let q = fmap MovieLister createFinder
> to work.
> Not sure I would want that behaviour when I ':load' a file though, as
> it may provide a false sense of security. -XTypeFamilies isn't turned
> on automatically, why should -XNoMonomorphismRestriction be?
>

You're more likely to omit (forget) type signatures for quick bindings at 
the prompt. The monomorphism restriction is inconvenient then.

> > I recommend that you create a file called ".ghci"
> >
> > in your home directory, and put into it the line:
> > :set -XNoMonomorphismRestriction
>
> That seems to also affect how the file is ':load'-ed, not sure I would
> want to do that.

If you want the MR in some module, you can enable it via
{-# LANGUAGE MonomorphismRestriction #-}
there.

It's a question of what you deem more (in)convenient. Since the MR is not 
entirely unlikely to be removed from the (default) language, the latter is 
more future-proof.


More information about the Glasgow-haskell-users mailing list