[Haskell-cafe] Re: I just don't get it (data structures and OO)

Stefan O'Rear stefanor at cox.net
Sun Jun 3 13:51:19 EDT 2007


(Sorry to break the thread, but mutt somehow managed to eat the message
I'm replying to...)

Arie Peterson:
> You could also use 'compositional functional references'. These are
> introduced in the paper "A Functional Programming Technique for Forms in
> Graphical User Interfaces" by Sander Evers, Peter Achten and Jan Kuper.
>
> === Introduction ===
>
> There are two things one typically wants to do when working with a
> substructure of some larger data structure: (1) extract the substructure;
> and (2) change the larger structure by acting on the substructure. A 'Ref
> cx t' encodes both of these functions (for a substructure of type 't' and
> larger structure (context) of type 'cx').
>
> > data Ref cx t
> >  = Ref
> >    {
> >      select :: cx -> t
> >    , update :: (t -> t) -> cx -> cx
> >    }
...
> I've written a template haskell function to derive Refs from a data                                                                                                                                               > structure definition (with record syntax): given

I've implemented this in Derive[1] in 12 minutes, counting the time
required to re-familiarize with the code.  The patch is at [2] and has
also been darcs sent.

[1] http://www-users.cs.york.ac.uk/~ndm/derive
[2] http://members.cox.net/stefanor/derive-Ref-patch

Stefan


More information about the Haskell-Cafe mailing list