I'm involved in teaching mathematics to classes with requirements such as AS and A level Mathematics specification.

Class books normally provide examples of computer software applied to mathematics tasks, but they are normally based on software applications like mathlab, mathematica or derive.

Even when a real programming language is used, it is normally old fashoned language like Pascal. And this is really sad in my opinion.

Because, Haskell is famous for his feeling with mathematics, and because I'm interested in it as well, I'd like to ask whether Haskell is a good choice as extension exercise method for students of a first year university class. Typical subjects are functions, caclulus, limits, but also linear algebra for example.

I've intermediate knowledge experience in programming (c#, ruby, powershell, javascript, tex) and also have already approached functional programming with XSLT.

Answers will be upvoted responsibly. Verbose answers including also some basic examples of Haskell code applied to mathematics, such as linear algebra (e.g. vectorial space), polynomials, solving linear equations are much appreciated and targeted as the wanted one.

  • 3
    Check out this book: collegepublications.co.uk/computing/?00004
    – Fred Foo
    Jun 11, 2011 at 8:40
  • @larsmans: thanks. That's a good starting point indeed; I'm also interested in more practical mathematics, like differentiation, limits, integrals. Jun 11, 2011 at 8:48
  • I fail to see how Mathematica is not a real programming language. When I have math problems I very frequently use it first (well Octave), and then convert to another language. If the focus is on math then I see no reason why a specialized math language is not suitable. Jun 11, 2011 at 10:54
  • @edA: Mathematica != Octave! Octave is a Matlab clone. People who use both tell me Matlab/Octave is more geared to numerics (big arrays, FFTs etc) while Mathematica is better for symbolic manipulation. The nearest FOSS equivalent to Mathematica is probably Maxima (formerly Macsyma).
    – timday
    Jun 11, 2011 at 23:44
  • @timday, yes, I know Octave != Mathematica, but the code language is the same. I also use Maxima for symbolic manipulation. Jun 14, 2011 at 6:54

4 Answers 4


Haskell is growing in popularity among mathematicians. As one blogger put it:

"after my involving myself in the subject, one thing that stands out is the relatively low distance between thought expressed in my ordinary day-to-day mathematical discourse, and thought expressed in Haskell code."

So here's some collected views, that I feel says you can't go terribly wrong taking this approach.

enter image description here

enter image description here


  • 1
    Having read some of your links, I can't say I'm too convinced. Got any actually examples of someone sitting down for a Haskell session and working it like you can Mathematica/Maxima ?. Further, the "11 reasons" blog points out what a mess the standard library is from the point of view of a mathematician, and looking at the list of math packages I see a lot of numerics (e.g blas, fft) but not much in the way of symbolic manipulation/CAS. Having said that... both the books look really interesting!
    – timday
    Jun 11, 2011 at 23:58
  • Ye, some examples of actual math would be great (like lin. algebra matrix additions etc...) - to see how the actual syntax looks. I bet there is not even op-overloading... Nov 21, 2011 at 19:53
  • @drozzy: of course there's operator overloading, via type classes.
    – nomen
    Aug 25, 2014 at 19:56

While I'm a great fan of Haskell for teaching mathematics, it might not be appropriate for all topics at AS/A level.

You'll have no problem with teaching the idea of a function, and linear algebra can be nice in Haskell. Linear algebra is often taught in a very imperative way with in-place updates of arrays. It can all be translated to Haskell, but it might require a little bit of thinking differently.

But it gets tricky when you want to talk about limits and calculus. I've had great success doing calculus in Haskell with a non-conventional approach. But that might not be a great idea when teaching to a fixed syllabus. Alternatively you can play with symbolic differentiation but then you'll start having to build datatypes for expressions which may be tricky for A/AS level. It's not a lot of code to get started, barely a couple of lines, but it might be scary for students. Unlike Derive and Mathematica, you don't get symbolic expressions for free.

Basic combinatorics is easy to explore with the List monad. This might be useful for teaching probability theory.

Haskell is fine for numerical applications of the sort that might appear at A/AS level, eg. applying Simpson's rule or investigating sample means and variances.

Do you do elementary group theory? That's easy to code up and play with in Haskell.

Overall, if you take care around limits I suspect that it's straightforward to do much of A/AS level mathematics with Haskell.


I'm not sure if Haskell is a good choice. Sure, it has a very "mathematical feeling", deals with infinite structures etc. But you can appreciate these features only if you already know the language. Learning Haskell in order to learn mathematics stacks one hard task on top of another. And learning Haskell is hard, even if you already know programming. So it really depends if your audience is bright and curious enough, else you lose half of them because of mathematics, and the other half due to Haskell.

  • Learning Haskell is easy if you already know the math behind it. Very easy.
    – nomen
    Aug 24, 2014 at 0:55
  • @nomen May be, but this wasn't the question.
    – Landei
    Aug 25, 2014 at 15:05
  • I am saying that being hard to learn to someone with a programming background does not disqualify it.
    – nomen
    Aug 25, 2014 at 19:52

No computer language will teach you mathematics. Only mathematics will teach you mathematics. That is: pen and paper approach (or chalk and blackboard), axioms, theorems and proofs. This is mathematics. No matter how sexy the language is, a program written in it is not mathematics, it's just an application of mathematics. To apply something, you need to learn it first.

  • 1
    I don't think anyone expects a programming language to literally teach mathematics and I don't think the original question asked for a programming language to literally teach mathematics. They want something that can be used for some exercises to help with the teaching of mathematics.
    – user27539
    Jun 13, 2011 at 19:49
  • Chalk, blackboard...
    – quant_dev
    Jun 13, 2011 at 21:08
  • Disagree. A language is just a means of expression. Chalk, pencil, computer: just tools used to express mathematics concretely. Languages are just tools to express mathematics abstractly. Compare the Haskell-Curry Isomorphism theorem (a program is a proof in a constructive logic)
    – nomen
    Aug 25, 2014 at 19:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.