
On Mon, Dec 21, 2015 at 08:41:47PM +0100, martin wrote:
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.
Unpacking should separate the container from its contents, i.e. given a packed container it should return an empty container and whatever was inside.
I'd still ask for a type signature if you feel it's possible, it clears things up (and/or highlights where the type system is getting in the way). An I'd still argue that "arbitrarily nestable" things is a bad idea, as Kim-Ee Yeoh explained. I like Haskell type system because carefully designed types "lead the way": some 'wrong' code won't even compile. In real life, what are we trying to model? Why is `unpack` useful/needed? How would I use its output? (a valid answer being: "just a mental experiment")