module UVMHS.Core.Classes.Bitty where

import UVMHS.Core.Classes.Order

import UVMHS.Core.Init

infixl 5 ,
infixl 6 
infixl 7 ,

class BitZero       a where bzero   a
class BitOne        a where bone    a
class BitComp       a where comp    a  a
class BitAnd        a where (⟑)     a  a  a
class BitOr         a where (⟇)     a  a  a
class BitXor        a where (⊻)     a  a  a
class BitShiftL     a where (⋘)     a  ℕ64  a
class BitShiftR     a where (⋙)     a  ℕ64  a
class BitSize       a where bsize   P a  ℕ64
class
  (   BitZero   a
  ,   BitOne    a
  ,   BitComp   a
  ,   BitAnd    a
  ,   BitOr     a
  ,   BitXor    a
  ,   BitShiftL a
  ,   BitShiftR a
  ,   BitSize   a
  )  Bitty     a

bit  (BitOne a,BitShiftL a)  ℕ64  a
bit :: forall a. (BitOne a, BitShiftL a) => ℕ64 -> a
bit ℕ64
n = a
forall a. BitOne a => a
bone a -> ℕ64 -> a
forall a. BitShiftL a => a -> ℕ64 -> a
 ℕ64
n

bget  (Eq a,BitZero a,BitOne a,BitAnd a,BitShiftL a)  ℕ64  a  Bool
bget :: forall a.
(Eq a, BitZero a, BitOne a, BitAnd a, BitShiftL a) =>
ℕ64 -> a -> Bool
bget ℕ64
n a
x = (a
x a -> a -> a
forall a. BitAnd a => a -> a -> a
 ℕ64 -> a
forall a. (BitOne a, BitShiftL a) => ℕ64 -> a
bit ℕ64
n) a -> a -> Bool
forall a. Eq a => a -> a -> Bool
 a
forall a. BitZero a => a
bzero

bset  (BitOne a,BitOr a,BitShiftL a)  ℕ64  a  a
bset :: forall a. (BitOne a, BitOr a, BitShiftL a) => ℕ64 -> a -> a
bset ℕ64
n a
x = a
x a -> a -> a
forall a. BitOr a => a -> a -> a
 ℕ64 -> a
forall a. (BitOne a, BitShiftL a) => ℕ64 -> a
bit ℕ64
n

bflp  (BitOne a,BitXor a,BitShiftL a)  ℕ64  a  a
bflp :: forall a. (BitOne a, BitXor a, BitShiftL a) => ℕ64 -> a -> a
bflp ℕ64
n a
x = a
x a -> a -> a
forall a. BitXor a => a -> a -> a
 ℕ64 -> a
forall a. (BitOne a, BitShiftL a) => ℕ64 -> a
bit ℕ64
n

bclr  (BitOne a,BitComp a,BitAnd a,BitShiftL a)  ℕ64  a  a
bclr :: forall a.
(BitOne a, BitComp a, BitAnd a, BitShiftL a) =>
ℕ64 -> a -> a
bclr ℕ64
n a
x = a
x a -> a -> a
forall a. BitAnd a => a -> a -> a
 a -> a
forall a. BitComp a => a -> a
comp (ℕ64 -> a
forall a. (BitOne a, BitShiftL a) => ℕ64 -> a
bit ℕ64
n)