From 18ba466ff51b36d47d719f1b22b55572ab634c15 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 4 Feb 2013 18:49:47 -0500 Subject: [PATCH] Add a Vector instance for Vn. --- src/FixedVector.hs | 9 +++++++++ 1 file changed, 9 insertions(+) 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 -- 2.44.2