If `do` is going away from being used as syntactic sugar to invoke functions with closure arguments, would it be a possibility to use it here?
-- Ziad On Wed, Dec 11, 2013 at 6:30 PM, Zack Corr <[email protected]> wrote: > It could certainly be implemented now, if it was restrictive to builtin > monad types - like `Option`. The real question would be what sort of syntax > fits in with Rust. Would there be a new bind operator, or have `bind` > instead of `let` in `do` blocks or just reuse let and have any option types > be automatically deconstructed in the binding (yuck). > > For example using the first, > > fn str_larger_than_five(str: ~str) { >> do { >> val <- from_str("1"); >> >> return val > 5; >> } >> } > > > or perhaps a bind keyword would nicer (my preference, but requires an > extra keyword): > > bind val = from_str("1"); > > return val > 5; > > > Of course the current usage of `do` would need to be removed in favour of > another keyword. > > > > On Thu, Dec 12, 2013 at 10:55 AM, Brendan Zabarauskas <[email protected] > > wrote: > >> Could `do` be implemented using sugar for now? Like, it expects such and >> such methods in order for it to work. We could put it behind a feature flag >> until we have HKT. >> >> ~Brendan >> >> On 12 Dec 2013, at 9:57 am, Zack Corr <[email protected]> wrote: >> >> > Yes, but Rust doesn't have HKT. I was suggesting it on this basis. I'd >> prefer `do` as well. >> > >> > >> > On Wed, Dec 11, 2013 at 5:25 PM, Ziad Hatahet <[email protected]> >> wrote: >> > On Tue, Dec 10, 2013 at 9:04 PM, Zack Corr <[email protected]> wrote: >> > I think the Monadic null operator (a.k.a. safe property access >> operator) would be pretty useful syntax sugar for mapping over option >> types, and certainly help with the whole "option vs fail" for error >> checking because it essentially allows monad-like functionality without >> actually having (first-class) monads. >> > >> > >> > I still think that having something like Haskell's `do`, or Scala's >> `for` is a better way to go about this. Especially that it generalizes over >> more than just `Option<T>`. >> > >> > -- >> > Ziad >> > >> > >> > _______________________________________________ >> > Rust-dev mailing list >> > [email protected] >> > https://mail.mozilla.org/listinfo/rust-dev >> >> > > _______________________________________________ > Rust-dev mailing list > [email protected] > https://mail.mozilla.org/listinfo/rust-dev > >
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
