[Haskell-beginners] How to nest arbitrary things

Imants Cekusins imantc at gmail.com
Mon Dec 21 13:51:08 UTC 2015


>  trucks
        containing boxes
                containing parcels
                        containing cans


.. or try this type:

data Item a = Truck a [Item] | Box a [Item] | Parcel a [Item] | Can a [Item]

"a" here is a property you may use to identify each Item e.g. String


More information about the Beginners mailing list