LGTM, thanks

On Wed, 7 Oct 2015 at 11:03 'Klaus Aehlig' via ganeti-devel <
[email protected]> wrote:

> Add a function that iterates a function of type `a -> Maybe a`
> in the sense of the Maybe monad until nothing is obtained. The
> last Just value is not dropped. (This differs from the
> semantics of iterateOk.)
>
> Signed-off-by: Klaus Aehlig <[email protected]>
> ---
>  src/Ganeti/Utils.hs | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/src/Ganeti/Utils.hs b/src/Ganeti/Utils.hs
> index 1365440..fbe3a36 100644
> --- a/src/Ganeti/Utils.hs
> +++ b/src/Ganeti/Utils.hs
> @@ -100,6 +100,7 @@ module Ganeti.Utils
>    , maxBy
>    , threadDelaySeconds
>    , monotoneFind
> +  , iterateJust
>    ) where
>
>  import Prelude ()
> @@ -869,3 +870,8 @@ monotoneFind heuristics p xs =
>               then Just x
>               else monotoneFind heuristics p xs'
>      _ -> Nothing
> +
> +-- | Iterate a funtion as long as it returns Just values, collecting
> +-- all the Justs that where obtained.
> +iterateJust :: (a -> Maybe a) -> a -> [a]
> +iterateJust f a = a : maybe [] (iterateJust f) (f a)
> --
> 2.6.0.rc2.230.g3dd15c0
>
> --

Helga Velroyen
Software Engineer
[email protected]

Google Germany GmbH
Dienerstraße 12
80331 München

Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

Diese E-Mail ist vertraulich. Wenn Sie nicht der richtige Adressat sind,
leiten Sie diese bitte nicht weiter, informieren Sie den Absender und
löschen Sie die E-Mail und alle Anhänge. Vielen Dank.

This e-mail is confidential. If you are not the right addressee please do
not forward it, please inform the sender, and please erase this e-mail
including any attachments. Thanks.

Reply via email to