<div class="gmail_quote">On Thu, Jan 19, 2012 at 13:16, Aleksey Khudyakov <span dir="ltr">&lt;<a href="mailto:alexey.skladnoy@gmail.com">alexey.skladnoy@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">On 20.01.2012 00:37, Nicholas Tung wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Dear all,<br>
<br>
     I wanted to voice support for a partial type annotations. Here&#39;s my<br>
usage scenario: I have a monad for an imperative EDSL, which has an<br>
associated expression data type,<br>
<br>
</blockquote></div>
I wanted such extension more than once. For me it&#39;s useful when compiler can almost infer type and only few type variables are actually required. Now I have to either type full signature or invert functions a la `asTypeOf&#39;<div class="im">

<br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
class (Monad m, Expression (ExprTyp m)) =&gt; MyDSLMonad m where<br>
     data ExprTyp m :: * -&gt; *<br>
<br>
     and you write imperative EDSL code like so,<br>
<br>
my_code_block = do<br>
     x &lt;- instruction1<br>
     y &lt;- instruction2 (x + x)<br>
     ...<br>
<br>
     I want the user to be able to annotate &quot;x is an Integer&quot;. However,<br>
to do that now, one has to now add a type signature for my_code_block<br>
like so, so that the $m$ variable is in scope,<br>
<br>
my_code_block :: forall m. MyDSLMonad m =&gt; m ()<br>
my_code_block = do<br>
     x :: ExprTyp m Integer &lt;- instruction1<br>
</blockquote>
<br></div>
Actually it should be<br>
<br>
&gt; my_code_block :: ...<br>
&gt; my_code_block = do<br>
&gt;   x :: Integer &lt;- instruction1 -- Require ScopedTypeVariables<br>
<br>
or<br>
<br>
&gt;   x &lt;- instruction1 :: Expr Integer<br>
<br>
or with partial type signatures<br>
<br>
&gt;   x &lt;- instruction1 :: _ _ Integer<br>
<br>
or wiht<br>
<br>
&gt;   x &lt;- instruction1<br>
&gt;   y &lt;- instrunctio2 (x + x :: Integer)<br></blockquote><div class="gmail_quote"><br></div><div class="gmail_quote">It&#39;s not important, but my example was what I meant -- I am creating an EDSL, and the values flowing through are actually syntax trees representing expressions. For example, &quot;x + x&quot; might create a tree with top node &quot;+&quot;, and subtrees as &quot;x&quot;. We then have type</div>

<div class="gmail_quote"><br></div><div class="gmail_quote">instruction1 :: m (ExprTyp m Integer)</div><div class="gmail_quote"><br></div><div class="gmail_quote">or using the shorthand, if there were partial signatures,</div>

<div class="gmail_quote"><br></div><div class="gmail_quote">instruction1 :: m (Expr Integer)</div><div class="gmail_quote"><br></div>regards,<br clear="all">Nicholas — <a href="https://ntung.com/" target="_blank">https://ntung.com</a> — 4432-nstung<br>

</div>