module Bytezap.Write.Internal where
import Bytezap.Poke qualified as P
data Write s = Write { forall s. Write s -> Int
size :: Int, forall s. Write s -> Poke s
poke :: P.Poke s }
instance Semigroup (Write s) where
Write Int
ll Poke s
lp <> :: Write s -> Write s -> Write s
<> Write Int
rl Poke s
rp = Int -> Poke s -> Write s
forall s. Int -> Poke s -> Write s
Write (Int
ll Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
rl) (Poke s
lp Poke s -> Poke s -> Poke s
forall a. Semigroup a => a -> a -> a
<> Poke s
rp)
instance Monoid (Write s) where
mempty :: Write s
mempty = Int -> Poke s -> Write s
forall s. Int -> Poke s -> Write s
Write Int
0 Poke s
forall a. Monoid a => a
mempty