]> gitweb.michael.orlitzky.com - hath.git/blob - src/Maskable.hs
Make combine_all operate recursively.
[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 127.0.0.0
14 -- and 127.0.0.1. In this case, the final '0' or '1' is the host
15 -- part of the address. The '127.0.0' is thus the network part.
16 --
17 -- The Bit argument allows us to specify whether the host bits
18 -- should be replaced with either Zero or One.
19 class Maskable a where
20 apply_mask :: a -> Maskbits -> Bit -> a
21