Idris, a dependent typed functional programming language: install and run on OS X Mavericks

I got rid of the (now deprecated) cabal-dev, updated to the latest version of cabal and thought of installing idris on my machine.  I immediately hit a problem, it won’t install. I get the following error message (log cut down):

$ cabal install idris
Resolving dependencies...
Configuring annotated-wl-pprint-0.5.3...
Building annotated-wl-pprint-0.5.3...
Preprocessing library annotated-wl-pprint-0.5.3...
Registering trifecta-1.5...
Installed trifecta-1.5
cabal: Error: some packages failed to install:
idris- depends on language-java-0.2.6 which failed to install.
language-java-0.2.6 failed during the configure step. The exception was:
ExitFailure 1

So, it’s logical to try and install ‘language-java-0.2.6′. I tried that:

$ cabal install language-java-0.2.6
Resolving dependencies...
Configuring language-java-0.2.6...
cabal: The program 'alex' version >=2.3 is required but it could not be found.
Failed to install language-java-0.2.6
cabal: Error: some packages failed to install:
language-java-0.2.6 failed during the configure step. The exception was:
ExitFailure 1

And that fails too. It turns out I could install the package ‘alex’ manually. So I run this:

$ cabal install alex
Resolving dependencies...
Configuring random-
Building random-
Linking dist/dist-sandbox-c9c9694f/build/alex/alex ...
Installing executable(s) in
Installed alex-3.1.3

That worked. I can now attempt to install Idris:

$ cabal install idris
Resolving dependencies...
Configuring language-java-0.2.6...
Building language-java-0.2.6...
Preprocessing library language-java-0.2.6...
Registering idris-
Installed idris-

Succes. Phew! I am now ready to start using Idris:

$ idris
bash: idris: command not found

Oops! It’s not in the search path, and it’s not obvious where it’s gone. That’s easy, prior to all this I had installed and initialised a cabal sandbox.  So it’s gone in the sandbox, which isn’t in my search path. I went for a sandbox approach because I wanted to isolate my installation of snap and yesod from this Idris playground.

To preserve my sandbox concept, I am going to use an alias to Idris:

$ alias idris="/Volumes/MacintoshHD/usrlocal/bin/.cabal-sandbox/bin/idris"

I typically add such alias to my ~/.bash_profile so that it’s always available.

$ idris
 ____ __ _
 / _/___/ /____(_)____
 / // __ / ___/ / ___/ Version
 _/ // /_/ / / / (__ )
 /___/\__,_/_/ /_/____/ Type :?  for help
Idris is free software with ABSOLUTELY NO WARRANTY.
For details type :warranty.
Idris >

And that’s it, I now have Idris available and I can plough on. Ironically, for a language that promises to bring you dependent typed programming, the infrastructure dependency management isn’t stellar. That remains a weak point for me for all things Haskell.

Post Scriptum

  1. This is part of an exploratory journey into dependent types, an exciting concept in computer programming that I wish to use for production code in the near future. To get a glimpse of what this means, read this nice blog post, which, by the way, I think of as a model for introducing advanced programming concepts.
  2. Idris is built on top of Haskell, of which I have a recent version running on my machine. So if you’ve never had any of that kind of stuff on your machine, your mileage might be considerably longer than what I’ve shown here.

Who is set to benefit from the introduction of Swift programming language

One of my first reactions to Swift was the following:

In this post I elaborate a little more on the reasons that I held this belief, that everybody wins.

  • Apple, obviously: legions of developers who might have been put off by Objective-C will now give a second look and many are likely to write code for Apple platforms.
  • Groovy, Scala, Objective Caml programmer: programmers experienced with these languages can now leverage their skills to build solutions for the Apple platform without having to learn another language. Their main hurdle would be  to get acquainted with iOS and OSX platform concepts and building blocks.
  • Scala ecosystem: the introduction of Swift might have the side effect of actually making some people understand Scala better and quicker, this because  it shares many concepts with Scala but has a more readable syntax
  • A converse effect of the above bullet point: Apple developers who make the jump to Swift, would also realise the many benefits of functional programming and adopt languages like Groovy, Scala or Erlang.

Folks looking for new opportunities should find plenty. From a business opportunity perspective, here are some potentially profitable developments:

  • Groovy backend for Clang and LLVM: this could make it possible to write native iOS and OSX code in Groovy. People used to writing web only code would suddenly be able to port their solutions to the Apple platform.
  • Cross Training Developers: this could be the best time for Groovy or Scala training organisations to tap into the masses of iOS and OSX developers scrambling to learn functional programming. Why leave that money on the table?
  • Apple and Pivotal work together: this is a bit tangential, but if Apple were interested in expanding their Cloud clout, this is a good way to do that because they suddenly would be able to target the data centre too! Just buy Pivotal and leapfrog both Microsoft and Google in one fell swoop!

