On Tue, 16 Sep 2003 01:52:03 -0700 Ashley Yakeley <[EMAIL PROTECTED]> wrote:
> In article <[EMAIL PROTECTED]>, > "Yu Di" <[EMAIL PROTECTED]> wrote: Replying to both: > > Hi, I want to create an arrow which is essentially > > > > data MyArrow a b = MyArrow ((String, a) -> (String,b)) > > I don't think this type is an arrow. For a "product arrow", i.e. an > instance of Hughes' "Arrow" class with "first" defined, you can define > this: Oh, it's definitely an arrow. > > i.e. there is an "information" asscioated with each piece of data > > (represented by the string), So make a data type that sticks together something and it's information. > > and I want to pass it around. What's wrong with the support Haskell already has for passing around things? Why do you think you need an arrow? >From how you read the meaning of the MyArrow type, you are apparently misunderstanding what arrows are. Arrows generalize functions. As such things of arrow type are intuitively transformers and the arrow framework standardizes how to stick transformations together to make a larger transformation. The things in an arrow's representation are what's required for the implementations of the transformations. Therefore, things in an arrows representation are, in a sense, "owned" by the arrow computation. This is evidenced by a) arrows have a fully polymorphic type, they place no restrictions on their input; within the computation, the String in MyArrow is not even visible let alone required to be provided, and b) the above arrow is the State arrow specialized to Strings. The String is the state and is owned by the computation. You are having trouble defining 'first' as you'd like because what you want is to duplicate the state of the computation. -The- (there is only one at any time) String being passed around isn't associated with the objects. >From the sounds of it you simply want a combinator library that operates on some decorated data. A monad or arrow may be useful to support that, e.g. the environment monad, but a monad/arrow isn't that. You haven't really given much detail to what you're ultimately trying to achieve so I can't really provide much advice. _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell