<div dir="ltr">Given these three library init predicates...<br><font face="courier new, monospace"><br>:- pred setup_sdl(bool::out, io::di, io::uo) is det.<br>:- pred setup_sdlmix(bool::out, io::di, io::uo) is det.<br>:- pred setup_sdlimg(bool::out, io::di, io::uo) is det.</font><br><br>is there a more idiomatic / efficient / less $%^&*( ugly way to do this please...<br><br><font face="courier new, monospace">:- pred setup_app(bool::out, io::di, io::uo) is det.<br><br>setup_app(CanRun, !IO) :-<br>    setup_sdl(SdlUp, !IO),<br>    (<br>        SdlUp = yes,<br>        setup_sdlimg(ImgUp, !IO),<br>        (<br>            ImgUp = yes,<br>            setup_sdlmix(MixUp, !IO),<br>            (<br>                MixUp = yes,<br>                CanRun = yes<br>            ;<br>                MixUp = no,<br>                CanRun = no<br>            )<br>        ;<br>            ImgUp = no,<br>            CanRun = no<br>        )<br>    ;<br>        SdlUp = no,<br>        CanRun = no<br>    ).</font><br>    <br> IIUIC you can't have predicates being anything other than `det` if they use IO ? The above code is classic staircase, in Haskell I'd hear "maybe monads" screaming at me but I have not yet gotten exposure to the std_util maybe wrapper...it seems to be just a normal type constructor with yes(T) and no, and also maybe_error as well. All suggestions welcome!!<br> <br> It's going well, I have sounds, images, lines, rectangles all in a window but I am now trying to get away from the FFI and start to learn more idiomatic Mercury.<br> <br> Thanks,<br> Sean<br> <br></div>