From: Michael Orlitzky Date: Mon, 4 Feb 2013 23:49:47 +0000 (-0500) Subject: Add a Vector instance for Vn. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=18ba466ff51b36d47d719f1b22b55572ab634c15;p=numerical-analysis.git Add a Vector instance for Vn. --- diff --git a/src/FixedVector.hs b/src/FixedVector.hs index 402b02e..70f641e 100644 --- a/src/FixedVector.hs +++ b/src/FixedVector.hs @@ -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