Hi everyone
We are using Blockly in a educational project to generate code for a functional language. More specifically we are generating Haskell code in order to build
CodeWorld applications.
This version supports better typing of blocks and allows Blocks to be polymorphic.
Haskell is a strict, pure, functional language and we work on immutable data structures in CodeWorld. Each function in CodeWorld has a type and hence all of our Blocks have types. I think this makes it well suited for a block-based environment as we can expressively see how the program flows.
The majority of the application is currently in Haskell. The Haskell code is compiled to JavaScript through GHCJS.
Once a user builds an application with the Blocks, and clicks run, code is generated for Haskell. This code is sent to the server, the code gets compiled again with GHCJS, using the CodeWorld libraries and the resulting program is then run in the browser.
We are generating Haskell CodeWorld code, instead of just running the application directly, as a means to teach programming to young students. Later they can use the full text UI for advanced programs.
This version currently supports:
- Building simple CodeWorld applications (pictures and transformations thereof)
- Generation of Haskell CodeWorld code and running it in the browser.
- Some use of polymorphic blocks (if, equality)
- Custom let definitions for variables (still a work in progress).
We might later on develop more advanced features that are used in functional languages, such as:
- Recursion
- Handling of first class typed functions
- Algabraic data types
- Pattern matching
I'm mainly posting this for this for those interested in some of the features we are working on, or to see if there is interest in such work. Maybe some of this could provide some utility for others doing something similar.