[Haskell-cafe] Defining types (newbie)

John Fouhy john at fouhy.net
Wed Mar 14 00:03:08 EDT 2007


On 14/03/07, Bryan O'Sullivan <bos at serpentine.com> wrote:
> John Fouhy wrote:
>
> > In Haskell, I envisage writing something like:
> >
> > data ThingCompare = TC Op Field
>
> This wants to be a bit more concrete:
>
> data ThingCompare = TC (a -> a -> Bool) (Thing -> a)

Hi Bryan,

I actually had to write:

data ThingCompare a = TC (a -> a -> Bool) (Thing -> a)

runTC :: ThingCompare a -> Thing -> Thing -> Bool
runTC (TC compare extract) x y = compare (extract x) (extract y)

But thanks for your help; it set me back on the right track.  I think
things are slowly starting to come back to me :-)

-- 
John.


More information about the Haskell-Cafe mailing list