]> gitweb.michael.orlitzky.com - numerical-analysis.git/blobdiff - src/FixedVector.hs
Add a Vector instance for Vn.
[numerical-analysis.git] / src / FixedVector.hs
index 402b02eeb531c743f3bd324a8ad3ad4652f8ef3b..70f641edaf640bd641511f971b27a06075f91d13 100644 (file)
@@ -20,6 +20,15 @@ newtype Vn v a = Vn (v a)
 --   it contains.
 type instance V.Dim (Vn v) = V.Dim v
 
+instance (V.Vector v a) => V.Vector (Vn v) a where
+  -- | Fortunately, 'Fun' is an instance of 'Functor'. The
+  --   'V.construct' defined on our contained type will return a
+  --   'Fun', and we simply slap our constructor on top with fmap.
+  construct = fmap Vn V.construct
+
+  -- | Defer to the V.inspect defined on the contained type.
+  inspect (Vn v1) = V.inspect v1
+
 instance (Show a, V.Vector v a) => Show (Vn v a) where
   -- | Display vectors as ordinary tuples. This is poor practice, but
   --   these results are primarily displayed interactively and