[Haskell-cafe] Beginner problems with 'triple' code

Stu White disco_stu_rex at yahoo.co.uk
Mon Jul 26 13:10:06 EDT 2004

I'm not especially experienced in using haskell, and I could use some help.
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 order.
I'm having a few problems with the code that I have at the minute (I suspect its riddled with errors!)
type Triple = Triple {
    entry 1 :: a;
    entry 2 :: a;
    entry 3 :: a;
    sortTriple :: Triple a -> Triple a;
    } deriving (Show, Eq)
    sortTriple t@(Triple x y z)
        | (y<x) = sortTriple (Triple y x z)
        | (z<y) = sortTriple (Triple x z y)
        | otherwise = t
Hope you guys can help me, sorry if this seems trivial - but I'm only a beginner!  If you could explain/correct any errors I'd appreciate it, as I am trying to learn what to do and what not to do, not just arrive at a working program.
S. Midley

 ALL-NEW Yahoo! Messenger - all new features - even more fun!  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org//pipermail/haskell-cafe/attachments/20040726/e088308a/attachment.htm

More information about the Haskell-Cafe mailing list