]> gitweb.michael.orlitzky.com - hath.git/blob - src/Maskable.hs
1441c07a6757b8ae3d80f781c52d8fb6fb5ea01d
[hath.git] / src / Maskable.hs
1 module Maskable where
2
3 import Maskbits
4
5 -- Any string of bits should be maskable by some number of netmask
6 -- bits. The convention of the Maskable typeclass follows CIDR
7 -- notation, where the number of mask bits (the number after the
8 -- slash) denotes how many bits are reserved for the network.
9 --
10 -- So, a mask of 32 applied to an address of 127.0.0.1 will again
11 -- return 127.0.0.1. Likewise, 31 mask bits applied to 127.0.0.1
12 -- should return 127.0.0.0, since 127.0.0.1/31 matches both 127.0.0.0
13 -- and 127.0.0.1. In this case, the final '0' or '1' is the host
14 -- part of the address. The '127.0.0' is thus the network part.
15 class Maskable a where
16 apply_mask :: a -> Maskbits -> a
17