-
Notifications
You must be signed in to change notification settings - Fork 138
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
Logical Constraints #289
Logical Constraints #289
Conversation
Can we discuss this in person tomorrow? |
Sure! |
I won't be in today, but I'll leave a few thoughts.
|
Thanks @gridaphobe. So, this is much more expressive than existential types. |
Perhaps we should use |
Nice, it also handles a proper state monad and |
What do you mean by "proper state monad and bind"? I feel we can use dictionaries and do something smarter than intersection types, but it is not clear in my mind yet. Anyways, we are getting closer:) |
The usual definition with data ST s a = ST (s -> (a,s)) There's no real reason to expect LH to fail with the usual definition, but it gives me some extra peace of mind having tried it :) Working directly with the dictionaries would be nice too, but it might require implementing the |
@nikivazou, hahahahahah! check out: https://github.com/ucsd-progsys/liquidhaskell/blob/master/tests/pos/filterAbs.hs (and for sanity) https://github.com/ucsd-progsys/liquidhaskell/blob/master/tests/neg/filterAbs.hs On Mon, Dec 22, 2014 at 3:14 PM, Eric Seidel [email protected]
Ranjit. |
This is cool! And quite clean! These logical constraints are very powerful, it seems.... See this https://github.com/ucsd-progsys/liquidhaskell/blob/master/tests/pos/StateConstraints.hs |
Btw, the more I think about it the syntax needs to be changed. This is because if you just write:
then any user will think that it is equivalent to write:
or for that matter,
but in fact the semantics are totally different, because In particular the x:A, y:B |- C <: D or find some other way to highlight that the last two On Mon, Dec 22, 2014 at 4:57 PM, Niki Vazou [email protected]
Ranjit. |
@ranjitjhala I agree, but I suggest logical implication over subtyping, something like y:a, x: {v:Bool |
Why? In reality it is sub typing no?
|
It is subtyping. But sub typing is equivalent to logical implication. I preferred implication because I call these constraints logical constraints, but if you see it as bounded quantification subtyping makes more sense. So, I also like the subtyping suggestion. |
See tests/pos/Constraints.hs
Logical Constraints are of the form
{x1:a1 | r1} -> ... -> {xn:an | rn} -> {v:b | p} -> {v:b | q} (1)
and produce the formula
r1 /\ ... /\ rn => (p => q) (2)
Meaning if the constraint (1) appears in the type of a function
f
, then the formula (2) isf
is checkedf
is called