diprism / perpl

The PERPL Compiler
MIT License
10 stars 5 forks source link

Improving Command Line Flags #136

Open colin-mcd opened 1 year ago

colin-mcd commented 1 year ago

Usage right now is

usage: perplc [OPTION ...] INFILE.ppl
  -m            Don't monomorphize (implies -lec)
  -l            Don't linearize (implies -ec)
  -e            Don't eliminate recursive datatypes (implies -c)
  -c            Compile only to PPL code (not to FGG)
  -z            Compute sum-product
  -o OUTFILE    Output to OUTFILE
  -O LEVEL      Optimization level (0 = off, 1 = on)
  -d DTYPE      Defunctionalize recursive datatype DTYPE
  -r DTYPE      Refunctionalize recursive datatype DTYPE

But I think it would be a lot more intuitive if we had flags like -m stop after monomorphization rather than before. That way, if you want to see just the monomorphized code you would do -m, instead of having to remember which stage follows monomorphization. I suggest the following:

usage: perplc [OPTION ...] INFILE.ppl
  -m            Stop after monomorphizing
  -l            Stop after linearizing
  -e            Stop after eliminating recursive datatypes
  -c            Stop after compiling to final-stage PPL code (not to FGG)
  ...
ccshan commented 1 year ago

I like this idea~ I guess each stage of our compiler depends on the previous stages and there is no "optional" stage. (I could imagine replacing a stage by a check that, for instance, the input program is already linear or monomorphic.)