I don’t see yet how Swift could benefit either Microsoft or Google ecosystems. If anything, this could be a blow to those ecosystems as Apple is suddenly more attractive to a rising generation of developers converting to functional programming.

Swift, a general purpose programming language for a specific platform

Apple announced a new programming language. The inevitable reactions poured in, Apple lovers mostly rejoiced, Apple haters pounded on. Some complained the fact that it was not open source. Here are some thoughts from an observing angle.

A new programming language that launches in 2014 would aim to attract the masses and actually solve problems. If not then nobody would pay attention, regardless of their affinities. There’s been a lot of learning compounded in the software engineering discipline over the years, it would be foolish to sidestep all that and try to bring up something new. These learnings can be found in the existing languages, C#, OCaml, Erlang, Groovy, Scala, Rust, Go, Lua, and many others I might not even be familiar with. So in this context, if you were in any vendor’s shoes, you would need to embrace what’s available and bring it closer to your environment. That’s what Apple has done. 

Concurrency and parallelism

It is surprising that Swift does not seem to address concurrency and parallelism the way Erlang for example does, at least not in a visible way so far. It seems they didn’t want to ‘copy’ much from Erlang in fact. One could speculate what Apple’s rationales might be. My immediate thought, when I saw that omission, was that perhaps that would have pushed the enveloppe too far for the current generation of Apple developers. If that were included, a-la-Erlang for example, quite likely the first batch of applications delivered with Swift could be utter disasters and permanently cripple the uptake of the language. Apple would have to first create a solid infrastructure for such parallelism and concurrency constructs. That is the most important reason I can think of for leaving out such paradigms.

Another rationale to consider is the fact that unpredictability doesn’t marry well with user interface behaviour. Parallelism and concurrency are first and foremost systems concerns, more at home with a systems programming language. Apple is heavily focused on the user experience, and much less on system experience (TM). This makes me believe that Apple intentionally decided that Swift would not be a systems programming language. At least not now.


Swift appears to be, at least from one vendor’s perspective, a vindication that verbose programming languages don’t make developers productive in this day and age. Also, letting people make simple silly preventable mistakes is not a profitable business. Every time you looked at Objective-C source code, after any amount of time with Clojure, Groovy, Lua, Erlang or OCaml, to name a few, you were left wondering why such status quo persisted. Apple gave their answer today. But they waited a long time for that. Microsoft with C# and particularly F# have long been delivering the goods in that department. Google with GO have been forging ahead and registering tremendous success. Marrying the best aspects of functional programming with sequential and object-oriented programming, deliver the most benefits to users at the moment. With Microsoft, Google, Apple, Mozilla on board, it would be hard to argue that functional programming has become mainstream. The early adopters should rightly feel vindicated, somehow.

Update: A pointer to the reference web site was missing, for those who might not be Apple developers. There is no point in including ‘hello world’ or other trivial sample code here. Swift web site is:

Martin Odersky on the Simple Parts of Scala

In these slides, Martin sums up perfectly the challenges facing Scala adoption in the wider community: ‘extremists’ at each end of the OO-FP divide can be prompt to come out with their ‘pitch fork’s.
I’ve always perceived Martin as a software anthropologist who’d examine long and hard where learning opportunities might be, then come up with applications where most people would get the most benefits. This is just like Anders Hejlsbeg, or Rick Hickey. What you see is that these people bring tremendous value to the software development practice, there’s much to learn in closely listening to what they have to say.

Another way I found useful to look at Scala’s embrace of both OO and FP goes like this:

  • OO provides the structural facilities, the scaffolding amenities, the brick layering capability if you wish. This is how you eventually render your product. You want to be able to tear these apart as you wish, throw parts away as you see fit. A building must obey some basic laws of physics, hygiene and citizenry to be acceptable for any housing purposes.
  • FP provides the means for generalising behaviours that one wish to share and repeatedly reuse. You want predictability, stability and control here. This would be like being able to re-arrange your whole house such that bedroom, the kitchen, the living area, the computer corner or the dining area could be all be shuffled around in an unlimited configuration without having to rebuild the whole house – this is unrealistic in real-life, but we’re talking about software here.

By combining the two aspects, you get more ‘bangs for the bucks’ as they say. With my simplistic analogies, FP would be the content of your house, and OO would be the building frame. If you do it well, you can take your house content anywhere with you, but you usually discard the building frame or leave it behind.

