Hardware Design with Generalized Arrows

* Final gross prices may vary according to local VAT.

Get Access


Ordinarily, a compiler for a multi-level language will contain some knowledge of the object language; for example, in a multi-stage programming language with runtime code generation, the compiler will know how to produce code which emits machine code for object language expressions. This means that adding, extending, or replacing the object language requires knowledge of compiler internals.

Generalized arrows act as an intermediate language, separating the meta language compiler from the object language implementation. Two-level expressions are flattened [11] into ordinary one-level expressions polymorphic in an instance of the GArrow class, which is used to represent object language expressions. Operations on object language expressions are then packaged in an instance of the GArrow class, which is a library rather than part of the compiler.

This paper presents an example application of this approach: a bit-serial circuit which searches for SHA-256 hash collisions. A two-level circuit-building program is passed through the GHC flattening pass (which is not specific to hardware design in any way) and the resulting one-level program is combined with a GArrow instance that emits Verilog code; this instance is an ordinary Haskell library which can be written without knowledge of compiler internals.