[Fix up isRealValued. Bryan O'Sullivan **20080119012539] { hunk ./en/ch04-defining-types.xml 563 - Here, we don't care about the value of the result, just - about which constructor was used to create it. If it was - Left, the result must be a complex - number, otherwise it must be real. We can use a wild card for - the entire second pattern; there's no need to see if the - constructor is Right, because it - must be; Either only has two + Here, we don't care about the value of the + result, just about which constructor was used to create it. + If the constructor was Just, the result + must be a real number, otherwise it's either infinite or + complex. We can use a wild card for the entire second + pattern; there's no need to see if the constructor is + Nothing, because it + must be; Maybe only has two hunk ./en/ch04-defining-types.xml 1010 - Local functions + Local functions, global variables hunk ./examples/ch04/Roots.hs 4 -data Roots = Undefined - | RealValued Double Double - | ComplexValued (Complex Double) (Complex Double) +data QuadraticRoots = Undefined + | RealValued Double Double + | ComplexValued (Complex Double) (Complex Double) hunk ./examples/ch04/Roots.hs 8 -roots :: Double -> Double -> Double -> Roots +roots :: Double -> Double -> Double -> QuadraticRoots hunk ./examples/ch04/Roots.hs 26 -isRealValued :: Either (Complex Double, Complex Double) (Double, Double) - -> Bool -isRealValued (Left _) = False -isRealValued _ = True +isRealValued :: Maybe (Double, Double) -> Bool +isRealValued (Just _) = True +isRealValued _ = False }