Skip to content
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

Inference in presence of 'error' #380

Closed
monoidal opened this issue Jun 18, 2019 · 8 comments
Closed

Inference in presence of 'error' #380

monoidal opened this issue Jun 18, 2019 · 8 comments

Comments

@monoidal
Copy link

monoidal commented Jun 18, 2019

I'd expect this to typecheck:

f :: a ->. b
f x = error "bad" x

We don't fully support inference yet, but this one contains merely application, no lambdas or case. Workaround: f x = (error "bad" :: a ->. b) x.

The fix could be guarded on LinearTypes, as in #379.

@monoidal
Copy link
Author

monoidal commented Jun 19, 2019

A different example I expected to typecheck is map Just written as:

m :: [a] ->. [Maybe a]
m [] = []
m (x:xs) = Just x : m xs

Just has to be written as (Just :: a ->. Maybe a). This sounds like a consequence of the p * q = Omega rule.

@aspiwack
Copy link
Member

The first example is ok, for now. The second breaks linear base, probably. It's bad.

@monoidal
Copy link
Author

monoidal commented Aug 1, 2019

After a discussion, for now let's restore the a * b <= c rule, making a * b and sup a b the same thing. This means, revert #360 and #351. Also, add a rule in mkMultSup. This is best done after merging #386, where tcSubMult behaves sensibly. This should (1) fix this issue, (2) help in tweag/linear-base#38 (3) address the concerns about violating the substitution invariant in Multiplicity.hs.

@monoidal
Copy link
Author

monoidal commented Aug 7, 2019

WIP on krzysztof/family, fails Lint:

<no location info>: warning:
    In the pattern of a case alternative: (I# dt_a8Vi :: Int#)
    Linearity failure in variable: dt_a8Vi
    'Omega ⊈ MultMul 'Omega 'Omega

@aspiwack
Copy link
Member

aspiwack commented Aug 8, 2019

Lint it supposed to be aware of this rule. We need to implement it in the submultiplicity check that lint does. (there used to be a submultiplicity predicate in Mult.hs. It was taking care of this)

@monoidal
Copy link
Author

monoidal commented Aug 16, 2019

The map Just example was fixed by #391.

Remaining work:

@monoidal
Copy link
Author

Likely culprit: let unif_fun_ty = mkVIsFunTyOm arg_tys res_tys in TcUnify, function matchActualFunTysPart.

@monoidal
Copy link
Author

Moved to upstream:#18731.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants