Value space transformations

I just found myself writing some code like this: processFoo processBar = toFoo . processBar . fromFoo where fromFoo foo = ... toFoo bar = ... and noticed some similarity in style to certain kinds of transformation used in linear algebra, such as for diagonalization: D = T M inv(T) This got me to wondering if this is a common pattern in functional programming. There seems to be some similarity, for example, with the way that Monads are sometimes used, where operations are "lifted" into (?) a Monad. So my questions are: (a) is there a common functional programming pattern that corresponds to vector space transformations so that a function defined over one space can be used in another, and (b) if so, are there any not-too-heavy papers or articles discussing this pattern? #g ------------ Graham Klyne For email: http://www.ninebynine.org/#Contact

So my questions are: (a) is there a common functional programming pattern that corresponds to vector space transformations so that a function defined over one space can be used in another, and (b) if so, are there any not-too-heavy papers or articles discussing this pattern?
Many times when you have a pair of functions: f : S -> T g : T -> S you find that they form a projection-embedding pair: f . g = id g . f <= id where the <= ordering typically indicates loss of information. For example, read and show are related this way with the read function losing information about whitespace, comments, etc. Various kinds of lookup tables and set representations (linear lists, arrays, binary trees, etc.) are also related in this way. A useful generalization is an "adjunction" or "galois connection". Section 3 of this paper has a concise definition and, more usefully, helps give you some intuition about them. A reflection on call-by-value, Amr Sabry and Philip Wadler. http://www.research.avayalabs.com/user/ wadler/topics/call-by-need.html#reflection Other people can probably suggest better papers. Hope this helps, -- Alastair Reid www.haskell-consulting.com
participants (2)
-
Alastair Reid
-
Graham Klyne