Example 1. An abbreviated List
interface using Java
interface List<T> {
T get(int index);
int length();
List<T> reverse();
}
It can be said that any instance (list
) must satisfy
list.get(list.length() - 1) == list.reverse().get(0)
There are other laws that are implicit in this abbreviated interface.
All monad instances must satisfy three laws, but we won't go into them. Instead, just be aware of what we mean by the monad laws.