Re: Numeric conversions

1997-10-01 Thread Simon L Peyton Jones
> > real2frac :: (Real a, Fractional b) => a -> b > > real2frac = fromRational . toRational > > The composition of fromRational and toRational seems to be the > only way to convert a Double or an Int to a Double. > > There is a function in the prelude, fromRealFrac, with exactly > the same defi

polymorphic mean value. Reply.

1997-10-01 Thread S.D.Mechveliani
[EMAIL PROTECTED] wrote something on the possible generic function for the mean value (I had lost the letter) > real2frac ... fromRational . toRational But will this do: - mean :: (Num a, Num b, Fractional b) => (a -> b) -

Re: Heap Sort

1997-10-01 Thread Jon . Fairbairn
Here is my version: First we need treefold: --- module Treefold where -- I'm surprised treefold isn't in the standard prelude since it's so useful -- treefold (*) z [a,b,c,d,e,f] = (((a*b)*(c*d))*(e*f)) -- translated from the version I wrote in Ponder in October 1992 -- Jon Fairbairn treefold

Re: Deriving newtype ADTs from type ADTs

1997-10-01 Thread Simon L Peyton Jones
> However, if the transforming program took into account the information in the > type signature (for unionMany, it would notice that the user used the type > synonym for the inner list only), it could make pretty good guesses about which > arguments and results to unpack or pack. > Since the ad

Re: Defining search trees as monads

1997-10-01 Thread Koen Claessen
| When I was trying to sleep last night I though I could implement Search | Trees in Haskell. | And not only that, I would try to implement them as monads. | The problem is that search trees require context Ord a. Since noone has replied to this yet, I will give a short explanation. A Monad