[Haskell-beginners] Functor instance for ordered lists

martin martin.drautzburg at web.de
Mon Jan 4 21:54:37 UTC 2016


Am 01/04/2016 um 10:11 PM schrieb Imants Cekusins:


> Why not define product as
> data Prod a c = Prod a [c]
> 
> where a is product info and c is child item data.

Well first the Product is not necessarily a single "thing". There can be various a's which satisfy the criteria to fall
into a specific Product. So either a must be a set-like thing or a function a->Bool.

Then there is not necessarily just one level of nesting. The c's can still be containers, and it matters what's inside
them. It's like a carton of iPhones, which has iPhone packages inside and each iPhone package consists of an iPhone, a
Charger, a Manual and ... and the Charger consists of a Cable, a circuit board ...

If any of the conditions are not met, if e.g. you receive a carton of iPhones where one charger lacks its cable, you
have reason to complain.



More information about the Beginners mailing list