I’ve been using NixOS for over 10 years now. I run NixOS on all of my servers, desktops and laptops - but also weird things like game consoles, e-book readers and mobile phones. Since I have a reasonable amount of personal Nix code, it’s important I have continuous integration configured for my various systems. So I run a few Hydra servers with that goal. Hydra supports periodically fetching…
I live near the Launceston & North East Railway . I’ve always wanted to see the railway used. I got involved with the group after reading an article that mentioned the idea of an electric train . I’ve been interested in electric vehicles for many years now, and I even own the former Flinders Island Clean Green Airport Shuttle . This 2011 Mitsubishi i-MiEV is possibly the first modern mass-produced…
Epic Games released an initial public implementation of the Verse programming language. Verse has been designed by some people who really know what they’re doing: Lennart Augustsson Joachim Breitner Koen Claessen Ranjit Jhala Simon Peyton Jones Olin Shivers Tim Sweeney It’s amazing to see a CEO help design a programming language but Tim Sweeney has been advocating for functional programming in…
For the past few years I’ve been the most senior developer on my teams in Atlassian, in both position (Principal Engineer) and time (almost 9 years ) - this means I usually take on the responsibility of managing our software architecture. Architecture is the relationships between systems, which can be fairly tricky to talk about. Probably the best form of communication is a diagram, with boxes…
I've moved to Bengaluru to teach functional programming (and other things) to my team in Atlassian. Our project is a large Scala application. Scala enables functional programming, but it is only made possible, not easy. Instead of using Scala to teach functional programming, we should use something easier. For a few years I've been using Haskell to teach functional programming. Sometimes I hear…
I am convinced the way I program is broken. At work I write a lot of Scala, Haskell and Nix. Almost all of the functions I write are representing the problem I'm solving; not many functions have anything to do with the language itself. Sometimes I have to consider or concede to the language or runtime. I should be able to write programs by abstracting over language, precisely up to the…
I wrote this post a couple of years ago for a team at work. I just found it again, so here it is: We gain two things by making a type more polymorphic: We can use it in more places We can reason about what it can't do, often to the point that we can count that there's only X possible implementations of a type signature (a topic called parametricity, covered pretty well elsewhere) We should strive…
Fred Brooks published a paper titled " No Silver Bullet – Essence and Accident in Software Engineering " in 1986. This paper is often cited for a few different reasons, one of the main references goes something like: There's no such thing as a silver bullet... Which is a reference to the following paragraph: There is no single development, in either technology or in management technique, that by…
I'm going to write some posts about the phrase "there's no such thing as a silver bullet" and why I think it's not a very useful thing to say. I'll write a post about the original paper but first I want to write about an interpretation I've seen: Everything has trade-offs. I can go through things that I use and come up with trade-offs: Space vs time Emacs vs Vim Git vs Mercurial JSON vs YAML…
Eta is a fork of GHC which provides Haskell with a JVM backend. I've been working on it recently and did a presentation on it at LambdaJam. One of the questions from my presentation was "since Eta takes Haskell and produces JVM code, can I use it to write Android apps?" I had a feeling Eta was close to being able to. It turns out it's not just close, it's pretty easy! Let's write some code which…
I have been using NixOS since the end of 2014, both at home and for work. One thing which has been a bit annoying over these years is when I have to execute a downloaded binary. Atlassian has some internal tools which are written in things like Go. I package these binaries and install them into my user profile but sometimes it can be annoying to spend the 5 minutes packaging something when you…
The following has never happened to me but I often hear stories. You go into work and discover that a coworker isn't happy with some code you wrote because they don't understand it. They go to your manager and tell them that you're being a problem by writing code they don't understand. Your manager, being very skilled in conflict resolution, makes a technical decision to avoid whatever tool you…
There’s an argument going on in the DynamoDB community right now. Should you write code on line #45 or not. I strongly believe that line #45 should be left empty. Here’s why. Line 45 is below the fold Terminals are 24 lines high by default. If you write any code on line #45 then programmers won’t immediately notice it. If you leave line #45 empty then the programmer won’t miss out on anything. We…
2024-12-29: This post is from a former employer’s blog. I’m particularly proud of this contribution to PureScript, and the blog is no longer around, so here is the post. I work on the SlamData front-end, which is completely written in PureScript . I work with 2 other PureScript engineers and we’ve noticed some slow compilation while working on the UI. If we have to modify one of the core modules,…
I’ve been thinking a lot about minimal QuickCheck properties required for asserting correctness of functions. I was inspired by Daniel Peeble’s proof of List reverse’s core properties and Matthew Brecknells’s minimisation . I’ve been taking these ideas and playing around with them in Idris. I have proofs that the following functions only need 2 properties to checked: List reverse Natural number…
I am not using node.js to generate this blog. I am now using Idris ! I’ve chucked the source up on GitHub . I wanted to be the first to use a dependently typed compiler to generate my blog. From what I can tell, I was beat by just a couple of weeks . Sadly, there are no interesting uses of dependent types used yet but one interesting thing I worked on was using Nix to build Idris packages . I…
A while ago I blogged about using Agda to prove the parity of added numbers . I’ve recently been doing some work on Idris and wondered how easy it would be to translate my Agda proof to Idris. The original Agda code looked something like this: module EvenOdd where open import Data.Nat data Even : ℕ → Set where evenZero : Even 0 evenSuc : {n : ℕ} → Even n → Even (suc (suc n)) _e+e_ : {n m : ℕ} →…
I’ve been playing around with making a dependently typed language. It’s based upon Martin-Löf Type Theory (commonly just called Type Theory, TT). Turns out that implementing a dependent type system is a great way to learn how to use one! I had written code to translate from my toy languages’ terms into TT - but I wanted a compiler, so that I could execute it somewhere outside of the…
I was recently on a panel with some smart people discussing Rod Johnsons’ infamous “Scala 2018” keynote. Most agreed that we should start enforcing code standards. Sadly, the tools for doing that are a bit lacking. For a while I’ve had an idea on a flexible tool for writing lint rules over Scala code. I already had WartRemover which was a linter for things I considered bad. I decided to rewrite…
Almost 2 years ago I attempted to write an Agda proof that two odd numbers added together always result in an even number. I picked Agda up again yesterday to have a little play. I quickly wrote a HList, which used a list of types at the type level to represent the heterogeneity: data HList : List Set → Set1 where HCons : forall {x xs} → x → HList xs → HList (x ∷ xs) HNil : HList [] Really…
This is also a Gist for you to clone and use runhaskell on How do we add extra information to a tree? This has been called The AST Typing Problem . After being hit with this problem in Roy’s new type-inference engine, I tried figuring out how to represent the algorithm. I eventually realised that it looked like a comonadic operation. Turns out it’s been done before but I couldn’t find any complete…
I’ve been working on Roy’s new type system which uses a concept called row variables . I’ve also been thinking about TypeScript’s unsound variance issues with its implementation of structural subtyping. That lead to an interesting discussion on Twitter about row polymorphism compared to structural subtyping. Both are trying to type code like the following: let f x = x.a + x.b f {a: 1, b: 2, c:…
For a while now, I’ve wanted a way for people to watch how I work and let me know how I could improve both my techniques and my code. I mostly work in Emacs so being inside of a terminal works fine. At Precog we use tmux for pairing sessions. It works really great but I wanted to make it read-only for guests. I created a guest user on the VPS that brianmckenna.org is now hosted on. The guest user…
Promises are being debated in the JavaScript community. The most popular specification is Promises/A+ . It’s a fairly small specification, containing only a single function: then . The function is heavily overloaded which makes it quite complicated - way more than it has to be. I’ll try to show how category theory can give us a much simpler, more generalised and lawful API! A proper Promise/A+…
Validation is known as scalaz’ gateway drug. Validation has the following two states: Successful value Failure with a Semigroup of errors Semigroup sounds scary but it’s something that can be appended together. Think of a list, array or set. This allows multiple failures to be combined, where the errors are appended together. People love validation in scalaz because it allows nice, declarative…
Last night I took Neuman Vong’s and Mark Wotton’s Haskell Buildpack for Heroku and got it working! I’ve been able to deploy a simple Warp example and a in-development Yesod application. The steps are quite easy: yesod init cd yesod-buildpack-demo mv deploy/Procfile . git add -A git commit -m "Initial commit" heroku apps:create yesod-buildpack-demo --stack cedar --buildpack…
I’ve added a QuickCheck implementation to bilby.js . The existing JavaScript implementations: Make it hard to create generators Require a specific test runner bilby’s implementation fixes both problems. You can register generators using the multimethod environment: λ = require('bilby') .method('arb', strictEquals(Boolean), function(a, s) { return Math.random() < 0.5; }) .method('shrink',…
While working on Roy , I’ve been coming up with some ideas and experiments on how to improve JavaScript code. The most important is a safer form of ad-hoc polymorphism. Currently, JavaScript devs rely on duck typing and monkey patching to achieve polymorphism. My idea is to use an immutable multimethod environment, like so: var env = λ.environment() .method('length', λ.isArray, function(a) {…
This week I’ve been working on the new constraint-based type-system for Roy . I’ve been working on it for a few months but got a bit stuck recently with typing algebraic data type definitions. I think I properly implemented that and I’m up to pattern matching. I’m basing the work off Generalizing Hindley-Milner Type Inference Algorithms (PDF) - a way of achieving Hindley-Milner via constraints;…
This has been my second week at Precog . During my first week I wrote a patch for the gll-combinators project to fix a whitespace handling issue. The issue occurred when using the ^# ( mapWithTail ) combinator, which passes column and line information to a function: case class A(loc: LineStream, x: String) literal("daniel") ^# { (loc, x) => A(loc, x) } The symptom was that the RegexParser class…
This week had my first few days at Precog . It’s been awesome contributing to the Quirrel language and working with insanely smart people. Last night I found out about a project called Dripper . It’s basically a wrapper around stow which makes it easy to compile and link applications with predefined scripts. Think of it as a Homebrew-like interface to stow. I’ve always wanted to be able to take a…
On Wednesday I gave a talk at ScalaSyd about monad transformers. I tried to make it fairly introductory which is a bit tricky to do. There’s a much better talk on the subject by Jordan West. I’ve posted my slides up here . Some crazy news is coming up in the next few days.
This week I made OSXMonad use the internal XMonad StackSet data type to have its windows managed. This means that eventually ordinary XMonad Layouts will be able to work with OSXMonad. I’m getting close. I’ve been having some trouble with the XMonad configurations and I’m not able to run the code via GHCi.
This week I managed to get OSXMonad running as an XMonad library. That means you can write a ~/.xmonad/xmonad.hs file like so: import XMonad import OSXMonad.Core main = osxmonad defaultConfig And the xmonad command will launch OSXMonad to manage Cocoa windows using the default XMonad configuration. Hardly any XMonad features work except some layouts at the moment, but it’s still pretty cool to…
This weekend was AusHac . I worked on an OS X tiling window manager in Haskell. The idea was to get a prototype “shell” that can tile windows in a way suitable for XMonad . XMonad’s layout algorithms could then be taken and strapped into the shell. Sadly the XMonad.Layout module has a few dependencies on X11, so it’s not going to be as easy as I’d like. I couldn’t chuck in XMonad’s layout…
The idea in ad hoc polymorphism is to separate functions from data, in contrast to mutating prototypes or the data itself. We can of course just define a function that uses duck typing but that’s only if the data quacks the same. It also doesn’t allow open extension of the function implementation. Ad hoc polymorphism is very common in functional languages like Lisp and Haskell. I wrote a little…
This weekend I worked on a tiny demo for a browser-based game. The idea was to experiment with some JavaScript game engines. CraftyJS seemed the most complete for what I wanted to do. The demo has two running characters. One is controlled by repeatedly pressing the spacebar. The other just moves foward constantly: CraftyJS can output to canvas and DOM nodes. This example uses only DOM nodes (with…
I’ve started work on adding Foldable1 and Traverse1 to scalaz . Pretty similar to the semigroupoids package: http://hackage.haskell.org/packages/archive/semigroupoids/1.3.2.1/doc/html/Data-Semigroup-Foldable.html The idea is to move over the following from Foldable to Foldable1: foldMap1 foldr1 foldl1 maximum minimum Those functions will then be total and won’t need to return Option. Other methods…
I spent some time this weekend playing around with Akka . It took me a while to get it to work nicely with ScalaCheck and Specs2 . My first attempt was to make the test create a new Akka TestKit : def e1 = new TestKit(system) with Scope with ImplicitSender { within(1 second) { system.actorOf(Props(new Actor { def receive = { case x ⇒ sender ! x } })) ! "hallo" expectMsgType[String] must be equalTo…
This weekend I went to Sydney’s GovHack . My team decided to work on a new PhotoSearch for the National Archives of Australia . Our README does a pretty good job a describing what it is and does: The National Archives of Australia has amazing collection our countries vibrant history, with over 300,000 images collected from the past 200 years. Sadly the ability to search these images on the…
For the past month I’ve been working part-time on a small Yesod web application. The idea is to make daily blogging easy by asking a small question. There’s questions like: What are you grateful for? How did you celebrate your last birthday? What’s in your fridge today? You can try it out here . Hosting thanks to Heroku!
I’ve been working on a Yesod webapp over the past few weeks. I noticed that the skeleton contained a deploy/Procfile . I also know of a couple of developers that have managed to get Haskell running on Heroku. Heroku Cedar is the polyglot platform which allows you to push any binary that will run on their servers. I first tried using Ubuntu 12.04 to compile the binary. Bad mistake; Heroku uses…
I’ve rewritten Roy’s tests to be Jasmine specifications. Previously I had written my own test runner which didn’t work very well. The custom test runner only supported functional level tests; it just executed Roy files and compared that with expected output. I’ve now started writing finer grained tests. I’m really missing QuickCheck for this stuff - I might take a look at Crockford’s JSCheck . But…
I’ve started working on Source Map support for Roy as a 20% time project at Atlassian. At the moment it’s fairly limited. You can only set breakpoints at the top level of a Roy file. That means nested functions, do-blocks, definitions, etc, can’t be debugged. But anyway, it’s pretty exciting to see Roy code being stepped through:
I was at JSConf almost 2 weeks ago, where I gave a talk about Roy . I then went on holiday in San Francisco and met up with heaps of cool people. On the flight back I was able to make a CodeMirror2 mode for Roy . Then I added it to the Roy website : Another change (that I should have done a long time ago) is getting type errors to print out line numbers: This was also initial work to getting…
I’ve added support for compiling browser modules via the node.js CLI. You can now run: ./roy --browser examples/node_module.roy And you’ll get code just like the Roy compiler generates when running in the browser: (function() { console.log((structural.obj.x + structural.obj.y)); })(); I’ve also cleaned up the module implementation. They are no longer half-implemented as macros. This is mainly so I…