From 3df3bba2b1a5012d2722bf5d1184e0e725621c89 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 15 Oct 2012 01:14:37 -0400 Subject: [PATCH] Add a custom Show instance for TwoTuple. --- src/TwoTuple.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/TwoTuple.hs b/src/TwoTuple.hs index daeb6e4..1b5e93e 100644 --- a/src/TwoTuple.hs +++ b/src/TwoTuple.hs @@ -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) -- 2.43.2