A stylized image of Haskell code from the article

Alphabet Soup: Haskell’s Single-Letter Naming Quirks

When you used punch cards or tape to write a computer program, brief variable names were the norm. Your compiler or assembler probably only allowed six letters, anyway. But times change, and people who, by habit, give array indices variable names like I, J, or K get a lot of grief. But [Jack Kelly] points out that for highly polymorphic languages like Haskell, you often don’t know what that variable represents anyway. So how are you supposed to name it? He provides a guide to one-letter variable names commonly used by Haskell developers and, sometimes, others.

Haskell’s conventions are particularly interesting, especially with i, j, and k, which are borrowed from mathematical tradition to signify indices or integers and passed on via Fortran. The article also highlights how m often refers to Monads and Monoidal values, while t can represent both traversables and text values. Perhaps more obscurely, p can denote profunctors and predicates, giving a glimpse into Haskell’s complex yet efficient type system. These naming conventions are not formal standards but have evolved into a grass-roots lexicon.

Of course, you can go too far. We see a lot of interesting and strange things written in Haskell, including this OpenSCAD competitor.

front view of a purple acrylic slide rule with white ink scale markings.

Design And Build Your Own Circular Slide Rule

You have to really like slide rules to build your own, including the necessary artwork. Apparently [Dylan Thinnes] is a big fan, based on this project he began working on a few months back. The result is a set of algorithms that automatically generates most of the scales that were common on slide rules back in the day. For example:

K       Cubic scale, x^3
A,B     Squared scale, x^2
C,D     Basic scale, x
CI,DI   Inverted scale, 1/x
CF,DF   Folded scale, x*pi
LLn     Log-log scales, e^a*x
LL0n    Log-log scales, e^-a*x
L       Log scale, log10(x), linear
S       Sine and cosines scale, sin(x)
T       Tangent scale, tan(x)

If you’ve ever tried to manually draw an axis using a computer program — attempting to automatically set reasonable tick marks, grids, and labels — you can appreciate that this is a non-trivial problem. [Dylan] tackled things from the bottom up, developing several utility functions that work in concert to iteratively build up each scale. One advantage of this approach, he says, is that you can quite easily build almost any scale you want. We’re going to take his word on that, because the project is not easily accessible to the average programmer. As [Dylan] notes:

At the moment it’s still a library w/ no documentation, and written in a relatively obscure language called Haskell, so it’s really only for the particularly determined.

The project is published on his GitHub repository, and sample scales and demo program are available. Without knowledge of obscure languages and being only mildly determined, one can at least generate some sample scales — just downloading the Haskell environment, a few dependencies, and clone [Dylan]’s repository. The output is an SVG file which can be scaled to any desired size. In this follow-up Reddit post he discusses the fabrication techniques used for the acrylic circular slide rule shown in the lead photo.

It’s always been possible to make your own slide rules using pre-generated artwork — for example, the Slide Rule Museum website has a slew of various scales available in graphic format. But if you want to make a custom scale, or make one of that’s meters long, check out [Dylan]’s project and give it a whirl. For another take on making slide rules, check out this project that we covered last year.

Purely Functional Selfies: Thermal Printer Speaks Haskell

[Dan] recently got a cheap POS thermal printer to chooch remotely over ESP32. Having conquered that project, he decided to see what else he could get the printer to do. Why not use it to print pictures? Sure, it’s been done, but not with Haskell. And yeah, the pictures will be grainy and weird-ish and limited to black and white, but hey, we love black and white around here as much as the idea of doing something simply because you can.

In the first project, [Dan] had to figure out how to talk to the printer since the RS422 cable it came with didn’t seem to work. He bought a TTL-to-RS485 adapter, but then realized he could use TTL directly and wired up a ESP32/OLED dev board to it. During the course of turning it into a photo booth, he had to switch to a bigger screen with a better refresh rate.

Unfortunately, [Dan] was unable to use Haskell by itself. He blames this on the cobwebs in the Haskell ecosystem, something that isn’t a problem for languages like Python that celebrate wide usage and support. [Dan] wrote a Python script that handles image capturing, display, and listening for touch activity on the screen, but Haskell ultimately controls the printer. Check out [Dan]’s demo after the break.

This project may have been trying at times, but at least [Dan] didn’t have to give it a brain transplant to get it to do what he wanted.

Continue reading “Purely Functional Selfies: Thermal Printer Speaks Haskell”

ImplicitCAD: Programmatic CAD Built With 3D Printing In Mind

Cornerstone of many useful things: This Prusa i3 part was modeled in OpenSCAD.

Programmatic CAD, in particular the OpenSCAD language and IDE, has accompanied the maker movement for a while now. After its introduction in 2009, it quickly found its way into the 3D printing toolbox of many makers and eventually became what could be called an Industry Standard among open hardware labs, makerspaces and tinkerers. The Prusa i3, one of the most popular DIY 3D printers, was designed in OpenSCAD, and even Makerbot, the company that sold 100.000 3D printers, uses the language for its “Customizer” – an online tool that allows users to customize 3D printable models with minimal effort.

OpenSCAD is indeed a wonderful tool, and we have been using it a lot. We have become used to its quirks and accepted working with polygon mesh approximations of the models we are trying to design. We have made our peace with excessive rendering times, scripting workarounds and the pain of creating fillets, and we have learned to keep our aesthetic expectations low. We are happy with the fact that there is a way to programmatically create and share virtually any object, but sometimes we wish there was a better way in the open source world. Hint: there is.

Continue reading “ImplicitCAD: Programmatic CAD Built With 3D Printing In Mind”

SpacewΛr Comes To Life From Bonus Formlabs Printer Parts

What might you do with a few extra stereolithographic 3D printer parts? Why not make a galvo display and resurrect a couple of classic vector graphic games of yore? That’s exactly what [Matt] did. With a few extra Formlabs components and a Haskell implementation of Spacewar, [Matt] can kick back and blast his extraterrestrial foes on the surface of his Formlabs cover.

[Matt’s] source code drives the Form 2 controller board to output laser graphics on the surface of a Form 1 case. These parts might be a commodity for this Formlabs Engineer, but the output is nothing short of spectacular, given the game and USB drivers were put together from scratch. In case you want to give the Haskell source code a try, [Matt’s] kindly included an alternative software-only display using OpenGL.

Unless you’ve just upgraded from Form 1 to Form 2, odds are pretty low that you can pull this one off without breaking either your printer or your wallet. Fortunately, [Alvaro] has paved the way with a stellar galvanometer display that began as a few parts from eBay. At last! Once our Formlab printer warranties expire, we’ll know where to start looking for parts for that mosquito killer we needed.

Continue reading “SpacewΛr Comes To Life From Bonus Formlabs Printer Parts”