google / codeworld

Educational computer programming environment using Haskell
http://code.world
Apache License 2.0
1.24k stars 193 forks source link

Math-editor mode #813

Open cdsmith opened 5 years ago

cdsmith commented 5 years ago

This proposal is to add a math-editor mode for CodeWorld. This would be a new mode that, instead of editing in a standard code editor, would integrate a WYSIWYG math editor into the UI.

Currently, there are three "modes" to CodeWorld.

  1. Classic mode. This is the educational environment at http://code.world
  2. Haskell mode. Located at http://code.world/haskell, this uses CodeMirror, but with a more standard Haskell UI.
  3. Blocks mode. This replaces the code editor with a block-based version based on Blockly.

In this proposal, we'd add a fourth mode: http://code.world/algebra (not a real link) In this mode, instead of a coding editor based on CodeMirror, we'd offer an equation editor (like MathQuill or such, but possibly needing a lot of customization). This would require implementing a language based on the results of the math editor, possibly by converting via Haskell, similar to what we do now with blocks -- or possibly even by implementing an interpreter directly in JavaScript. (Obviously, that's no small undertaking, as it's essentially inventing a brand new language!)

The goal of doing this would be to take the underlying philosophy of CodeWorld even further, by allowing students to write in something even closer to mathematics.

This has some of the same limitations as blocks, in that if the implementation is by conversion to Haskell, then we'd either need to detect and prevent all possible errors at editing time (which is likely to be a leaky moving target), or somehow convert errors from Haskell back into the equation editor.

cdsmith commented 4 years ago

This is absolutely something I'm excited to work on. More ideas:

  1. The UI should be something like a notebook format, where text blocks can be interspersed with math blocks that define parts of the program. There should be built-in formatting for a title, author(s)... I am sort of liking the idea of modeling it after a math paper, so it would make it easy to add an "abstract", would number your definitions. Inline assertions could be labeled and numbered, as well.
  2. MathQuill is definitely a good starting point for the editor. Additionally, the whole library will have to be reworked to look more like mathematics. Instead of translated, we'd probably want a name like T_{xy}. And we'd definitely want to use mathematical notation for all the little things that CodeWorld cannot, such as the set of real numbers, cartesian products of types. Piecewise functions could be typed with an { instead of Haskell-format guards. Pattern matching should be changed so that instead of bound variables that shadow global scope, an expression that matches one in global scope is considered a specific value. And so on.
  3. It would definitely be good to simplify types more, such as by making string literals into picture expressions automatically (forget fonts and such, we don't need them), and eliminating the Program type in favor of just having a small selection of "modes" for drawings, animations, activities, and group activities.
  4. I can see adding all kinds of info into the source that helps with giving learners cues about the meaning of notation. For instance, when writing "f(x) = x + 2", the signature line could be added automatically. I'd also considering adding a little text that says "for any x," before the line as an annotation to explain the implicit quantification.
  5. The compilation to JavaScript should run on the client. The code should be designed to be hot-swapped into the running program as it's edited. And so on.

Chances are this will start out being less capable than the existing mode. That's okay, since it's an alternative rather than a replacement. My hope would be to eventually transition K-12 use cases here, but that's realistically probably 10 years off.