1. 3

    it’s be nice, for pdf papers, to add a bit of context to help people decide whether to read or not.

    1. 3

      Good idea.

      From the abstract: “This is the year 2008 and ML-style exceptions are everywhere. Most modern languages, whether academic or industrial, feature some variant of this mechanism. Languages such as Java even feature static coverage-checking for such exceptions, something not available for ML languages, at least not without resorting to external tools. In this document, we demonstrate a design principle and a tiny library for managing errors in a functional manner, with static coverage-checking, automatically-inferred, structurally typed and hierarchical exceptional cases, with a reasonable run-time penalty. Our work is based on OCaml and features monads, polymorphic variants, compile-time code rewriting and trace elements of black magic.”

    1. 7

      In PureScript or OCaml, you can use open variant types to do this flawlessly

      Yes!! Polymorphic variants are incredible

        1. 4

          Note that open variants are different from polymorphic variants, albeit both are incredible.

          1. 1

            Oh good to know! Is open variant then the ability to define new exceptions, all of which are part of the exn variant?

            1. 4

              In fact, you can consider exceptions of exn to be a special case of the open, or extensible variant! See https://caml.inria.fr/pub/docs/manual-ocaml/extn.html#sec266 for more details.

              1. 2

                That’s awesome!

          2. 2

            Another thing I thought was nice to mention: row polymorphism.

            In row polymorphism, variants are open by default. I’ve been toying with writing my own implementation but this one has a nice readme explaining pretty well how it works.

            https://github.com/willtim/Expresso#variants

            The reason given for variant literals being open by default is usually to do error handling and only expose our current problems.

            1. 4

              Polymorphic variants in OCaml work by row polymorphism - this paper introduced the algorithm and resulted in the ocaml implementation. Good luck with the implementation! It’s my favorite type system feature :)

          1. 3

            desktop and battle station

            The usual stuff: awesome with lots of tabs, some poorly written widgets, and a relatively minimal vim with the excellent merlin. xterm for minimal typing latency. Other stuff in the background: cmus, unbound, redshift, neomutt. The laptop is a heavyweight (5 kg) Clevo P775 with desktop components and a 3k screen.

            1. 1

              I’ve never seen that one image in the Game of Life article. That looked wild. Do you have a link to that implementation and its parameters so we can replicate it?

                1. 1

                  I saw some experimentation back when I looked at it with gliders or simple patterns. I didnt know they’d taken it this far with these complex designs. Pretty amazing. Thanks for the link.

              1. 5

                Fun facts:

                • All instructions use modrm encoding for encoding memory operands, except for A0/A1/A2/A3, where the address is a constant encoded immediately after the instruction (“moffs”).
                • x86 has a single-byte encoding for INC esp (increment stack pointer by one).
                • x86 has a single-byte encoding for BCD-arithmetic. For example: AAA - ASCII Adjust After Addition.
                • POP [ptr] (pop a dword from the stack and move it to the specified address in memory) updates esp before resolving ptr (which can contain esp). In some sense it mixes decoding of the instruction and execution.
                • LEA reg, [ptr] is an instruction that computes ptr and stores it in a register without referencing memory. Pointer arithmetic is very flexible in x86, being able to add a register with a shift, another register and a constant offset. For example, it can encode a = b + c -1 in a single instruction. LEA is also the only instruction that fails when encoded with a register operand (because LEA reg1, reg2 is invalid) but never fails when encoded with a memory operand.
                • There are two ways to encode OP reg1, reg2 for most instructions.
                • XCHG eax, r is encoded as 0x90+r, NOP is 0x90 or XCHG eax, eax.
                • Most arithmetic instructions also compute the parity flag, which is the parity of the lowest byte of the result.
                • Most arithmetic instructions also compute the adjust flag, which is set when an overflow happens from the 4th bit of the result.
                • Due to a bug in Windows NT, CPUID reports some bits differently depending configuration registers. Search for “bug” in http://sandpile.org/x86/cpuid.htm.
                1. 2

                  NOP hasn’t been XCHG EAX,EAX since the 80386—it causes an unnecessary dependency on EAX so it’s been special coded for quite a long time.

                1. 1

                  Nice work! I’ve been looking for a x86 virtual machine that is similar to SPIM where I can either enter code line by line or via a file. The v86 project has caught my eye but it’s not quite what I want. Any suggestions?

                  1. 1

                    What are you missing about v86? What you want could probably be done if you bring your own assembler (for example by porting NASM using emscripten) and we export some internal apis from v86.

                    1. 1

                      I was hoping for an interface where I can see the registers, flags, memory, etc. in real time along with the .text history, similar to this.