> -- Takes an IPAddr and returns another one describing the network
> subnet :: (Word (Host a) ~ Word (Mask a)) => a -> a
> subnet a = let m = mask a
> h = host a
> in makeIPAddr (fromBits $ (bits h) .&. (bits m)) $ m
Excellent!
Note that I didn't put a IPAddr context since in your code subnet is a
method of this class (with a default implementation), if this wasn't
your intention you should correct the indentation.
You are right, the context was not necessary. The function is in fact a default implementation.
BTW: Does what I'm trying to do make any sense at all? Does anyone know of a better/simpler way to do this (i.e making most of these computations independant of the exact underlying type)?
Anyways, thanks a lot for your help,
Patrick
--
Jedaï