
26 Jul
2004
26 Jul
'04
1:30 p.m.
On Mon, 26 Jul 2004, Stu White wrote:
As part of a project, I'm trying to construct a data type that can represent three values as a 'triple' (as opposed to a 'tuple'), and then make a function so that I can sort these values into ascending ord er.
Since sorting requires equal types of the triple elements you wouldn't loose generality if you use lists instead. For lists the function 'sort' is available in the libraries of GHC: Prelude> Data.List.sort [4,2,7] [2,4,7]
data Triple = Triple { entry 1 :: a; entry 2 :: a; entry 3 :: a; sortTriple :: Triple a -> Triple a; } deriving (Show, Eq)
Are you sure you want 'sortTriple' be a part of the data structure?