summaryrefslogtreecommitdiff
path: root/packages/base/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base/src')
-rw-r--r--packages/base/src/Internal/Static.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/packages/base/src/Internal/Static.hs b/packages/base/src/Internal/Static.hs
index 058b9d0..a0af085 100644
--- a/packages/base/src/Internal/Static.hs
+++ b/packages/base/src/Internal/Static.hs
@@ -35,8 +35,10 @@ import Control.DeepSeq
35import Data.Proxy(Proxy) 35import Data.Proxy(Proxy)
36import Foreign.Storable(Storable) 36import Foreign.Storable(Storable)
37import Text.Printf 37import Text.Printf
38
38import Data.Binary 39import Data.Binary
39import GHC.Generics (Generic) 40import GHC.Generics (Generic)
41import Data.Proxy (Proxy(..))
40 42
41-------------------------------------------------------------------------------- 43--------------------------------------------------------------------------------
42 44
@@ -51,7 +53,17 @@ instance Binary a => Binary (Complex a)
51 put (r :+ i) = put (r, i) 53 put (r :+ i) = put (r, i)
52 get = (\(r,i) -> r :+ i) <$> get 54 get = (\(r,i) -> r :+ i) <$> get
53 55
54instance (Binary a) => Binary (Dim n a) 56instance (KnownNat n, Binary a) => Binary (Dim n a) where
57 get = do
58 k <- get
59 let n = natVal (Proxy :: Proxy n)
60 if n == k
61 then Dim <$> get
62 else fail ("Expected dimension " ++ (show n) ++ ", but found dimension " ++ (show k))
63
64 put (Dim x) = do
65 put (natVal (Proxy :: Proxy n))
66 put x
55 67
56lift1F 68lift1F
57 :: (c t -> c t) 69 :: (c t -> c t)