There is no useful reason to be dogmatic about OO vs. FP. If someone doesn’t see the benefits of either then they should just pick what works for them, or avoid Scala. Coming from Java development background, or facing with a future with Java, Scala is a great platform to build sustainable solutions on.

Martin’s Slides – warning, Slideshare might require Flash – not my wish though ;-( :

Macaw is just what I wanted

I get inspired when I can visually tinker with experience design. This is the reason that got my attenion and I adopted it almost immediately.

Macaw user interfaceblank canvas in Macaw

I hailed Twitter Bootstrap when it was launched. It helped me and many others  with UI prototype work. Some seemed to prefer deploying Bootstrap default experience with little change. I don’t like that much. I would often customise the look & feel to make it a bit proprietary. Over time I came to realise that I didn’t particularly enjoy tweaking and tuning the myriad features exposed through the LESS assets. There is nothing wrong or limited with Bootstrap per se. Web browser development tools are also a good help for quickly trying out UI ideas. There are many online sites such as codepen that help you experiment with snippets and small features. These are all fine but, I just wasn’t getting inspired by any of it. What these tools lacked – that would get me excited – was the ability to just draw my idea of an entire page as I envision it, tinker only with the drawing, and then immediately get the code behind without resorting to any extra artifices. There is an emerging bunch of tools that allow you do that in a cost effective manner.

I discovered that my way of tinkering with web design worked better if I could do it visually. As I examine visual elements I get more ideas and I can iterate quicker. Going back and forth to the LESS source files and tuning design was too slow to entice me. I am not a designer by education so I make lots and lots of tweaking before I like something. As a kid I used to love drawing things. I would typically start by drawing a line or some randomly curved shape, then as I added to that some kind of shape would start to emerge and I would finalise my drawing that way. If I ended up drawing a horse or a house that was usually not even in my mind when I started. That was my way of playing with pen and pencil. It seems that is also how I can enjoy doing UI work.

For a long time I relied on Omnigraffle, not really a web design tool, and Pixelmator, also not a real UI web design tool. I’ve used Adobe FireWorks on and off for years. FireWorks is a nice tool but it never got me excited much. It seemed that I couldn’t find any product out there that I would want to stick to. That changed recently.

There’s a new product that allows you to visually design what you want, then get a baseline html and css code that embodies that. It’s called Macaw. I saw a brief video announcing its features and immediately decided to buy a license when it shipped. I got a copy at the beginning of this month, started using it, and it felt right away that this was how I always wanted to work with web design.

Aside from the immediate feedback, one benefit I particularly appreciate with Macaw is that the authoring assistants are intuitive and help you just the right way. As a non-negligeable bonus it generates a minimal base code that can be directly fed into an application design. Here are two radically different design I made with it.

macaw - design prototyping examplemacaw – design prototyping example
Web UI Prototyping with MacawWeb UI Prototyping with Macaw

I create these artefacts just like I would in Omnigraffle, however the whole experience of manipulating the elements fits perfectly with the job: desiging a web front-end. Once done, the code that Macaw generates is clean and minimal, it does link to jQuery though. So, I could just take the code I get from this and embed it in the application code. This approach is more to the point, and more efficient than say using a free html template downloaded from the web.

macaw generated cssmacaw generated css
macaw generated source filesmacaw generated source files

Before Macaw I tried several products of which many are online solutions. I won’t list them since this isn’t really a posting on product comparison. While lots of nice experiences are available I was often disappointed with the code that got generated. The problem I expect to solve with these tools is to get started with a clean slate and be able to repurpose code with minimal effort. This means that I didn’t want any dependencies in the code and that seemed almost impossible to achieve. For this reason I couldn’t settle for anything in particular and kept on to a traditional model where the UI design assets were fairly remote from the code produced to implement it. I don’t need to do that anymore, I can rely on Macaw to visually tinker with prototype designs.

Of course when it comes to serious web crafting like making animations or complex interactions Macaw wouldn’t fit the bill. Webflow for example seems to be another nice one, particularly suited to animation rich UIs. The produced code embeds relatively proprietary JavaScript code. And the business model seemed to be favourable to repeat uses or even hosted solutions. For my particular needs I saw these as compromises I didn’t really want. And honestly I would just hire a professional designer if the experience is complex or that it needs to be very sophisticated. I am an IS&T architect who believe in all-round craftsmanship. I want to deliver the whole solution. If it needs to look spiffy and flashy then I call out to professional designers.

Having used the product for a little while now, I am convinced that Macaw is the tool that I was missing so far. I can now deliver complete end-to-end experiences to clients with the tools that I am comfortable with.

Musings on Technology and the society