On 2009 Mar 28, at 22:36, michael rice wrote:
import Data.Ratio cf :: [Integer] -> Rational cf (x:xs) = (toRational x) + (1 % (cf xs)) cf (x:[]) = toRational x cf [] = toRational 0
Data.Ratio> :load cf.hs ERROR "cf.hs":3 - Type error in application *** Expression : toRational x + 1 % cf xs *** Term : toRational x *** Type : Ratio Integer *** Does not match : Ratio (Ratio Integer)
|
Your function cf produces a Rational (Ratio Int); you're using it in the denominator of another Ratio, which makes that Ratio's type Ratio (Ratio Int). This is almost certainly not what you intended, but I couldn't say what you actually want.