[Haskell-beginners] How to nest arbitrary things

Francesco Ariis fa-ml at ariis.it
Mon Dec 21 17:30:13 UTC 2015


On Mon, Dec 21, 2015 at 06:00:06PM +0100, martin wrote:
> That's fine. I'm happy not to be able to pack a truck into another truck.
> Only problem is that I don't know how to write an "unpack" function,
> which removes one level of nesting. I can only write unpackTruck,
> unpackParcel ...
>
> I suppose the ability to write a generic unpack function implies that
> there can be a generic pack function and then I could pack a truck into
> another truck.

I would say typeclasses might help you, but before that, what would
the unpack function signature look like?

    unpack :: (Package s) => s a -> [a]

Like this? If so, I don't see much benefit (or what problem we're
trying to solve) in trucks>boxes>parcels>cans types.





More information about the Beginners mailing list