[Haskell-cafe] Re: Strange typing?
Ozgur Akgun
ozgurakgun at gmail.com
Mon Mar 22 11:49:57 EDT 2010
Thank you all very much for the pointers.
Best,
On 22 March 2010 09:32, Gleb Alexeyev <gleb.alexeev at gmail.com> wrote:
> Ozgur Akgun wrote:
>
>> 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?
>>
>> data DT1 = X | Y | Z
>> data DT2 = A | B | C | D
>>
>>
>> func1 :: DT1 -> DT2 -- instead of this
>> func1' :: (X|Y) -> (B|C) -- i want sth. like this. (| means or)
>>
>> OCaml has a feature called 'polymorphic variants' that allows exactly
> this. You may want to google 'polymorphic variants in haskell'.
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
--
Ozgur Akgun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100322/1951ec81/attachment.html
More information about the Haskell-Cafe
mailing list