{-# LANGUAGE OverloadedStrings #-} module RON.Text.Serialize.Experimental (serializeOpenFrame) where import RON.Prelude import qualified Data.ByteString.Lazy.Char8 as BSLC import RON.Text.Serialize (serializeOpenOp) import RON.Types (Op (opId), OpenFrame) import qualified RON.UUID as UUID serializeOpenFrame :: OpenFrame -> ByteStringL serializeOpenFrame :: OpenFrame -> ByteStringL serializeOpenFrame OpenFrame ops = ByteStringL -> [ByteStringL] -> ByteStringL BSLC.intercalate ByteStringL ",\n" [ByteStringL] opsSerialized ByteStringL -> ByteStringL -> ByteStringL forall a. Semigroup a => a -> a -> a <> ByteStringL ";\n" where opsSerialized :: [ByteStringL] opsSerialized = (UUID -> Op -> ByteStringL) -> [UUID] -> OpenFrame -> [ByteStringL] forall a b c. (a -> b -> c) -> [a] -> [b] -> [c] zipWith UUID -> Op -> ByteStringL serializeOpenOp (UUID UUID.zero UUID -> [UUID] -> [UUID] forall a. a -> [a] -> [a] : (Op -> UUID) -> OpenFrame -> [UUID] forall a b. (a -> b) -> [a] -> [b] map Op -> UUID opId OpenFrame ops) OpenFrame ops