Posts for: #Haskell

Migrating a REST API from Javascript to Haskell

Background

For just over a year, I’ve been running the JTime project, which consists of a REST API, an Android app and a website, the latter two of which talk to the REST API. The JTime project allows me to see nearby prayer times. I don’t advertise it, as it is more of an educational project to try new technologies, and I just don’t want to be promoting it in case people think I’m clever for having made it (I don’t like showing off, and generally the people around me are non-programmers). So barely anyone uses it.

Read more

Thoughts on Haskell

Over the past few months, I have been learning haskell. It is truly an amazing language, unlike the heavyweight languages (Java, Python, C#), with a lot of innovative features in it. This is probably due to it being originally (although it still is) a research language, though it does seem very capable for use in production. Here are a few of my thoughts about it so far.

  • GHC, the standard compiler/interpreter, is awesome. The compiler times could be faster, but the executables it produces are very fast.
  • The language is very beautiful. To give an example: fibs = 0:1:(map (\n -> fibs!!n + fibs!!(n+1)) [0..]) is an infinite list of the Fibonacci numbers. It is not the fastest way of doing this (matrix exponentiation is really fast) but it is very good in terms of performance.
  • The level of support for higher order functions and currying is really good. In particular, I like the way function types are expressed, eg func :: Integer -> Integer -> String is a function that takes 2 numbers and returns a string. It can also be thought of (and used) as a function that takes one number and returns a new function, that takes one number and returns a string. This builtin currying allows for simplifying various problems in a beautiful way.
  • The type system is really powerful. Writing functions that work on classes of types is very straightforward, and type inference means that a lot of the time, you don’t need to write types. Although standard practice is to write out the types of functions, purely to help people reading the code. Often, you can just let ghc figure out what the type of a function is, and just copy paste it back into your code for documentation.
  • There are a lot of extensions built into GHC, and these extensions can be enabled on a file by file basis by adding flags at the top of the file.

I also have issues with haskell:

Read more