summaryrefslogtreecommitdiff
path: root/lib/MandelHSlib.hs
blob: 44d59dda4a61ae45c023ba5fea2c4e3e8d8e8d11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module MandelHSlib where

import qualified Data.Serialize as Ser
import qualified Data.Vector.Storable as VS


data Fractal = Fractal (Int, Int) Int (VS.Vector Double)

instance Ser.Serialize Fractal 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)