[Haskell-cafe] Pointfree rank-2 typed function

Bas van Dijk v.dijk.bas at gmail.com
Tue Nov 24 08:34:08 EST 2009


Hello,

Given this program:

------------------------------------------------------------
{-# LANGUAGE Rank2Types #-}

newtype Region s a = Region a

unRegion :: forall a s. Region s a -> a
unRegion (Region x) = x

runRegionPointfull :: forall a. (forall s. Region s a) -> a
runRegionPointfull r = unRegion r
------------------------------------------------------------

Is it possible to write the rank-2 typed function 'runRegionPointfull'
in pointfree style?

Unfortunately the following doesn't typecheck:

runRegionPointfree :: forall a. (forall s. Region s a) -> a
runRegionPointfree = unRegion

Couldn't match expected type `forall s. Region s a'
           against inferred type `Region s a1'
    In the expression: unRegion
    In the definition of `runRegionPointfree':
        runRegionPointfree = unRegion

Why can't the typechecker match `forall s. Region s a' and `Region s a1'?

Thanks,

Bas


More information about the Haskell-Cafe mailing list