My wife has been put in charge of scheduling lectors and ministers at our church, so of course she needs a Haskell program to do the schedules for her! While I've been working on it, I wrote something that I thought was a pretty cool trick. 
<br><br>Each Mass requires a variety of different type and number of participants, so when defining the &quot;Mass&quot; data structure I put a function in which selects participants for that type of Mass from a given list:
<br><br>data MassTime = MassTime {<br>&nbsp; ...<br>&nbsp; selectParticipants :: (Participants -&gt; Maybe Participants), -- Picks participants for this mass<br>&nbsp; ... } <br><br>Each mass has particular requirements. Notice the &#39;selectParticipants&#39; function does not take a mass definition as an argument. 
<br><br>Here&#39;s the trick I thought was neat. When creating the MassTime value, I capture it in a closure and bind it to the selector function, as below:<br><br>&nbsp;makeMass :: Day -&gt; MassTime<br>&nbsp;makeMass day =<br>&nbsp;&nbsp;&nbsp; mass
<br>&nbsp; where<br>&nbsp;&nbsp;&nbsp; -- Use trick here to capture mass defined and pass to our selection function.<br>&nbsp;&nbsp;&nbsp; mass = MassTime ... (weekendMassSelector mass) ...<br><br>&#39;weekendMassSelector&#39; is defined elsewhere, and basically knows how to count up the right number of participants based on the mass definition given. It&#39;s signature is:
<br><br>&nbsp; weekendMassSelector :: MassTime -&gt; Participants -&gt; Maybe Participants<br><br>So weekendMassSelector gets the MassTime value it needs, before it is even constructed. Partial evaluation then gives a function with the (Participants -&gt; Maybe Participants) signature required by the data constructor. I love Haskell - this just seems too cool.
<br>&nbsp;<br>Since I really doubt this is something new - is this a technique that&#39;s commonly used? Does it have a name? It looks a lot like passing a &quot;this&quot; argument to a function - have I re-invented OOP encapsulation? :)
<br><br>Justin<br>