{-# LANGUAGE DeriveGeneric #-}


module Data.Size where

import qualified Data.Serialize as Cereal hiding (get,put)
import Control.DeepSeq
import GHC.Generics


data BitSize = BitSize Int
  deriving (Int -> BitSize -> ShowS
[BitSize] -> ShowS
BitSize -> String
(Int -> BitSize -> ShowS)
-> (BitSize -> String) -> ([BitSize] -> ShowS) -> Show BitSize
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BitSize -> ShowS
showsPrec :: Int -> BitSize -> ShowS
$cshow :: BitSize -> String
show :: BitSize -> String
$cshowList :: [BitSize] -> ShowS
showList :: [BitSize] -> ShowS
Show, BitSize -> BitSize -> Bool
(BitSize -> BitSize -> Bool)
-> (BitSize -> BitSize -> Bool) -> Eq BitSize
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BitSize -> BitSize -> Bool
== :: BitSize -> BitSize -> Bool
$c/= :: BitSize -> BitSize -> Bool
/= :: BitSize -> BitSize -> Bool
Eq, Eq BitSize
Eq BitSize =>
(BitSize -> BitSize -> Ordering)
-> (BitSize -> BitSize -> Bool)
-> (BitSize -> BitSize -> Bool)
-> (BitSize -> BitSize -> Bool)
-> (BitSize -> BitSize -> Bool)
-> (BitSize -> BitSize -> BitSize)
-> (BitSize -> BitSize -> BitSize)
-> Ord BitSize
BitSize -> BitSize -> Bool
BitSize -> BitSize -> Ordering
BitSize -> BitSize -> BitSize
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: BitSize -> BitSize -> Ordering
compare :: BitSize -> BitSize -> Ordering
$c< :: BitSize -> BitSize -> Bool
< :: BitSize -> BitSize -> Bool
$c<= :: BitSize -> BitSize -> Bool
<= :: BitSize -> BitSize -> Bool
$c> :: BitSize -> BitSize -> Bool
> :: BitSize -> BitSize -> Bool
$c>= :: BitSize -> BitSize -> Bool
>= :: BitSize -> BitSize -> Bool
$cmax :: BitSize -> BitSize -> BitSize
max :: BitSize -> BitSize -> BitSize
$cmin :: BitSize -> BitSize -> BitSize
min :: BitSize -> BitSize -> BitSize
Ord, (forall x. BitSize -> Rep BitSize x)
-> (forall x. Rep BitSize x -> BitSize) -> Generic BitSize
forall x. Rep BitSize x -> BitSize
forall x. BitSize -> Rep BitSize x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BitSize -> Rep BitSize x
from :: forall x. BitSize -> Rep BitSize x
$cto :: forall x. Rep BitSize x -> BitSize
to :: forall x. Rep BitSize x -> BitSize
Generic)

data ByteSize = ByteSize Int
  deriving (Int -> ByteSize -> ShowS
[ByteSize] -> ShowS
ByteSize -> String
(Int -> ByteSize -> ShowS)
-> (ByteSize -> String) -> ([ByteSize] -> ShowS) -> Show ByteSize
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ByteSize -> ShowS
showsPrec :: Int -> ByteSize -> ShowS
$cshow :: ByteSize -> String
show :: ByteSize -> String
$cshowList :: [ByteSize] -> ShowS
showList :: [ByteSize] -> ShowS
Show, ByteSize -> ByteSize -> Bool
(ByteSize -> ByteSize -> Bool)
-> (ByteSize -> ByteSize -> Bool) -> Eq ByteSize
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ByteSize -> ByteSize -> Bool
== :: ByteSize -> ByteSize -> Bool
$c/= :: ByteSize -> ByteSize -> Bool
/= :: ByteSize -> ByteSize -> Bool
Eq, Eq ByteSize
Eq ByteSize =>
(ByteSize -> ByteSize -> Ordering)
-> (ByteSize -> ByteSize -> Bool)
-> (ByteSize -> ByteSize -> Bool)
-> (ByteSize -> ByteSize -> Bool)
-> (ByteSize -> ByteSize -> Bool)
-> (ByteSize -> ByteSize -> ByteSize)
-> (ByteSize -> ByteSize -> ByteSize)
-> Ord ByteSize
ByteSize -> ByteSize -> Bool
ByteSize -> ByteSize -> Ordering
ByteSize -> ByteSize -> ByteSize
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ByteSize -> ByteSize -> Ordering
compare :: ByteSize -> ByteSize -> Ordering
$c< :: ByteSize -> ByteSize -> Bool
< :: ByteSize -> ByteSize -> Bool
$c<= :: ByteSize -> ByteSize -> Bool
<= :: ByteSize -> ByteSize -> Bool
$c> :: ByteSize -> ByteSize -> Bool
> :: ByteSize -> ByteSize -> Bool
$c>= :: ByteSize -> ByteSize -> Bool
>= :: ByteSize -> ByteSize -> Bool
$cmax :: ByteSize -> ByteSize -> ByteSize
max :: ByteSize -> ByteSize -> ByteSize
$cmin :: ByteSize -> ByteSize -> ByteSize
min :: ByteSize -> ByteSize -> ByteSize
Ord, (forall x. ByteSize -> Rep ByteSize x)
-> (forall x. Rep ByteSize x -> ByteSize) -> Generic ByteSize
forall x. Rep ByteSize x -> ByteSize
forall x. ByteSize -> Rep ByteSize x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ByteSize -> Rep ByteSize x
from :: forall x. ByteSize -> Rep ByteSize x
$cto :: forall x. Rep ByteSize x -> ByteSize
to :: forall x. Rep ByteSize x -> ByteSize
Generic)

byteSize :: ByteSize -> Int
byteSize (ByteSize Int
si) = Int
si









instance Cereal.Serialize BitSize
instance Cereal.Serialize ByteSize

instance NFData BitSize
instance NFData ByteSize