Thank you all very much for the pointers.<br><br>Best,<br><br><div class="gmail_quote">On 22 March 2010 09:32, Gleb Alexeyev <span dir="ltr">&lt;<a href="mailto:gleb.alexeev@gmail.com">gleb.alexeev@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">Ozgur Akgun wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Is there any way to limit a functions type, not by a data type but by a group of constructors of a data type? If not, what would be the *right* thing to do to achieve this level of type safety?<br>
<br>
data DT1 = X | Y | Z<br>
data DT2 = A | B | C | D<br>
<br>
<br>
func1 :: DT1 -&gt; DT2 -- instead of this<br>
func1&#39; :: (X|Y) -&gt; (B|C) -- i want sth. like this. (| means or)<br>
<br>
</blockquote></div>
OCaml has a feature called &#39;polymorphic variants&#39; that allows exactly this. You may want to google &#39;polymorphic variants in haskell&#39;.<div><div></div><div class="h5"><br>
<br>
_______________________________________________<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>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Ozgur Akgun<br>