module Radix.Word8.Debug
( S (..)
, validBelow
) where
import Radix.Word8.Foundation
import Data.Bits
data S = L
| R
deriving Int -> S -> ShowS
[S] -> ShowS
S -> String
(Int -> S -> ShowS) -> (S -> String) -> ([S] -> ShowS) -> Show S
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> S -> ShowS
showsPrec :: Int -> S -> ShowS
$cshow :: S -> String
show :: S -> String
$cshowList :: [S] -> ShowS
showList :: [S] -> ShowS
Show
validBelow :: Prefix -> S -> Key -> Bool
validBelow :: Key -> S -> Key -> Bool
validBelow Key
p1 S
s Key
p2 =
let q :: Key
q = Key
p2 Key -> Key -> Key
forall a. Bits a => a -> a -> a
.&. (Key
p1 Key -> Key -> Key
forall a. Bits a => a -> a -> a
.&. Key -> Key
forall a. Num a => a -> a
negate Key
p1)
in Bool -> Bool
not (Key -> Key -> Bool
beyond Key
p1 Key
p2) Bool -> Bool -> Bool
&& case S
s of
S
L -> Key
q Key -> Key -> Bool
forall a. Eq a => a -> a -> Bool
== Key
0
S
R -> Key
q Key -> Key -> Bool
forall a. Eq a => a -> a -> Bool
/= Key
0