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

Feeling pretty giddy seeing the interpreter portion of my "Write a Compiler" course finally running in Haskell (instead of the usual Python). Definitely learned a lot and exploded a good part of my brain navigating my way through that house of mirrors.

@dabeaz Meta-circular interpreter is one of the classic exercises for Lisp or Prolog programmers ... does Haskell's static typing make this tricky? (I've only dabbled with Haskell, so genuinely curious)

@PeterLudemann Conceptually, it's not too hard to implement in Haskell. However, you effectively have to implement your own "dynamic typing" by properly putting everything into a sum type that you then destructure in the interpreter.

For me, the really tricky part has been managing environments. Especially, if you're providing mutability. Have to mess around with IORefs and other things for that.

@dabeaz I've had no problems managing environments when writing interpreters in Prolog (meta-circular and otherwise): it's just a stack (list) of key-value pairs (red-black tree), both of which can be sufficiently efficient in declarative languages, and don't need monads. I found Python more annoying for this - requiring either updating a dict and dealing with Python's semantics for collections, or making lots of copies.

@PeterLudemann The problem (in my case) is implementing something like (set! var value). I couldn't figure out a sane way to do that without IORef.

Peter Ludemann

@dabeaz I think that `(set! var value)` is essentially the same as `var=value` ... for a Python abstract interpreter (type analyzer) in , I used something similar to -passing, but with 4 items in the continuations (some are lists, some are red-black trees; all are immutable) - these can be a bit of pain to manipulate but I used a -like notation to simplify things. I presume that something similar could be done in .