-
Notifications
You must be signed in to change notification settings - Fork 2
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
Less enough Functional dependencies #2
Comments
I was about to put in a PR but then I noticed this issue. Let's look at the type signature for
So how do we want this to behave? Well, if we give it an
I noticed when trying to do something like
it wouldn't work unless I added the type signature
because If we change the FDs to just
this is exactly what we'd expect, and now Regarding your question as to why those FDs don't compile together, I'm actually not sure, but the one that is causing problems is the only one I think we need - p.s. really cool trick, I didn't know this was possible! |
So I believe this should be The similar example is here. class TestClass a b c | a b -> c, a c -> b where
func :: a -> b -> c
instance instanceA :: TestClass a (f a) a where
func = unsafeCoerce
else
instance instanceB :: TestClass a b b where
func = unsafeCoerce
test :: Int -> Int
test = func unit
-- ^^^^^^^^^
-- Could not match type
--
-- t3 Unit
--
-- with type
--
-- Int
--
--
-- while solving type class constraint
--
-- Test.TestClass Unit
-- Int
-- Int
--
-- while applying a function func
-- of type TestClass t0 t1 t2 => t0 -> t1 -> t2
-- to argument unit
-- while checking that expression func unit
-- has type Int -> Int
-- in value declaration test
--
-- where t0 is an unknown type
-- t1 is an unknown type
-- t2 is an unknown type
-- t3 is an unknown type I expected this chooses |
Oh wow, I neglected to notice you had a test suite. I will give that a look. |
I may have figured out your class TestClass a b c | a b -> c, a c -> b where
func :: b -> a -> c
instance instanceA :: TestClass (f a) a a where
func = unsafeCoerce
else
instance instanceB :: TestClass b a b where
func = unsafeCoerce
test :: Int -> Int
test = func unit |
Oh, you forget swapping FD's typevars. |
it actually doesn't make sense anyway since |
looks like it's a bug hdgarrood
|
If it is fixed, this will work! 😄 However, |
For type inference, I think this should/can have fundeps as:
But it doesn't work.
I don't know why. Please HELP!
Is this a compiler issue or not?
The text was updated successfully, but these errors were encountered: