X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FMaskable.hs;h=d05ff6ffbaf63b9695206f596bdd1bc154afc1e4;hb=18a81546e7c4ad10574918efb08b2e104e911d73;hp=1441c07a6757b8ae3d80f781c52d8fb6fb5ea01d;hpb=4520812e6f264cdeba984d180f20a8f8c6b6d645;p=hath.git diff --git a/src/Maskable.hs b/src/Maskable.hs index 1441c07..d05ff6f 100644 --- a/src/Maskable.hs +++ b/src/Maskable.hs @@ -1,17 +1,22 @@ module Maskable where +import Bit import Maskbits --- Any string of bits should be maskable by some number of netmask --- bits. The convention of the Maskable typeclass follows CIDR --- notation, where the number of mask bits (the number after the --- slash) denotes how many bits are reserved for the network. +-- | Any string of bits should be maskable by some number of netmask +-- bits. The convention of the Maskable typeclass follows CIDR +-- notation, where the number of mask bits (the number after the +-- slash) denotes how many bits are reserved for the network. +-- +-- So, a mask of 32 applied to an address of 127.0.0.1 will again +-- return 127.0.0.1. Likewise, 31 mask bits applied to 127.0.0.1 +-- should return 127.0.0.0, since 127.0.0.1/31 matches both +-- 127.0.0.0 and 127.0.0.1. In this case, the final '0' or '1' is +-- the host part of the address. The '127.0.0' is thus the network +-- part. +-- +-- The Bit argument allows us to specify whether the host bits +-- should be replaced with either Zero or One. -- --- So, a mask of 32 applied to an address of 127.0.0.1 will again --- return 127.0.0.1. Likewise, 31 mask bits applied to 127.0.0.1 --- should return 127.0.0.0, since 127.0.0.1/31 matches both 127.0.0.0 --- and 127.0.0.1. In this case, the final '0' or '1' is the host --- part of the address. The '127.0.0' is thus the network part. class Maskable a where - apply_mask :: a -> Maskbits -> a - + apply_mask :: a -> Maskbits -> Bit -> a