[Haskell-cafe] wxHaskell: convenience functions

David Roundy droundy at abridgegame.org
Fri Sep 16 14:19:05 EDT 2005


On Fri, Sep 16, 2005 at 06:30:54PM +0100, Mark Carter wrote:
> Actually, I can see how my requirement of not wanting to pass in cbEdit 
> might not be so good. From an FP point of view, that's just asking for 
> trouble. A better solution would appear to be to put the cbEdit in as a 
> parameter, and just face the fact that all callers will be required to 
> pass an extra parameter.

It depends on where you want this convenience function to be visible.  You
could define

mainFrame = do
  ...
  cbEdit <- checkBox p1 [text := "Ed...
  let isEditing = get cbEdit checked
  ...

and you're perfectly fine.  The catch is that isEditing is now only visible
in this scope.  You could pass isEditing to another function without
causing any trouble.  It might be cleaner than passing cbEdit around (for
example, if the mechanism by which the "isEditing" state is stored ever
changes).
-- 
David Roundy


More information about the Haskell-Cafe mailing list