Haskell Sectioning#


Infix operators 1 by definition have to take two arguments, one on the left, and one on the right. We can partially apply this operator to either the left hand side or the right hand side operand first. We call this sectioning.

With commutative functions, it doesn’t matter which argument is applied first, but it makes all the difference with non-commutative functions.

Intro text!

What is the answer to this question‽

This is the answer:

$ git log
$ man tree

This is the text that follows the answer 😄

And this ends the entire QandA. May the source…

question 2#

Let’s see?

The code is:

#!/usr/bin/env bash
title='The Script'
printf 'The title is “%s”.\n'
echo -e $'the end\n'

Did it work?


Top level paragraph.

The End.

Basic Syntax#

When using sectioning with commutative functions, the side in which the operator is placed makes no difference because the order of the arguments does not change the result.

λ> (2+) 3
λ> (+2) 3

But when the function is not commutative, like (^), then it does change the results.

λ> (2^) 3
λ> (^2) 3

2 ^ 3 is 8, but 3 ^ 2 is 9.

λ> (1/) 2
λ> (/1) 2

Subtraction vs Negation#

To be continued 😅.



Remember that operators are functions, like any other function. We call them operators because they are defined with symbols like + or ^, etc. instead of alphabethic names like sum or `power.