-
Notifications
You must be signed in to change notification settings - Fork 661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rank N Polymorphism / unification issue #238
Comments
Note that it still fails when I remove the type annotation; it just doesn't print those last two errors. |
Huh, this is actually interesting - the following code does not compile in Haskell foo :: (a -> a) -> (b,c) -> (b,c)
foo f (x,y) = (f x, f y) |
Narrowed it down! So it looks like Elm would need to support Rank-2 types for this to work. I'll do some research. Can we keep this open, but tabled? {-# LANGUAGE RankNTypes, UnicodeSyntax #-}
module Dispatch where
foo :: (∀ a. a -> a) -> (b,c) -> (b,c)
foo f (x,y) = (f x, f y)
bar = foo id
|
For reference: http://ghc.haskell.org/trac/haskell-prime/wiki/Rank2Types And implementation: http://research.microsoft.com/en-us/um/people/simonpj/papers/higher-rank/putting.pdf |
Sorry for the slow response! Yeah, we can definitely keep this open. My intuition was that a mapExtFoo : (forall a. Ext a -> Ext a) -> Foo -> Foo I think the type checker is able to handle this kind of thing, but these types are not parsed at the moment. I feel like this is the kind of thing that might make things undecidable or at least really expensive, but I am not expert enough to know decisively. |
According to TAPL, rank 2 is decidable, otherwise rank-n is not. Sent from my iPhone On Sep 5, 2013, at 9:22 PM, Evan Czaplicki notifications@github.com wrote:
|
Why is it a flag in Haskell then? Maybe it has bad interactions with type classes? |
@evancz It's a flag for the same reason |
Ah, makes sense. Thanks @pthariensflame :) |
I'm doing this thing where I make meta issues to track a category of related ideas. In this case, I added this to #1039. Often we have a bunch of different threads open that are mutually exclusive, or depend on each other in tricky ways. This is described more here in the "design discussion" section. So I am going to close this, but any discussion should continue here! |
This is a neat one I think; consider the following module:
As both "branches" of the Foo data structure contain things that are Ext, if we have a function that maps Ext to Ext, we should be able to apply it independently to both sides, and thus apply it to Foo as a whole.
I think the issue here is that the f argument wants to unify to two different types, but notice that it can uniquely unify within the scope of each case branch. Compiler output below:
The text was updated successfully, but these errors were encountered: