home.social

#freemonad — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #freemonad, aggregated by home.social.

fetched live
  1. To my surprise, the idea I had last night is actually working just fine in #RustLang.

    So, my #VisualNovel #SpareTimeProject is now probably going to use an #eDSL encoded as a #FreeMonad which is wrapped in a #StateMonadTransformer.

    Now I just need to continue working on it. I haven't made much progress in the last 9 months...

  2. Yesterday I ported Haskell's State Monad Transformer to #RustLang. That should make tracking the game state in my #FreeMonad based embedded Domain Specific Language for scripting the story in my spare time #VisualNovel #GameDev project way easier.

    Also, the currently released version of "higher" has the limitation that bindings in do-notation only work well with Copy types. The State Monad Transformer doesn't have this limitation and can store any state that is Clone.

  3. @joenash The blog posts haskellforall.com/2012/07/puri & haskellforall.com/2012/06/you- by @GabriellaG439 about #FreeMonad|s seem related. They don't contain this claim verbatim, but a kinda lemma of it: «[…] we can always factor out impure parts from any code by using free monads. Free monads let you decompose any impure program into a pure representation of its behavior and a minimal impure interpreter[…]»

    @donsbot

  4. I've started some architecture work for my potential #VisualNovel spare time project. I must say I'm torn between using a #FreeMonad for storytelling, or going the usual #RustLang way of using a trait...

    A Free Monad would decouple the storytelling from the user interaction completely, and its internal state would become trivial to manage.

    A trait would allow to utilize Rust's borrow checker to ensure a situation's consistency. For instance one could tie a character's lifetime to the location.

  5. On the topic of #FreeMonad in #RustLang: I found out that there is another package on crates.io, that was released a few weeks before my higher-free-macro macro:
    crates.io/crates/algar

    Unlike my code algar is using a generic type instead of a macro, what is possible because it has different Functor/Monad/... traits that use an associated type to specify the domain.

    On the other hand, algar has limitations that higher-free-macro does not have. Its Monad can only bind with FnOnce, for instance.

  6. I went ahead and published my small #FreeMonad crate for #RustLang officially today.

    crates.io/crates/higher-free-m

    This crate employs a macro to create a Free Monad type for a user-supplied Functor. The Free Monad is implemented as a recursive data type with Box as indirection.

    It uses the traits from the "higher" crate by @bodil to express what a Functor/Monad/etc. is.

  7. Today I've added an example to my #FreeMonad in #RustLang project.
    It is pretty bad code, but that's what happens if one intentionally makes bad decisions in order to highlight issues and potential workarounds...

    For instance, I used a `Vec` where a 3-element array would have sufficed, making me write a ton more `clone()` calls than I ever wanted...

    Still, I'm pretty happy how small the interpreter turned out, and how easy it was to focus on the actual game logic:
    github.com/soulsource/higher-f