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