haskell - How to create a list of heterogeneous datatypes without using sum-types or copies -
the use-case: app follow users across several messaging services. there's twitteraccount datatype, facebookaccount datatype, etc. these joined account sum-type, next level of hierarchy leads problem. a twitteraccount has list of twitterpost s, facebookaccount has list of facebookpost s, etc. my task: want able put posts last 10 days accounts single list, , extract common time , message body fields them display. my failed approach: thought if every class of post implemented typeclass simplepost exposing functions messagebody , messagetime that might solve problem, can't create list of [simplemessage] . i want maintain invariant twitteraccount can contain twitterpost s, , on, can't use sum-types. i'd prefer not create copies of objects this. what best, cleanest, haskell-ish design problem? update isn't answer, alternative 4 solutions provided recursion.ninja , helder pereira i've been thinking if can meet invariants using phantom type...