{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Flat.AsSize(AsSize(..)) where
import Flat.Class (Flat (..))
import Flat.Decoder.Prim (sizeOf)
import Flat.Decoder.Types (Get)
import Flat.Types (NumBits)
newtype AsSize a = AsSize NumBits deriving (AsSize a -> AsSize a -> Bool
forall a. AsSize a -> AsSize a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AsSize a -> AsSize a -> Bool
$c/= :: forall a. AsSize a -> AsSize a -> Bool
== :: AsSize a -> AsSize a -> Bool
$c== :: forall a. AsSize a -> AsSize a -> Bool
Eq,AsSize a -> AsSize a -> Bool
AsSize a -> AsSize a -> Ordering
AsSize a -> AsSize a -> AsSize a
forall a. Eq (AsSize a)
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
forall a. AsSize a -> AsSize a -> Bool
forall a. AsSize a -> AsSize a -> Ordering
forall a. AsSize a -> AsSize a -> AsSize a
min :: AsSize a -> AsSize a -> AsSize a
$cmin :: forall a. AsSize a -> AsSize a -> AsSize a
max :: AsSize a -> AsSize a -> AsSize a
$cmax :: forall a. AsSize a -> AsSize a -> AsSize a
>= :: AsSize a -> AsSize a -> Bool
$c>= :: forall a. AsSize a -> AsSize a -> Bool
> :: AsSize a -> AsSize a -> Bool
$c> :: forall a. AsSize a -> AsSize a -> Bool
<= :: AsSize a -> AsSize a -> Bool
$c<= :: forall a. AsSize a -> AsSize a -> Bool
< :: AsSize a -> AsSize a -> Bool
$c< :: forall a. AsSize a -> AsSize a -> Bool
compare :: AsSize a -> AsSize a -> Ordering
$ccompare :: forall a. AsSize a -> AsSize a -> Ordering
Ord,NumBits -> AsSize a -> ShowS
forall a. NumBits -> AsSize a -> ShowS
forall a. [AsSize a] -> ShowS
forall a. AsSize a -> String
forall a.
(NumBits -> a -> ShowS)
-> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AsSize a] -> ShowS
$cshowList :: forall a. [AsSize a] -> ShowS
show :: AsSize a -> String
$cshow :: forall a. AsSize a -> String
showsPrec :: NumBits -> AsSize a -> ShowS
$cshowsPrec :: forall a. NumBits -> AsSize a -> ShowS
Show)
instance Flat a => Flat (AsSize a) where
size :: Flat a => AsSize a -> NumBits -> NumBits
size :: Flat a => AsSize a -> NumBits -> NumBits
size = forall a. HasCallStack => String -> a
error String
"unused"
encode :: AsSize a -> Encoding
encode = forall a. HasCallStack => String -> a
error String
"unused"
decode :: Flat a => Get (AsSize a)
decode :: Flat a => Get (AsSize a)
decode = forall a. NumBits -> AsSize a
AsSize forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Get a -> Get NumBits
sizeOf (forall a. Flat a => Get a
decode :: Get a)