I generally use fun unless there is a good reason to use function. You can see this in the code you posted where the fun declaration takes 3 arguments and the function declaration does pattern matching on it's input