[Haskell-cafe] Rank2Types and pattern matching

Max Bolingbroke batterseapower at hotmail.com
Sun Jul 4 05:58:11 EDT 2010

On 4 July 2010 00:24, Yves Parès <limestrael at gmail.com> wrote:
> then it works, so obviously, the trouble is about pattern matching.
> What was I doing wrong?

This seems to be in violation of the Haskell Report. See e.g. section
3.3 (http://www.haskell.org/onlinereport/exps.html):

The following identity holds:
\ p1 ... pn -> e	=	\ x1 ... xn -> case (x1, ..., xn) of (p1, ..., pn) -> e
where the xi are new identifiers.


runSomeMonad4, runSomeMonad5 :: (forall s. SomeMonad s a) -> a
runSomeMonad4 = \x -> case x of SomeMonad x -> runIdentity x
runSomeMonad5 = \(SomeMonad x) -> runIdentity x

runSomeMonad4 is accepted and runSomeMonad5 is rejected.

Of course, the Report doesn't make provision for rank-N types, so this
is not *strictly* speaking a violation. But it does seem against the
*spirit* of the report, if nothing else!


More information about the Haskell-Cafe mailing list