New function type Effect for use in foreach

The Function<A, Void> approach was awkward, as one had to return null. Introducing a new type Effect eliminates the need for returning nulls.