I have tranformation functions of the type:

> type transformer= a->Maybe b

I have defined the operator ++> as

> mbX ++> f = maybe Nothing f mbX

So that I can represent a set of transformations on an object that
either succeed or fail. e.g.

> validObject =         lookup "foo" ++>    -- lookup foo in hashtable
>                       (decrypt key) ++> -- decrypt string if possible
>                       (acceptIfNormal.read) --check sanity of
>                                             --deserialized objet

Note that each action could result in Nothing and return Nothing or
it returns a value that is passed on to the next command.

I have two questions here:

1. What is the standard name for the ++> opertor.
Because it is very similar to >>= and the this pattern must be very
common, I assume that there is a more standard name for the ++> operator
that is in a library or prelude.  (I don't want to add obscure opertors
that know one recognizes to my code)

2. Initially, I defined ++> as

> x ++> f = x ++ f x

But that seemed to require that x and (f x) be of the same type.
Would existential types allow x and (f x) to be of different type?
How would you define ++ for type Maybe to accomplish that?

-Alex-


___________________________________________________________________
S. Alexander Jacobson                   i2x Media  
1-212-697-0184 voice                    1-212-697-1427 fax


Reply via email to