Type error in GHC-7 but not in GHC-6.12.3

Bas van Dijk v.dijk.bas at gmail.com
Sun Oct 31 16:54:11 EDT 2010


(resending this to the list because this failed yesterday because of
the mailinglist downtime)

On Sat, Oct 30, 2010 at 1:57 AM, Bas van Dijk <v.dijk.bas at gmail.com> wrote:
> I could isolate it a bit more if you want.

And so I did. The following is another instance of the problem I'm
having but set in a more familiar setting:

{-# LANGUAGE RankNTypes #-}

import Control.Monad.ST

foo :: (forall s. ST s a) -> a
foo st = ($) runST st

Couldn't match expected type `forall s. ST s a'
               with actual type `ST s a'
   In the second argument of `($)', namely `st'

Note that: 'foo st = runST st' type checks as expected.

Surprisingly 'foo st = runST $ st' also type checks!

I find the latter surprising because according to the report[1]: e1 op
e2 = (op) e1 e2. So either both should type check or both should fail.

I guess that a RULE somewhere eliminates the ($) before the
type-checker kicks in. I do find that a little strange because I
thought RULES where applied after type checking.

Regards,

Bas

[1] http://www.haskell.org/onlinereport/exps.html#operators


More information about the Glasgow-haskell-users mailing list