mathstodon.xyz is one of the many independent Mastodon servers you can use to participate in the fediverse.
A Mastodon instance for maths people. We have LaTeX rendering in the web interface!

Server stats:

2.8K
active users

#lamber

0 posts0 participants0 posts today
Artyom Bologov<p>Acknowledging that I'm lazy on a work seminar might've been a mistake, but I did it. And now I'm writing a post on the most laziest <a href="https://merveilles.town/tags/ProgrammingLanguage" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ProgrammingLanguage</span></a> design case ever. Using <a href="https://merveilles.town/tags/Lamber" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Lamber</span></a>, of course:</p><p><a href="https://github.com/aartaka/lamber" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="">github.com/aartaka/lamber</span><span class="invisible"></span></a></p>
Artyom Bologov<p>In the spirit of (not-that-radical, unfortunately) openness (inspired by none other than <span class="h-card" translate="no"><a href="https://mas.to/@TodePond" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>TodePond</span></a></span>,) let me share a thing I've been quietly working on for the last couple of months: <a href="https://merveilles.town/tags/Lamber" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Lamber</span></a>, my pure <a href="https://merveilles.town/tags/LambdaCalculus" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>LambdaCalculus</span></a> -compiling <a href="https://merveilles.town/tags/FunctionalProgramming" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>FunctionalProgramming</span></a> language inspired by <a href="https://merveilles.town/tags/Lua" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Lua</span></a> and <a href="https://merveilles.town/tags/haskell" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>haskell</span></a> </p><p><a href="https://github.com/aartaka/lamber" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="">github.com/aartaka/lamber</span><span class="invisible"></span></a></p><p><a href="https://merveilles.town/tags/theWorkshop" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>theWorkshop</span></a></p>
Artyom Bologov<p>I want to use <a href="https://merveilles.town/tags/ed" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ed</span></a> more, but me being a Lisper is a huge obstacle to that. <a href="https://merveilles.town/tags/Lisp" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Lisp</span></a> ASTs and line-based editing don't play well together. And it's a pain to balance the parens in ed. I have already amassed a bunch of regex scripts for doing Lisp, but it's clearly not enough.</p><p>Sigh. I want to write something that isn't C or <a href="https://merveilles.town/tags/Lamber" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Lamber</span></a> in <a href="https://merveilles.town/tags/ed" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>ed</span></a>, but I have to come up with a lot of tools and hacks for that.</p>
Artyom Bologov<p>I think my idea of a simple type system for <a href="https://merveilles.town/tags/Lamber" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Lamber</span></a> is coming together:<br>- We have primitive/nominal/tag types, like int, char, bool.<br>- We have structure/record/tuple/constructed types that consist of N types.<br>- We have function types that accept args of some type each and return a value of some type.<br>- Function types and structute types can and are recursive. They can include other types.</p><p>An important property of structure types is that their members are named by accessors (which rarely is a problem, right?) So hypothetic cons type is:</p><p>def cons = type (car cdr)<br> fn (f) f car cdr .</p><p>This way, we ensure that there are accessor functions, car and cdr, and that they return properly typed values. E.g., we can infer that for "let x = cons 1 true", "car x" will return an int, while "cdr x" will return a bool.</p><p>I've done it this way because I want a syntactically simple type system that works. A property I want to retain is never having to declare function types explicitly, only relying on type annotations/constructors inside of them to infer the types.</p><p>I'm still thinking on whether this is a good solution, but it seems to strike a perfect balance between conceptual simplicity and the amount of implementation magic required for it.</p><p><a href="https://merveilles.town/tags/theWorkshop" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>theWorkshop</span></a></p>
Artyom Bologov<p><a href="https://merveilles.town/tags/TIL" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>TIL</span></a> that there's a <a href="https://merveilles.town/tags/LambdaCalculus" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>LambdaCalculus</span></a> based language called brujin (for obvious reasons) and that it's absolutely unreadable! The standard library and the amount of work that went into it is extremely impressive though, so go give it a read:</p><p><a href="https://bruijn.marvinborner.de/" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="">bruijn.marvinborner.de/</span><span class="invisible"></span></a></p><p>and show some love to Marvin Borner, the creator of brujin!</p><p>I'm stealing parts of it (like Maybe monad) into <a href="https://merveilles.town/tags/Lamber" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Lamber</span></a>, my own applicative <a href="https://merveilles.town/tags/LambdaCalculus" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>LambdaCalculus</span></a> compiling <a href="https://merveilles.town/tags/Lua" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Lua</span></a> like language.</p><p><a href="https://merveilles.town/tags/theWorkshop" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>theWorkshop</span></a> <a href="https://merveilles.town/tags/theLibrary" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>theLibrary</span></a></p>
Artyom Bologov<p>So I compiled a proper standard library for <a href="https://merveilles.town/tags/Lamber" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Lamber</span></a>, taking all functions from <a href="https://github.com/aartaka/stdlambda" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="">github.com/aartaka/stdlambda</span><span class="invisible"></span></a> and translating them to a much more readable syntax!</p><p>What's left is making a proper front-end/CLI, and the language is ready for open sourcing!</p><p>I can add much more to it, but that's a minimum. The wishlist for more is:<br>- Infix operations.<br>- Type checking and inference.<br>- Record types.<br>- State/IO operations.<br>- Interfacing with underlying platform (Common Lisp) and reusing its functions.<br>- Optimization passes based on the above.<br>- More implementations!</p>
Artyom Bologov<p>Y'all, how readable does this piece of code seem to you?</p><p>def div = fn (numer denom)<br> local loop = fn quot<br> when lt quot denom<br> then 0<br> else : succ : loop : sub quot denom<br> end<br> loop numer<br>end</p><p>That's division via subtraction from <a href="https://merveilles.town/tags/Lamber" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Lamber</span></a> standard library. And yes, it parses, compiles to pure <a href="https://merveilles.town/tags/LambdaCalculus" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>LambdaCalculus</span></a> and returns the right number when applied properly!</p><p><a href="https://merveilles.town/tags/theWorkshop" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>theWorkshop</span></a></p>