module MandelHSlib where import qualified Data.Serialize as Ser import qualified Data.Vector.Storable as VS data Fractal a = Fractal (Int, Int) Int (VS.Vector a) instance (VS.Storable a, Ser.Serialize a) => Ser.Serialize (Fractal a) where put (Fractal size maxiter v) = do Ser.put size Ser.put maxiter Ser.putWord64be (fromIntegral (VS.length v)) VS.mapM_ Ser.put v get = do size <- Ser.get maxiter <- Ser.get len <- fromIntegral <$> Ser.getWord64be v <- VS.replicateM len Ser.get return (Fractal size maxiter v)