<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2015-01-25 22:47 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 Sun, Jan 25, 2015 at 10:39:48PM +0100, Gautier DI FOLCO wrote:<br>
> 2015-01-25 9:37 GMT+01:00 Tom Ellis <<br>
> <a href="mailto:tom-lists-haskell-cafe-2013@jaguarpaw.co.uk">tom-lists-haskell-cafe-2013@jaguarpaw.co.uk</a>>:<br>
><br>
> > 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<br>
> > directory,<br>
> > > I should stop the computation.<br>
> ><br>
> > 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>
</span><span class="">> If I do it this way, the evaluation is forced to be stopped, I have no way<br>
> to react to this error.<br>
<br>
</span>Could you explain more precisely what you are trying to achieve, perhaps<br>
with an example?<br>
<div class=""><div class="h5"><br>
Tom<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>
</div></div></blockquote></div><br>In fact I'm looking for a practical way to alter Imap to change it temporarily or not, globally or locally in a failable monad.<br><br>Example:<br><br><div style="margin-left:40px">select "Unknown" -- will fail<br>doSomethingUnrelated<br><br>failableLessMode<br>select "Unknown" -- will fail<br>doSomethingUnrelated -- unreached expression<br>-- or<br>select "Unknown" <!!> $ do-- will fail<br>  doSomethingUnrelated -- unreached expression<br><br>where <!!> :: Imap (Maybe a) -> (a -> Imap b) -> Imap (Maybe b)<br></div><br>Is it clearer?<br>Please let me know.<br><br>Thanks.<br></div></div>