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

Spreadsheet-like file watcher #252

Merged
merged 69 commits into from Sep 25, 2018

Conversation

Projects
None yet
4 participants
@pchiusano
Member

pchiusano commented Sep 24, 2018

screen shot 2018-09-24 at 2 39 55 pm

This is hooked up to the stack exec watcher executable. General idea: you can put > before any line in the program to 'watch' that line, and on each save, the result of that line's expression will be evaluated and printed out as shown. It's incredibly snappy (so snappy that you sometimes don't even notice it's updated) and gives me a feeling like I'm editing a spreadsheet... only it's a spreadsheet with access to a higher order language! Moreover, I get to keep using my favorite text editor to get this interactivity.

The idea is that this sort of thing totally replaces any need for a REPL. I think REPLs have a poor DX, and they aren't how you'd design an interactive programming environment today, even if you are sticking to just plain text.

Also added recently, you can use (expr)? and save the file to learn the type of expr and any constraints on replacement expressions:

screen shot 2018-09-24 at 11 57 33 pm

For later:

  • We could do more to avoid redundant evaluations.
  • It would be great if we can optionally obtain a full execution trace for watched expressions. This is potentially a huge amount of data, so it would need to return some sort of value that user could then slice and dice in various ways to explore it.
  • A bit easier - it would be great if you showed not just the line the expression comes from, but the expanded expression with free variables all substituted away.

pchiusano and others added some commits Sep 20, 2018

Add basic pretty-printer for Types
Add pretty-printer for types, currently lacking precedence-awareness to suppress superfluous parentheses, and lacking integration with PrettyPrint.hs for line-breaking.

Next step is to fix those omissions, then move on to pretty-printing Terms, and data and effect declarations.
Add EffectfulArrows' pattern for matching on Type
As per Paul's comment, except the for the extra `Maybe` so we can spot the difference between `a -> b` and `a ->{} b`.

So the pattern returns the following

  `(AnnotatedType v a, [(Maybe [AnnotatedType v a], AnnotatedType v a)])`

which gives the spine of function arguments, plus optional ability specifications on each arrow.

Plus use of this pattern in the Type pretty-printer.
Add precedence support to the Type pretty-printer
...not that there are many levels of precedence to support - just 0 (normal) and 10 (type operator application).

Also render `Sequence a` as `[a]`.
Integrate the Type pretty-printer with PrettyPrint.hs
Add line-break points at
* the space in a function application
* the space before the -> of an arrow
* the space after a comma in an effect list.

Presumably we might one day want to be able to express a preference between
breaking lines at these various points, and be able to control where
we indent to after the line break.

Still need to re-sugar pairs (,) and delay '

Also look into a regression where it seems like "Pair a b" is being parsed
as "Pair a (Pair b ())" (or at least printed that way).
Code review markups on Type pretty-printer
Making changes as per Paul's comments at df938b2
Add support for tuple and delay sugar to type-printer
The latter is unfinished.

Also fix a bug in the Pure' type smart pattern.
More work on effect and delay rendering in Type pretty-printer
Tricky interactions between the two...

Possibly uncovered a parser issue - see Test\TypePrinter.hs.
More work on effect and delay rendering in Type pretty-printer
Got through the confusion that was preventing me debug the "a ->{e} 'b" case.

Worked around lexer limitation in "a ->'{e} b" by rendering as "a -> '{e} b".

Realised that failure of "''a" is just a lexer limitation - "'('a)" works - so
intend to remove the code I added to prevent pretty-printer outputting chained
delays using the ' sugar.
More work on Type pretty-printer
* Various tidy-ups.
* Fix bug with nested arrows.
* Enable ' sugar for delay even for chained delays.
* Add a 'Group' node everywhere parentheses might be output.

Also added a note to say I need to make it undo the effect of generalizeEffects.  But I plan to leave that til after the Term printer is done.
Scaffold for round-trip test of TypePrinter
Adding a #define line to Builtin.hs (see the code), and running the tests, instruments
every call to Builtin.t, to test that the pretty-printer and parser are consistent, i.e.
that `parse . pretty = id` on that input.

Running this didn't throw up any new problems in the Type pretty-printer.  (It did throw up
a known limitation - lack of reversal of generalizeEffects - which is also covered by a pending
test in the suite.)

People may prefer that I take this code out again?

runarorama and others added some commits Sep 24, 2018

update watchwatch ...
to ignore other files
to watch .sbt files
to kill sbt if the build.sbt file is broken, or else everything goes to hell
Code review markups on Type pretty-printer
* (previous commit) backed out 'ambient round trip test' CPP thing in Builtin.hs - also it turned out
it was anyway only kicking in on my tests and on parsing of Builtins!  Would need to make it kick in during file parsing.
* Nest and group App chains properly
* Some extra nesting/grouping in foralls

Also fix rendering of unary tuples so they come out as `Pair a ()` rather than the ambiguous `(a)`.
@pchiusano

This comment has been minimized.

Show comment
Hide comment
@pchiusano

pchiusano Sep 24, 2018

Member

Going to merge this tomorrow if no objections.

Member

pchiusano commented Sep 24, 2018

Going to merge this tomorrow if no objections.

aryairani and others added some commits Sep 25, 2018

watchwatch will reload the last processed unison file after a haskell…
…/scala build event...

watchwatch.sh also accepts an initial unison file as a command-line arg, e.g.
  ./scripts/watchwatch.sh scratch.u

@pchiusano pchiusano merged commit ab8d81e into topic/codebase-editor Sep 25, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@aryairani aryairani deleted the topic/notebook branch Oct 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment