Dex: New functional language for array processing
There’s a new open source language for programming with typed indices: “Dex”, short for index. The Haskell-type language was developed as an unofficial project at Google Research and is still in the very early stages of development. Let’s take a closer look.
Dex is a new research language for array processing. It was developed by Google Research engineers Dougal Maclaurin, Alexey Radul and Matthew J. Johnson, alongside DeepMind’s Dimitrios Vytiniotis. They outlined the purpose of Dex in their workshop paper titled “Dex: array programming with typed indices”.
The concept of Dex
According to the researchers, some points complicate array programming more than necessary, e.g. managing bulk operations on high-rank arrays. The shape and indexing errors that are associated with them cause difficulties as well. That’s where Dex comes in. The functional array processing language originates in the Haskell/Meta Language (ML) family and is designed to offer an index comprehension syntax that is expressive and lightweight.
Dex could also serve as an inspiration for similar languages, as the engineers state in their paper: “We hope the language ideas we present here can influence the design of existing array programming systems.”
estimatePiArea :: Key -> Real estimatePiArea key = (k1, k2) = splitKey key x = rand k1 y = rand k2 inBounds = sq x + sq y < 1.0 4.0 * b2r inBounds estimatePiAvgVal :: Key -> Real estimatePiAvgVal key = x = rand key 4.0 * sqrt (1.0 - sq x) meanAndStdDev :: A n. (Key -> Real) -> Key -> (Real, Real) meanAndStdDev f key = samps = many @n f key (mean samps, std samps) type NumSamps = 1000000 :p meanAndStdDev @NumSamps estimatePiArea 0 (3.143024, 1.6411874163007711) :p meanAndStdDev @NumSamps estimatePiAvgVal 0 (3.1417837281469603, 0.892754742618003)
If you want to try out the new programming language, you need the Haskell Tool Stack as well as LLVM 7, e.g. via
apt-get install llvm-7-dev.