Modal is a matrioshka language based on pattern-matching to rewrite trees
1–10 of 23 posts
Re: Modal is a matrioshka language based on pattern-matching to rewrite trees
#2I'm Wryl, the original author of this language. I sketched it out in late 2018 and played with it in 2019 after seeing some Mill architecture articles floating around. I mostly created it out of spite, thinking "You don't need fancy designs to do high-level things on bare metal!"
At the time, I called it a term rewriting language, which seem a bit of a weaker label than what it is. It's more like a string rewriting system with variables and nested strings, with parentheses acting as the separators for sub-strings.
It got to the point where I could transcribe Quicksort from the Haskell wiki into a fragment of Modal. I stopped playing with it after I had some not-so-fun industry experiences, and declared my work a dead-end.
Devine from Hundred Rabbits managed to get me to talk about it a bit more, and has taken the language far beyond what I could dream of. It's now gone beyond a sketch to a genuine marvel of engineering which is continually being refined as we figure out more idioms. The language is in very good hands.
I'm of the opinion that rewriting is an unexplored paradigm, and that we don't really understand how to build software. Modal was a product of my research efforts, which are still on-going. I hope to bring more projects like this to light. This has been quite fun.
Re: Modal is a matrioshka language based on pattern-matching to rewrite trees
#3Re: Modal is a matrioshka language based on pattern-matching to rewrite trees
#4What is this for? What's something you make with it (or do you make stuff with it?)
A sample.
(-- ?x) ()
-- (Now we can add comments to what we are doing.)
-- (Let's add some alternative syntax for defining rules.)
(?x -> ?y) ( ?x ?y)
-- (Let's add some boolean operators, 'and' and 'or'.)
((true) && (true)) -> true
((true) && (false)) -> false
((false) && (true)) -> false
((false) && (false)) -> false
((true) || (true)) -> true
((true) || (false)) -> true
((false) || (true)) -> true
((false) || (false)) -> false
-- (Some alternative syntax.)
(?x and ?y) -> (?x && ?y)
(?x or ?y) -> (?x || ?y)
-- (Let's build an 'if' statement.)
(quote ?x) -> (quote ?x)
(unwrap (?x)) -> (unwrap ?x)
(unwrap ?x) -> ?x
(
if ?c
?t
else
?f
) -> (
if/else ?c
quote ?t
quote ?f
)
(
if/else (true)
quote ?t
quote ?f
) -> (
unwrap ?t
)
(
if/else (false)
quote ?t
quote ?f
) -> (
unwrap ?f
)
-- (All together.)
if ((true) and ((false) or (true))) (
Hooray!
) else (
Boo!
)Re: Modal is a matrioshka language based on pattern-matching to rewrite trees
#5What is this for? What's something you make with it (or do you make stuff with it?)
It's a general purpose programming language who's main paradigm is rule-based pattern matching. A sample. (-- ?x) () -- (Now we can add comments to what we are doing.) -- (Let's add some alternative syntax for defining rules.) (?x -> ?y) ( ?x ?y) -- (Let's add some boolean operators, 'and' and 'or'.) ((true) && (true)) -> true ((true) && (false)) -> false ((false) && (true)) -> false ((false) && (false)) -> false ((t…
Re: Modal is a matrioshka language based on pattern-matching to rewrite trees
#6Earlier quoted context omitted.
It's a general purpose programming language who's main paradigm is rule-based pattern matching. A sample. (-- ?x) () -- (Now we can add comments to what we are doing.) -- (Let's add some alternative syntax for defining rules.) (?x -> ?y) ( ?x ?y) -- (Let's add some boolean operators, 'and' and 'or'.) ((true) && (true)) -> true ((true) && (false)) -> false ((false) && (true)) -> false ((false) && (false)) -> false ((t…
What's it for though? Is it optimized for building anything specific?
This means that the above sample is effectively your "assembly language". There was no gap between your programs and the hardware they ran on.
Modal can be used to write small utilities, games, programming language implementations, type systems.. the list goes on. It's a fully general meta-language that can be used for general purpose programming.
Re: Modal is a matrioshka language based on pattern-matching to rewrite trees
#7Earlier quoted context omitted.
What's it for though? Is it optimized for building anything specific?
Not particularly, no. Nothing specific. The semantics of the language lend themselves well to an implementation in hardware. I had a sketch in VHDL in the time I spent developing this. This means that the above sample is effectively your "assembly language". There was no gap between your programs and the hardware they ran on. Modal can be used to write small utilities, games, programming language implementations, typ…
Re: Modal is a matrioshka language based on pattern-matching to rewrite trees
#8Earlier quoted context omitted.
Not particularly, no. Nothing specific. The semantics of the language lend themselves well to an implementation in hardware. I had a sketch in VHDL in the time I spent developing this. This means that the above sample is effectively your "assembly language". There was no gap between your programs and the hardware they ran on. Modal can be used to write small utilities, games, programming language implementations, typ…
Oh I see, very cool. Would be interesting to see basic graphics programming using it - the aesthetics of the page and how it's presented are very intriguing, but a little esoteric/mysterious (perhaps intentionally so).
Re: Modal is a matrioshka language based on pattern-matching to rewrite trees
#9What is this for? What's something you make with it (or do you make stuff with it?)
Re: Modal is a matrioshka language based on pattern-matching to rewrite trees
#10What is this for? What's something you make with it (or do you make stuff with it?)
It's a general purpose programming language who's main paradigm is rule-based pattern matching. A sample. (-- ?x) () -- (Now we can add comments to what we are doing.) -- (Let's add some alternative syntax for defining rules.) (?x -> ?y) ( ?x ?y) -- (Let's add some boolean operators, 'and' and 'or'.) ((true) && (true)) -> true ((true) && (false)) -> false ((false) && (true)) -> false ((false) && (false)) -> false ((t…