🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.functional
Article #1134

Haskell Operator Overloading. (Very) trivial newbie question.

#1134
From: James
Date: Tue, 02 Mar 1999 00:00
21 lines
1490 bytes
Hello,

The following is not a homework question, just something that has been
testing my patience. I have an algorithm that sorts a list of pairs. Say one
instance of the input is of type,

:: ((a,a),(a,a))

I find that if I use the derived ordering it sorts, but the result is not
what I want. I want to introduce an ordering based on a function I already
have. For example a metric on the above input with type,

:: Floating a => ((a,a),(a,a)) -> a

My understanding is that I should be able to achieve this by operator
overloading. I have looked at both the gentle intro and the Hugs prelude but
have just not had much success expressing it precisely in Haskell.

An example from any of you would be greatly appreciated.

  Thanks in advance
Technical Details
Message-ID: <7bhonu$qto$1@news8.svr.pol.co.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 107f24,96995099712e3974,start
X-Google-Attributes: gid107f24,public
X-Google-Thread: 10707f,96995099712e3974,start
X-Google-Attributes: gid10707f,public
From: "James" <reply@newsgroup.com>
Subject: Haskell Operator Overloading. (Very) trivial newbie question.
Date: 1999/03/02
Message-ID: <7bhonu$qto$1@news8.svr.pol.co.uk>
X-Deja-AN: 450526870
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
X-Complaints-To: abuse@theplanet.net
X-Trace: news8.svr.pol.co.uk 920413758 27576 62.136.121.126 (2 Mar 1999 22:29:18 GMT)
Organization: Customer of Planet Online
NNTP-Posting-Date: 2 Mar 1999 22:29:18 GMT
Newsgroups: comp.lang.functional,fa.haskell