
|> > data Ref cx t |> > = Ref |> > { |> > select :: cx -> t |> > , update :: (t -> t) -> cx -> cx |> > } |> |> A Ref is a bit like a typed and composable incarnation of apfelmus's |> indices, or a wrapper around Tillmann's change* functions, containing |> not only a setter but also the accompanying getter. | |That's a neat idiom. I wonder how far one could usefully generalize it. you might find Koji Kagawa's papers interesting: http://guppy.eng.kagawa-u.ac.jp/~kagawa/publication/index-e.html in particular Mutable Data Structures and Composable References in a Pure Functional Language , Koji Kagawa, In SIPL '95: State in Programming Languages, San Francisco, USA, January 1995. Compositional References for Stateful Functional Programming, Koji Kagawa, ICFP 1997, June 1997, Amsterdam, the Netherlands. claus