Category Archives: Functional Programming

Infix Order Reversal

In Haskell, given any function with two arguments (curried) we can choose to use it infix position. The syntax for this depends on how we name the function; if we name the function in the form (s) then s is the infix form of the function, and otherwise an arbitrary function f can be converted to infix form by wrapping in backticks, as in `f`.

In either case, the infix form of the function expects the arguments in a certain order, and the order used in Haskell is:

(s) x y := x s y

I think it would be more natural if the order was the other way around, so:

(s) x y := y s x Continue reading

Posted in Computer Science, Functional Programming, Linguistics | 3 Comments

Anonymous Algebraic Data Types

In functional programming, there is a nice symmetry between types and values. While we often think of types and values as playing different roles – the types as being the ‘objects’ and the values as being the ‘arrows’ (or the inhabitants of types) in the category of types (Hask) – we can also look at types as ‘values’ themselves, of an object called ‘Type’ (often denoted ‘*’), in a higher level category. Continue reading

Posted in Category Theory, Computer Science, Functional Programming | Leave a comment

Grammar is like a Type System

In an analogy between natural language and programming language, grammar can be compared to a type system, which provides a great way to learn about one if you know about the other1. Continue reading

Posted in Category Theory, Functional Programming, Linguistics | Leave a comment