]> gitweb.michael.orlitzky.com - hath.git/blob - src/Maskable.hs
hath.cabal: add other-modules for the tasty test suite.
[hath.git] / src / Maskable.hs
1 module Maskable (
2 Maskable(..) )
3 where
4
5 import Bit (Bit)
6 import Maskbits (Maskbits)
7
8 -- | Any string of bits should be maskable by some number of netmask
9 -- bits. The convention of the Maskable typeclass follows CIDR
10 -- notation, where the number of mask bits (the number after the
11 -- slash) denotes how many bits are reserved for the network.
12 --
13 -- So, a mask of 32 applied to an address of 127.0.0.1 will again
14 -- return 127.0.0.1. Likewise, 31 mask bits applied to 127.0.0.1
15 -- should return 127.0.0.0, since 127.0.0.1/31 matches both
16 -- 127.0.0.0 and 127.0.0.1. In this case, the final '0' or '1' is
17 -- the host part of the address. The '127.0.0' is thus the network
18 -- part.
19 --
20 -- The Bit argument allows us to specify whether the host bits
21 -- should be replaced with either Zero or One.
22 --
23 class Maskable a where
24 apply_mask :: a -> Maskbits -> Bit -> a