]> gitweb.michael.orlitzky.com - numerical-analysis.git/blobdiff - src/TwoTuple.hs
Add a custom Show instance for TwoTuple.
[numerical-analysis.git] / src / TwoTuple.hs
index daeb6e41f8cdbbbe43e11139236dbc88f5955c18..1b5e93e151f1f7d8b5f3774e454b4a4589c20b3b 100644 (file)
@@ -1,5 +1,7 @@
 -- | Implement ordered pairs all over again for fun (and to make sure
---   that we can manipulate them algebraically).
+--   that we can manipulate them algebraically). Also require (as
+--   opposed to the built-in ordered pairs) that the elements have
+--   matching types.
 --
 module TwoTuple
 where
@@ -8,7 +10,10 @@ import Vector
 
 
 data TwoTuple a = TwoTuple a a
-  deriving (Eq, Show)
+  deriving (Eq)
+
+instance (Show a) => Show (TwoTuple a) where
+  show (TwoTuple x y) = "(" ++ (show x) ++ ", " ++ (show y) ++ ")"
 
 instance Functor TwoTuple where
   f `fmap` (TwoTuple x1 y1) = TwoTuple (f x1) (f y1)