Commit Graph

574 Commits

Author SHA1 Message Date
Chris Gibbs
0fed33475b A few more Type pretty-printer tests (some still pending) 2018-09-22 00:00:43 +01:00
Chris Gibbs
a6706b6829 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?
2018-09-22 00:00:38 +01:00
Chris Gibbs
14be343515 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.
2018-09-22 00:00:37 +01:00
Chris Gibbs
026dc21a2e 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.
2018-09-22 00:00:35 +01:00
Chris Gibbs
05f362e359 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.
2018-09-22 00:00:34 +01:00
Chris Gibbs
7304708255 Add support for tuple and delay sugar to type-printer
The latter is unfinished.

Also fix a bug in the Pure' type smart pattern.
2018-09-22 00:00:32 +01:00
Chris Gibbs
0b18e0eb3e Code review markups on Type pretty-printer
Making changes as per Paul's comments at df938b2d85
2018-09-22 00:00:31 +01:00
Chris Gibbs
4fd2350f51 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).
2018-09-22 00:00:27 +01:00
Chris Gibbs
3db821f8f1 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]`.
2018-09-22 00:00:22 +01:00
Chris Gibbs
1c3ea375f3 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.
2018-09-22 00:00:21 +01:00
Chris Gibbs
6dc1fe58bc 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.
2018-09-22 00:00:19 +01:00
Arya Irani
c9e2f82041 start of PrettyPrinter.hs 2018-09-22 00:00:17 +01:00
Rúnar Óli Bjarnason
21df3334a2 Added a file watcher 2018-09-20 13:30:40 -04:00
Paul Chiusano
56356a844a Merge remote-tracking branch 'origin/master' into topic/haskell-runtime
# Conflicts:
#	parser-typechecker/src/Unison/ABT.hs
2018-09-11 23:13:16 -04:00
Paul Chiusano
8e02bc46a3 Convert lambda application to let, get rid of Apply instruction
Calls to known functions are converted to let bindings
2018-09-11 23:10:00 -04:00
Paul Chiusano
248ebf1e0c made IR closed 2018-09-09 16:18:58 -04:00
Paul Chiusano
f3ff3b4ae6 Revert "simplify"
This reverts commit 6c54fe3933.
2018-09-09 15:43:28 -04:00
Paul Chiusano
6c54fe3933 simplify 2018-09-09 15:27:11 -04:00
Paul Chiusano
169c14f784 builtins 2018-09-09 15:05:14 -04:00
Paul Chiusano
f057e59df2 added separate static / dynamic apply IR 2018-09-07 23:41:13 -04:00
Paul Chiusano
2b1bd38246 successfully evaluated (x y -> x) 42 0 2018-09-07 16:55:52 -04:00
Paul Chiusano
5291996c83 unpending some tests 2018-09-05 14:49:14 -04:00
Arya Irani
1f3f405274 better fix for tests/state2a-min.u (effects in non-recursive let rec) 2018-09-04 16:15:32 -04:00
Arya Irani
231055d146 fix tests/state2a-min.u by calling Components.minimize' in block
and also by fixing Components.minimize'
2018-09-04 15:42:04 -04:00
Paul Chiusano
388d0a3a54 Merge remote-tracking branch 'origin/master' into topic/haskell-runtime 2018-09-04 13:49:28 -04:00
Arya Irani
e534a5581c
Merge pull request #243 from unisonweb/fix/effect-instantiation2
Misc typechecker bugfixes
2018-09-04 10:18:13 -04:00
Arya Irani
9ba1e249f8
Merge pull request #244 from unisonweb/wip/pretty-errors
misc fixes & cleanup
2018-09-04 10:17:53 -04:00
Paul Chiusano
2561265d36 Merge branch 'fix/effect-instantiation2' into topic/haskell-runtime 2018-09-01 14:13:37 -04:00
Paul Chiusano
3b369ec295 Merge remote-tracking branch 'origin/master' into fix/effect-instantiation2 2018-09-01 10:54:25 -04:00
Paul Chiusano
26f06a644a remove debugging statements 2018-09-01 10:53:27 -04:00
Paul Chiusano
58b9b37573 fix regression in map-reduce 2018-09-01 10:50:11 -04:00
Paul Chiusano
0d5727a641 fix test that was causing <<loop>> due to circular annotation definition in the typechecker 2018-08-31 18:51:05 -04:00
Arya Irani
7d4c37f71b
Merge pull request #242 from unisonweb/fix/effect-instantiation
Fix issue with ability instantiation
2018-08-31 17:11:37 -04:00
Arya Irani
bd7f713545 more cleanup 2018-08-31 15:24:31 -04:00
Paul Chiusano
53d735d84a fix to instantiateL/R which was completely forgetting to instantiate effects
This appears to have been masking another error with effect inference in map-reduce.u, which is now failing with an ability check again
2018-08-31 13:36:48 -04:00
Arya Irani
a48fa3bd82 add two pending tests
unison-src/test1.u became a-tale-of-two-optionals.uu
2018-08-31 12:16:38 -04:00
Paul Chiusano
731319ae2e nicer inferred types for lambdas that don't mention pointless effect variables 2018-08-31 12:01:27 -04:00
Paul Chiusano
5ae98f7f2a fixed, but want to clean up inferred types a bit to eliminate unneeded effect vars 2018-08-31 10:12:49 -04:00
Arya Irani
e9eceff67a more final cleanup 2018-08-30 19:18:44 -04:00
Arya Irani
20c39ce084 final cleanup 2018-08-30 18:58:14 -04:00
Arya Irani
183f0e4264 a couple more tests 2018-08-30 18:25:41 -04:00
Arya Irani
171cbdc6cc add some regression tests to ensure/refute specific type errors 2018-08-30 18:19:27 -04:00
Arya Irani
7162382ade wired up "wrong argument type" message with polymorphicTypeInfo 2018-08-30 17:45:40 -04:00
Arya Irani
994ff0249f Merge remote-tracking branch 'origin/master' into wip/pretty-errors 2018-08-30 13:55:32 -04:00
Arya Irani
cb2dee86fa Merge remote-tracking branch 'origin/master' into wip/pretty-errors 2018-08-30 13:55:00 -04:00
Paul Chiusano
940504a476 builtins are effect polymorphic 2018-08-30 10:32:06 -04:00
Paul Chiusano
35b5945a77 fixed regression in map-reduce due to overagressive generalizeEffects impl even if user has already provided effect variables in the signature 2018-08-30 10:05:42 -04:00
Paul Chiusano
794c98c03e seems to be working but regression in map-reduce.u 2018-08-29 23:39:46 -04:00
Arya Irani
48f61bc76c wired up "wrong argument type" error; polymorphicTypeInfo bit still needs debugging 2018-08-29 18:52:38 -04:00
Paul Chiusano
d258fb01fc WIP, still not quite working 2018-08-29 17:42:04 -04:00