<div class="gmail_quote">On Thu, Jan 19, 2012 at 13:16, Aleksey Khudyakov <span dir="ltr"><<a href="mailto:alexey.skladnoy@gmail.com">alexey.skladnoy@gmail.com</a>></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'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'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'<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)) => MyDSLMonad m where<br>
data ExprTyp m :: * -> *<br>
<br>
and you write imperative EDSL code like so,<br>
<br>
my_code_block = do<br>
x <- instruction1<br>
y <- instruction2 (x + x)<br>
...<br>
<br>
I want the user to be able to annotate "x is an Integer". 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 => m ()<br>
my_code_block = do<br>
x :: ExprTyp m Integer <- instruction1<br>
</blockquote>
<br></div>
Actually it should be<br>
<br>
> my_code_block :: ...<br>
> my_code_block = do<br>
> x :: Integer <- instruction1 -- Require ScopedTypeVariables<br>
<br>
or<br>
<br>
> x <- instruction1 :: Expr Integer<br>
<br>
or with partial type signatures<br>
<br>
> x <- instruction1 :: _ _ Integer<br>
<br>
or wiht<br>
<br>
> x <- instruction1<br>
> y <- instrunctio2 (x + x :: Integer)<br></blockquote><div class="gmail_quote"><br></div><div class="gmail_quote">It'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, "x + x" might create a tree with top node "+", and subtrees as "x". 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>