[Haskell-cafe] dependent types
Jason Dagit
dagit at codersbase.com
Mon Apr 12 12:04:07 EDT 2010
On Mon, Apr 12, 2010 at 4:32 AM, Ben Millwood <haskell at benmachine.co.uk>wrote:
>
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100412/309d6ef6/attachment.html
More information about the Haskell-Cafe
mailing list