<div dir="ltr">Wow ... thanks Serguey .... that gets rid of <span style="font-family:arial,sans-serif;font-size:13.333333969116211px">DatatypeContexts as well!</span><div><span style="font-family:arial,sans-serif;font-size:13.333333969116211px"><br>
</span></div><div><span style="font-family:arial,sans-serif;font-size:13.333333969116211px">Regards,</span></div><div><span style="font-family:arial,sans-serif;font-size:13.333333969116211px">Kashyap</span></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Mon, Apr 1, 2013 at 9:12 PM, Serguey Zefirov <span dir="ltr">&lt;<a href="mailto:sergueyz@gmail.com" target="_blank">sergueyz@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 dir="ltr"><div>You have fixed the type of list by move RAX RAX. Now it has type Instruction SNDREG SNDREG<br><br></div>Make your Instruction a GADT and require that MOV should have appropriate constraints:<br><br>{-# LANGUAGE DatatypeContexts, GADTs #-}<div class="im">
<br>
<br>data SREG = RIP<br>data DREG = RBX<br>data SNDREG = RAX<br><br><br></div>data Instruction where<br>        MOV :: (Source s, Destination d) =&gt; s -&gt; d -&gt; Instruction<div class="im"><br><br><br>class Source a<br>
class Destination a<br>
<br>instance Source SREG<br>instance Source SNDREG<br><br>instance Destination DREG<br>instance Destination SNDREG<br><br><br>move :: (Source s, Destination d) =&gt; s -&gt; d -&gt; Instruction<br></div><div class="im">move s d = MOV s d<br>
<br>
hello = [move RAX RAX, move RAX RAX]<br><br></div>hello2 = [move RAX RAX, move RAX RBX] -- this is still not allowed.<br><br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">2013/4/1 C K Kashyap <span dir="ltr">&lt;<a href="mailto:ckkashyap@gmail.com" target="_blank">ckkashyap@gmail.com</a>&gt;</span><br>

</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div>Hi Cafe,</div>I am trying to embed x86 assembly in Haskell. I&#39;d like the EDSL to not allow invalid movements into registers - for example, should not allow moving into RIP. I was not able to get it to work. I ended up using DataTypeContexts - which is considered misfeature anyway. I was wondering if I could get some suggestions.<div>


<br></div><div><div>{-# LANGUAGE DatatypeContexts #-}</div><div><br></div><div>data SREG = RIP</div><div>data DREG = RBX</div><div>data SNDREG = RAX</div><div><br></div><div><br></div><div>data (Source s, Destination d) =&gt; Instruction s d = MOV s d </div>


<div><br></div><div><br></div><div>class Source a</div><div>class Destination a</div><div><br></div><div>instance Source SREG</div><div>instance Source SNDREG</div><div><br></div><div>instance Destination DREG</div><div>

instance Destination SNDREG</div>
<div><br></div><div><br></div><div>move :: (Source s, Destination d) =&gt; s -&gt; d -&gt; Instruction s d</div><div>move s d = MOV s d</div><div><br></div><div>hello = [move RAX RAX, move RAX RAX]</div><div><br></div><div>


hello = [move RAX RAX, move RAX RBX] -- this is still not allowed.</div></div><div><br></div><div>Regards,</div><div>Kashyap</div><div><br></div></div>
<br></div></div>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">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>
<br></blockquote></div><br></div>
</blockquote></div><br></div>