
Hi! I believe dependent types is the right term for my problem. I was trying to solve it with GADTs but I was not successful so I am turning to infinite (lazy) wisdom of Haskell Cafe. I am attaching example code where I had to define MaybePacket data type which combines different types of Packets I would like to allow over Line. The problem is that there is a correlation between Line type and MaybePacket type and I would like to tell Haskell about that. But I am not sure how. Because now compiler, for example, warns me of a non-exhaustive pattern even if some MaybePacket value is not possible for given Line. Somehow I would like to have a getFromFirstLine function which would based on type of given Line return Maybe (Packet i) (for Line) or Maybe AnyPacket (for LineAny). So that this would be enforced and type checked. Best regards and thanks for any help Mitar

On 10 September 2010 07:14, Mitar
But I am not sure how. Because now compiler, for example, warns me of a non-exhaustive pattern even if some MaybePacket value is not possible for given Line.
This issue pops up quite quite often - Ryan Ingram's answer to it the last time it was on the Cafe points to the relevant Trac issue numbers: http://www.haskell.org/pipermail/haskell-cafe/2010-August/082790.html

Hi!
On Fri, Sep 10, 2010 at 9:22 AM, Stephen Tetley
This issue pops up quite quite often - Ryan Ingram's answer to it the last time it was on the Cafe points to the relevant Trac issue numbers:
But I have not yet made it as GADTs. I would need some help here. How to change MaybePacket to GADTs? Mitar

Hi! I made it. ;-) Thanks to all help from copumpkin on IRC channel. I am attaching my solution for similar problems in future. And of course comments. Mitar
participants (2)
-
Mitar
-
Stephen Tetley