diff options
author | Tom Smeding <tom@tomsmeding.com> | 2022-10-16 15:03:51 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2022-10-16 15:03:51 +0200 |
commit | 4c8c2f99a9817fe84ee7626de11736b133c1de1f (patch) | |
tree | cfc536f74b1b2d9b35ab79116ab0fd0dc7eb8d1f /lib |
Initial
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MandelHSlib.hs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/MandelHSlib.hs b/lib/MandelHSlib.hs new file mode 100644 index 0000000..d9409f7 --- /dev/null +++ b/lib/MandelHSlib.hs @@ -0,0 +1,20 @@ +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) |