Get the latest tech news

APL Interpreter – An implementation of APL, written in Haskell (2024)


January 11, 2024 (Github Link) Why APL? APL is an array programming language1. Its only data type is the (multidimensional) array.

While this might seem like a huge limitation, the generality it provides leads to a syntax that is incredibly compact and expressive, which forces the programmer to approach problems at a higher level. In all honesty, Haskell probably isn’t an ideal tool for an array-language interpreter: it makes parsing and combination of functions much more elegant, but at the expense of ease of working with state, data structures, and performance. In my interpreter, … Dops/dfns are not strongly short-circuited: if the condition in a guard is false, the rhs isn’t evaluated, but it is still parsed (in Dyalog, it isn’t parsed) Scalars are not 0-rank: they are vectors with a single element (this approach seems more simple, but it causes some incompatibilities in the behavior of certain functions) Arrays with non-1 rank cannot have zero as an element in their shape (Dyalog allows this) LCM, GCD, factorial, and binomial only work on integers (Dyalog allows reals and complex numbers) The circle function (dyadic ○) only supports 1 2 3, ¯1, ¯2, ¯3 Dfns cannot modify global variables ⎕IO can be any integer(not just 0 or 1) Axis spec operator is more limited (several functions don’t support it (e.g. ⊂)), it also only takes singleton numbers, never vectors Dyadic ⍒/⍋ is limited to vector (not higher-dimensional array) collation sequences Reduce can’t take a negative or zero argument on left (window) Encode only works on integers

Get the Android app

Or read this on Hacker News

Read more on:

Photo of implementation

implementation

Photo of Haskell

Haskell

Photo of APL Interpreter

APL Interpreter

Related news:

News photo

Programming language Dino and its implementation

News photo

Technical Guide to System Calls: Implementation and Signal Handling in Modern OS

News photo

Show HN: A Implementation of Alpha Zero for Chess in MLX