[Haskell-cafe] Dependent types

Mitar mmitar at gmail.com
Fri Sep 10 02:14:19 EDT 2010


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Test2.hs
Type: application/octet-stream
Size: 1582 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100910/9d1f46d5/Test2.obj


More information about the Haskell-Cafe mailing list