
On Mon, Apr 12, 2010 at 4:32 AM, Ben Millwood
Personally I think this approach is all rather OO. The way that seems most natural to me is:
moveVehicleAcrossBridge :: Bridge -> Vehicle -> Maybe Move moveVehicleAcrossBridge bridge { maxWeight = max } vehicle { weight = w } | w > max = Nothing | otherwise = {- ... moving stuff ... -}
so you just test the properties directly as and when they are interesting to you.
The problem with this is that it doesn't address the question the OP had. The OP's question was how to enforce things at the type level, but this, while being a valid approach, allows heavy vehicles to attempt the bridge crossing. I agree it's a nice way of encoding it, but if type level enforcement is called for then I don't see how it applies. Jason