[Haskell-beginners] Heterogenous list implemented with GADT

Ken Overton koverton at lab49.com
Thu Sep 30 16:13:45 EDT 2010


On Sep 30, 2010, at 4:00 PM, Daniel Fischer wrote:
> What TG2 does is wrap a list of (henceforth) unknown type (as long as the
> type has a Show instance, and that Show instance is made available by
> pattern matching).

Thanks, that sheds some light on the usefulness of GADTs in general for me.

> To achieve something like your example, you'd need
>
> data TG3 where
>  MkTG3 :: Show a => a -> TG3
>
> xs :: [TG3]
> xs = [MkTG3 5, MkTG3 'Z', MkTG3 3.14, MkTG3 False]


Much clearer, thanks a lot.

--kov



This email and any attachments may contain information which is confidential and/or privileged. The information is intended exclusively for the addressee and the views expressed may not be official policy, but the personal views of the originator. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents is prohibited. If you have received this email and any file transmitted with it in error, please notify the sender by telephone or return email immediately and delete the material from your computer. Internet communications are not secure and Lab49 is not responsible for their abuse by third parties, nor for any alteration or corruption in transmission, nor for any damage or loss caused by any virus or other defect. Lab49 accepts no liability or responsibility arising out of or in any way connected to this email.


More information about the Beginners mailing list