Rank 2 polymorphism in pattern matching?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Rank 2 polymorphism in pattern matching?

C Rodrigues
This counterintuitive typechecking result came up when I wrote a wrapper
around runST.  Is there some limitation of HM with respect to type checking
pattern matching?

data X a b = X (a -> a)
run :: forall a. (forall b. X a b) -> a -> a
-- This definition doesn't pass the typechecker
run (X f) = f
-- But this definition works
run x = (\(X f) -> f) x


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Rank 2 polymorphism in pattern matching?

Aaron Denney
On 2006-04-08, C Rodrigues <[hidden email]> wrote:

> This counterintuitive typechecking result came up when I wrote a wrapper
> around runST.  Is there some limitation of HM with respect to type checking
> pattern matching?
>
> data X a b = X (a -> a)
> run :: forall a. (forall b. X a b) -> a -> a
> -- This definition doesn't pass the typechecker
> run (X f) = f
> -- But this definition works
> run x = (\(X f) -> f) x

Have you tried
run (X f) x = f x
?


--
Aaron Denney
-><-

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Rank 2 polymorphism in pattern matching?

Bruno Oliveira-5
In reply to this post by C Rodrigues
Hello,

See this message:

http://article.gmane.org/gmane.comp.lang.haskell.general/13145/

Your (initial) program should work in GHC 6.2. I actually find this feature useful,
but Simon apparently changed this when moving to GHC 6.4 and nobody complained...
Apparently not many people use this feature.

Cheers,

Bruno

On Sat, 08 Apr 2006 18:31:03 +0000, C Rodrigues wrote:

>This counterintuitive typechecking result came up when I wrote a wrapper
>around runST. Is there some limitation of HM with respect to type checking
>pattern matching?
>
>data X a b = X (a -> a)
>run :: forall a. (forall b. X a b) -> a -> a
>-- This definition doesn't pass the typechecker
>run (X f) = f
>-- But this definition works
>run x = (\(X f) -> f) x
>
>
>_______________________________________________
>Haskell-Cafe mailing list
>[hidden email]
>http://www.haskell.org/mailman/listinfo/haskell-cafe


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe