<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2015-01-25 9:37 GMT+01:00 Tom Ellis <span dir="ltr"><<a href="mailto:tom-lists-haskell-cafe-2013@jaguarpaw.co.uk" target="_blank">tom-lists-haskell-cafe-2013@jaguarpaw.co.uk</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="">On Sat, Jan 24, 2015 at 07:46:52PM +0100, Gautier DI FOLCO wrote:<br>
> data ImapF next =<br>
>          Select DirectoryName (Maybe DirectoryDescription -> next)<br>
>        | Noop (DirectoryDescription -> next)<br>
>        | Search MailSearch (Maybe [UID] -> next)<br>
> -- Functor instance<br>
> type Imap = Free ImapF<br>
><br>
> searchAll :: Imap (Maybe [UID])<br>
> searchAll = liftF $ Search undefined id<br>
> select :: DirectoryName -> Imap (Maybe DirectoryDescription)<br>
> select directory = liftF $ Select directory id<br>
><br>
> My main problem is the following: if I do a select of an unknown directory,<br>
> I should stop the computation.<br>
<br>
</span>What do you mean you "should stop the computation"?  Do you mean the<br>
interpretation of the free monad should be forced to stop?  If so, doesn't<br>
making the type of the `Select` constructor<br>
<br>
    Select DirectoryName (DirectoryDescription -> next)<br>
<br>
achieve this?  That way if the interpreter talks issues a select command to<br>
the server and fails to receive a `DirectoryDescription` in return then it<br>
is forced to stop.<br>
<br>
Tom<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br>Hello,<br><br>Thanks for your answer.<br>If I do it this way, the evaluation is forced to be stopped, I have no way to react to this error.<br></div></div>