Sorry I just now pressed "send" by mistake when the letter was not finished yet. Please ignore my last mail. Thanks. Following is the correct version of my question.
----- Hi, I want to create an arrow which is essentially data MyArrow a b = MyArrow ((String, a) -> (String, b)) i.e. there is an "information" asscioated with each piece of data (represented by the string), and I want to pass it around. And often the arrow's processing logic will depend on the input information, therefore a monad-style data MyArrow a b = MyArrow (a -> (String, b)) will not work. Now I have a problem with the definition of "pure" and "first". At first, I declared pure f = MyArrow (\(s, x) -> (s, f x)) first (MyArrow f) = MyArrow (\(s, (x, y)) -> let (s', z) = f (s, x) in (s', (z, y))) this seems to work, but then I begin to have problems with the "data-plumbing" pure arrows, e.g. in pure (\x -> (x, x)) >>> first someArrow >>>> pure (\(_, x) -> x) Ideally, this arrow will preserve whatever information I put there for the input, but because "first someArrow" will change the WHOLE information associated with the pair of result, I can't find any way to let "pure (\(_, x)->x)" (which is an extremely generic function) retrieve the PART of information for the second piece in the pair tuple. I thought about this a lot, but it seems to me that the only way to solve this is to somehow make the information "lookupable" from the data itself, not "placed beside" the data, but how I can do that? And can there be some other solution to this? Thanks very much! Di, Yu 9.15 __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
