Regarding Daniel Westheide's blog part 10, it is is given:
case class Email(
subject: String,
text: String,
sender: String,
recipient: String
type EmailFilter = Email => Boolean
val sentByOneOf: Set[String] => EmailFilter = senders => mail => senders.contains(email.sender)
By correspondence of left and right sides of the definition of sentByOneOf, its Set[String] arg is senders, while by the definition of EmailBuilder, EmailBuilder corresponds to email => senders.contains(email.sender)
REPL shows the form of sentByOne Of is:Set[String] => (Email => Boolean) = <function1>
It is a higher-order function because it returns a function.
Understanding all this is best achieved by using it. For example, given:val e1 = Email("hello1","text1","sender1","recipient1")
val e2 = Email("hello2","text2","sender2","recipient2")
val e3 = Email("hello3","text3","sender3","recipient3")
val e4 = Email("hello4","text4","sender4","recipient4")
val s = SetFilt("sender1","sender2","sender3")
val efilterA = sentByOneOf(s)
thenefilterA(e1) // returns true
efilterA(e2) // returns true
efilterA(e3) // returns true
efilterA(e4) // returns false
At a higher level of processing a mail filtering system would consist of a number of mail filters such as sentByOneOf() configured for particular groups of senders or recipients, etc.,
and which would filter streams of incoming and possibly outgoing email messages. Examples of mail filtering systems for unix/linux are MailFilter and procmail.