<div dir="ltr"><br><div class="gmail_quote"><br><div dir="ltr"><div class="gmail_extra">Oleg: Very interresting, thanks. I have some questions:<br>- What do you mean by "The type Cont Int a describes an impure computation, which may
abort with an Int value, for example". <br></div><div class="gmail_extra">Aborting with an Int value is akin to exceptions?<br></div><div class="gmail_extra">- for me it's not clear when to choose an "applicative" or a "monadic" DSL? Betsides, what's the rational behind the name "let_" (never seen it before)?<br>

</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br>Linsey, Jacques: Thanks for the pointer! I learned about data kinds.<br>I tried to apply your suggestions to add a phantom type parameter to Exp.<br></div>

<div class="gmail_extra">I came up to (I dropped the Free monad idea, which seems unrelated to the problem):<br><span style="font-family:courier new,monospace"><br>> data Eff = Effect | NoEffect<br><br>> -- first type parameter is used to track effects<br>
> data Exp :: Eff -> * -> * where<br>
>   ReadAccount  :: Exp r Int  --ReadAccount can be used in whatever monad (with or without effect)<br>>   WriteAccount :: Exp NoEffect Int -> Exp Effect ()  --WriteAccount takes an effect-less expression, and returns an effectfull expression<br>

>   SetVictory   :: Exp NoEffect Bool -> Exp Effect ()  -- same for SetVictory<br>>   OnTimer      :: Exp Effect () -> Exp Effect () --OnTime can program whatever expression to be triggered every minutes, in particular effectful ones<br>

>   Return       :: a -> Exp r a<br>>   Bind         :: Exp r a -> (a -> Exp r b) -> Exp r b<br><br>This is the (simplified) game state:<div class="im"><br><br>> data Game = Game { bankAccount :: Int,<br>
</div>>                    victory     :: Exp NoEffect Bool,<br>
>                    timerEvent  :: Exp Effect ()}<br><br></span></div><div class="gmail_extra"><span style="font-family:courier new,monospace">> -- victory when account > 100<br></span></div><div class="gmail_extra">

<span style="font-family:courier new,monospace">> victoryRule' :: Exp Effect ()<div class="im"><br>> victoryRule' = SetVictory $ do<br></div>>   m <- readAccount<br>>   --WriteAccount (return $ m + 1) --won't compile (good)<div class="im">
<br>
>   return (m > 100)<br><br>> --increase my bank account by 1 every minute<br></div>> myTimer :: Exp Effect ()<br>> myTimer = OnTimer $ do<br>>   m <- readAccount<div class="im"><br>>   writeAccount (return $ m + 1)<br>

</div></span><br><br></div><div class="gmail_extra">Do you have a better name suggestion for Eff? Other pointers where this idiom is realised??<br></div><div class="gmail_extra">Thanks!!<span class="HOEnZb"><font color="#888888"><br>
</font></span></div><span class="HOEnZb"><font color="#888888"><div class="gmail_extra">Corentin<br>
</div></font></span></div>
</div><br></div>