by wryl · 2y ago · 0 comments
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!
)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.