User:Junkshipp/Sandbox2
i have an idea for a visual, typed minimalistic esolang. each value would be a ”block”, some atomic and some composite (i.e. made out of smaller blocks).
typing rules would be enforced by ”teeth” on these blocks. for example, the type N -> N -> N would be represented by the teeth pattern 🔺▪️🔺▪️▪️, written in polish notation. (note: this detail is subject to change). each block would have a teeth pattern on the left of the block and possibly on right, depending on the mode the block is in: in parameter mode, all teeth would be on the left. all blocks would have a parameter mode. blocks representing function types would also have an application mode, in which the first triangle is deleted and the type of the parameter of the function is moved to the right side, though the teeth there are inverted (i.e. become notches). toggling between these two modes should be simple, perhaps by right-clicking on the block.
applying a block representing a function to another block would be as simple as putting them next to each other and connecting the teeth to notches. for example, say I had a block A of type (N -> N) -> N (🔺🔺▪️▪️▪️) and a block B of type N -> N (🔺▪️▪️), both in parameter mode, and I wanted to apply the first block to the second. block A would start out with the teeth 🔺🔺▪️▪️▪️ on the left and no teeth on the right. by right-clicking it (or whatever), i could change the mode of block A to application mode. it would now have the tooth ▪️on the left side and the teeth (inverted, so notches) 🔺▪️▪️ on the right side. block B in parameter mode would have exactly that pattern of teeth (not notches) on the left side and no teeth on the right. by dragging the two blocks next to each other, the teeth on the left side of B and the notches on the right side of A would interlock, creating a new composite block. the new composite block would have the tooth ▪️on the left side (as block A, in application mode) and no teeth on the right (like block B).
this new composite block, would thus be of the type N (▪️), and would be in parameter mode. as can be seen, applying a block of type (N -> N) -> N to a block of type N -> N gave us a block of type N, exactly as expected. this always works.
one difficulty with this system is notating the order in which functions are applied to each other, as no brackets would be available. this could be done by “indentation” (not actually indentation, just analogous), where the heights of blocks would provide this information. before i explain this, let’s define the height of a block to be the height of its first block from left to right. when two blocks would be applied to each other, the height of the second block would be adjusted to be one “indentation level” taller than the height of the first, keeping the relative heights of the blocks in the second block intact. for the next examples, imagine turning your head sideways, 90 degrees to the right.
c-like notation: A(B)(C) haskell-like notation: A B C block notation:
A BB CC
c-like: A(B(C)) haskell-like: A (B C) block:
A BB CCC
c-like: A(B(C))(D) haskell-like: A (B C) D block:
A BB CCC DD