From: David T. <Dav...@un...> - 2008-05-21 21:17:29
|
On Mon, 2008-05-19 at 08:59 +0200, blue storm wrote: > > 2) For [Option.enum], it's not a big deal, just a matter of > > uniformisation wrt other containers. I consider also adding [iter] and > > [filter]. > > Enum already have iter and filter. As it is supposed to provide a > common layer for those kinds of operation, i'm not sure iter and > filter are that useful. An of_enum would be useful, though (is it ok > for those function not to be one to one mapping ?). I'm willing to write [of_enum], if people consider it interesting. What should it do if there is more than one element in the enumeration ? Raise an error or just consume the first element ? > >> What's the use case for Option.enum? > > For example, if you have an enumeration of options, and you want to > "flatten" it into an enumeration of the base type (you're not > interested in the failure cases) : > Enum.concat (Enum.map Option.enum your_option_enum) As usual, you have a point. > Speaking of the Option module, I have a suggestion for a monadic > "bind" function (a celebrity in the Haskell world, would imho be > useful in OCaml too) : [...] If we have to write a bind, I'd keep it consistent with other OCaml-based binds, i.e. in the same order as Haskell. Cheers, David -- David Teller Security of Distributed Systems http://www.univ-orleans.fr/lifo/Members/David.Teller Angry researcher: French Universities need reforms, but the LRU act brings liquidations. |