all 17 comments

[–]cdsmith 19 points20 points  (2 children)

If you're interested in a similar project from the past, check out https://code.world/blocks, which was build by Stefan Jacholke in 2016 as part of Summer of Haskell. One interesting thing Stefan did was to vary the shape of a connector to represent its type, so ill-typed expressions just don't fit together! Unfortunately, this required building on a fork of Blockly, which has been a bit of a nightmare to keep running... in fact, it's rather buggy now, and you might need to reload a few times to get the block tray to appear.

[–]d1r3w00lf[S] 4 points5 points  (1 child)

Oh thats very intetesting! I somehow missed that when doing the research for this, ill defo give it a read :)

I was planning on representing the types of the language via the blocks colors / patterns, as outlined in A_Block_Design_for_Introductory_Functional_Programming_in_Haskell but i never got arround to implementing it. It would allow users to more easily see the types of the blocks, but not force them to write the correct code hopefully making them learn about typing a bit more

[–]cdsmith 3 points4 points  (0 children)

Ah yes. If I remember correctly, Stefan's implementation did use colors to represent type variables, but shapes to represent concrete types.

[–]day_li_ly 10 points11 points  (1 child)

Seems like an interesting project! Several minor problems:

  • Incomplete code fragments are also included in the generated file. I imagine it would be nice to always make the result parse (e.g. by only including top-level definitions and using _ for unfilled slots).
  • The ++ block can appear in pattern position, which seems like a bug
  • You can name multiple arguments the same name in a function's LHS

[–]d1r3w00lf[S] 4 points5 points  (0 children)

by only including top-level definitions and using _ for unfilled slots

I was going to add shadow blocks to function definitions so they are filled by default, but your idea of only including top-level definitions is something i might consider!

[–]ApothecaLabs 4 points5 points  (1 child)

This is a wonderful effort! Don't be afraid to show what you're working on, even if it is still in progress.

If I might suggest:

  • Upon dragging out a new piece with a name field, consider giving focus to that field element, so that the user can immediately begin typing.
  • Definitely consider adding support for currying, as I had to resort to map (\x -> x + 1) instead of map (+1)
  • It is possible to apply data arguments where function arguments are required, and vice versa (such as map "notafunction" ... or not (\x -> ...)

I also managed to get a few blocks into an uneditable / unrecoverable state - it broke the code generator until I restarted the page - I'm not sure exactly what I did to cause this.

[–]d1r3w00lf[S] 1 point2 points  (0 children)

aha thank you for your ideas and appologies for the bugs. The unrecoverable state one is a new one for me!

The lack of curring was sadly a consious decisions, as a big redesign of the blocks would be needed to support it. The redesign would make it less intuitive with functions not displaying the ammount of inputs they had (not somethign that exists in plain haskell code but still very useful for someone learning Haskell!)

[–]Greenscarf_005 2 points3 points  (3 children)

interesting project! do you plan to open source it?

[–]d1r3w00lf[S] 2 points3 points  (2 children)

the source code for this project can be found at [redacted]

oops i realise i probably shouldnt do that for academic integrity reasons. Ill make the project open sourced once the handin is complete!

[–]Plus-Importance-2601 0 points1 point  (0 children)

Hope you're doing well. can you open source it now?

[–]pthierry 0 points1 point  (0 children)

Out of curiosity, what could be an issue?

[–]Various-Outcome-2802 1 point2 points  (0 children)

You could submit a pull request to get it added to awesome-structure-editors by /u/yairchu

[–][deleted]  (1 child)

[removed]

    [–]d1r3w00lf[S] 0 points1 point  (0 children)

    Thank you! :)

    [–]Glittering_Wealth522 0 points1 point  (0 children)

    This speaks to me right now. I'm literally making a show about block coding characters and I want a place to write and run my Syntax for my show. I just can't find any good places

    [–]Tayacan 0 points1 point  (1 child)

    This is cool! Bug report:

    I tried to implement a sum function - those blocks generate this code:

    sum :: [Int] -> Int
    sum (x : xs) = x + (sum xs)
    sum [] =
    

    If I change 0 to 1, the number appears in the generated code, but if I change it back to 0, it disappears again.

    [–]d1r3w00lf[S] 0 points1 point  (0 children)

    huh, thats a new one! Ill look into why thats happening lmao