liquidhaskell-tutorial icon indicating copy to clipboard operation
liquidhaskell-tutorial copied to clipboard

Review of chapter 3 complete

Open christetreault opened this issue 10 years ago • 21 comments

I've completed my review of chapter 3 of the tutorial. The annotated .pdf can be found at:

https://drive.google.com/file/d/0Bx6BpheCXcBWaHJhdUxpTUNTbnc/view?usp=sharing

I had some issues with this chapter. Namely exercise 3.2, which I have concluded is impossible. I can only imagine that there must be some way to do it, but I couldn't find one (and I spent a good day or two banging my head against that wall).

christetreault avatar Feb 13 '15 21:02 christetreault

@christetreault you can take a look here for 3.2:

http://goto.ucsd.edu:8090/index.html#?demo=permalink%2F1423863481.hs

nikivazou avatar Feb 13 '15 21:02 nikivazou

Doesn't work for me (liquid haskell 0.3.0.0, liquid-fixpoint 0.2.2.0, ghc 7.8.3, z3 4.4.0).

To be fair, if I copy my code and paste it into your demo page, it type checks.

doesnt_work

christetreault avatar Feb 13 '15 21:02 christetreault

This is weird, it is safe for me with liquidHaskell-3.... In the Context the specified refinement of vec is lost and I do not know why....

nikivazou avatar Feb 13 '15 21:02 nikivazou

I am using the binaries on hackage, not the current repo. Perhaps something you did in the last few days fixed this?

christetreault avatar Feb 13 '15 21:02 christetreault

Maybe. Can you please do a make test to see what else is broken in your current setup?

nikivazou avatar Feb 13 '15 21:02 nikivazou

To be clear, you want me to clone the current liquidhaskell repo and build it with make test?

I'm having some trouble getting the dependencies resolved. It seems some module tasty has a dependency on optparse-applicative == 0.11.*, and cabal install installs version 0.8.1

christetreault avatar Feb 13 '15 22:02 christetreault

OK, I think I know the problem (@gridaphobe : I fear its DIFFCHECK)

@christetreault can you do this:

  1. Use exactly the same signature as you have in the screenshot above,
  2. Change the body of the function a little bit by adding whitespace e.g. to
unsafeLookup index vec     =     vec     !     index

Can you let me know if that works?

ranjitjhala avatar Feb 13 '15 23:02 ranjitjhala

@christetreault do it on the version you have -- no need to rebuild.

ranjitjhala avatar Feb 13 '15 23:02 ranjitjhala

Also, very sorry you ended up wasting so much time on this! Going forward, if you get stuck for even more than 20mins, shoot an email/issue because to me thats a "bug" in the tutorial...

ranjitjhala avatar Feb 13 '15 23:02 ranjitjhala

Well, I did that, and it worked. Then I undid it, and now it still works. Is it caching results in that .liquid folder that's in the source dir?

christetreault avatar Feb 13 '15 23:02 christetreault

Sigh. Sorry again!

Yes, its caching the results and it only "rechecks" a function if you change the implementation for the function (even slightly, e.g add a blank space.) This makes things very fast, BUT has these weird effects (and of course, should be something that is explained in the tutorial...!)

Most certainly my bad...

ranjitjhala avatar Feb 13 '15 23:02 ranjitjhala

@ranjitjhala given that we also support checking specific binders with -b, we could extend the emacs mode with a command to check the function the point is in.

gridaphobe avatar Feb 13 '15 23:02 gridaphobe

So if I write a function, then write a messed up specification for said function, then fix the spec, it will never recheck it unless I change the function or clear the cache?

christetreault avatar Feb 13 '15 23:02 christetreault

Good idea, except that would require writing emacs-lisp to determine the binder right?

May be easier to tweak LH with an option:

"--check-line N"

which would force checking of all binders around N-4 ... N+4 which would be:

(a) trivial to do in the "Diff" module (b) trivial to add in the emacs mode (easy to get N = cursor's position)

On Fri, Feb 13, 2015 at 3:52 PM, Eric Seidel [email protected] wrote:

@ranjitjhala https://github.com/ranjitjhala given that we also support checking specific binders with -b, we could extend the emacs mode with a command to check the function the point is in.

Reply to this email directly or view it on GitHub https://github.com/ucsd-progsys/liquidhaskell-tutorial/issues/3#issuecomment-74347950 .

Ranjit.

ranjitjhala avatar Feb 13 '15 23:02 ranjitjhala

Yes, it will not recheck UNTIL you "jostle" the function a bit, e.g. go inside the body and add a " " somewhere ...

(or you go and DELETE the "--diff" flag at the top of the file...

On Fri, Feb 13, 2015 at 3:54 PM, Chris Tetreault [email protected] wrote:

So if I write a function, then write a messed up specification for said function, it will never recheck it unless I change the function or clear the cache?

Reply to this email directly or view it on GitHub https://github.com/ucsd-progsys/liquidhaskell-tutorial/issues/3#issuecomment-74348122 .

Ranjit.

ranjitjhala avatar Feb 13 '15 23:02 ranjitjhala

@ranjitjhala most major-modes (including haskell-mode) provide functions to determine the function-at-point :)

gridaphobe avatar Feb 13 '15 23:02 gridaphobe

This wouldn't directly solve the issue of only editing a spec, but we could extend hsakell-mode's function to notice when it's inside a liquid-spec. I'll look into it next week.

gridaphobe avatar Feb 13 '15 23:02 gridaphobe

That being said, it might be nicer to just fix the issue at the level of diffcheck. E.g. do an actual diff of the new and saved files and check everything that depends on changed lines.

gridaphobe avatar Feb 14 '15 00:02 gridaphobe

Good point (Re: major modes) but in general, given the choice between hacking emacs-lisp and hacking haskell, I think the right answer is pretty clear to me :)

On Fri, Feb 13, 2015 at 3:58 PM, Eric Seidel [email protected] wrote:

This wouldn't directly solve the issue of only editing a spec, but we could extend hsakell-mode's function to notice when it's inside a liquid-spec. I'll look into it next week.

Reply to this email directly or view it on GitHub https://github.com/ucsd-progsys/liquidhaskell-tutorial/issues/3#issuecomment-74348506 .

Ranjit.

ranjitjhala avatar Feb 14 '15 00:02 ranjitjhala

This issue should be closed after PR https://github.com/ucsd-progsys/liquidhaskell-tutorial/pull/27 is merged

christetreault avatar Sep 12 '15 01:09 christetreault

So it seems that this particular case is fixed. Using the following command line, it works:

cabal exec liquid ../liquidhaskell-tutorial/src/04-poly.lhs -- --diffcheck

christetreault avatar Oct 16 '15 17:10 christetreault