import Data.Ratio {- Exercise 8.1 -} approx :: (Fractional a, Ord a) => a -> a -> (a, Integer) approx = undefined {- Exercise 8.2 -} data MP = MP String {- Exercise 8.2.1 -} nrmString, negateString :: String -> String nrmString = undefined negateString = undefined {- Exercise 8.2.2 -} instance Show MP where show = undefined instance Eq MP where (==) = undefined {- Exercise 8.2.3 -} instance Num MP where (+) = undefined (*) = undefined negate = undefined signum = undefined abs = undefined fromInteger = undefined fromMP :: MP -> Integer fromMP = undefined -- some tests for Exercise 8.2 corresponding to text -- provided for convenience only test82 = test821 && test822 && test823 test821 = test821ex && test821neg "+-++" && test821nrm "+-++" test821ex = (nrmString "+-+-++" == "++") && (nrmString "-+-+--" == "--") && (nrmString "---++-++" == "") && (negateString "+-+-++" == "-+-+--") && (negateString "-+-+--" == "+-+-++") test821nrm s = let t = nrmString s in nrmString t == t test821neg s = negateString (negateString s) == s test822 = ((MP "+-+-+") == (MP "--+++")) && not ((MP "+-+-+") == (MP "")) && (show (MP "+-+-+") == show "+-+-+") three,four,mfive :: MP three = fromInteger 3 four = fromInteger 4 mfive = fromInteger (-5) test823 = (fromMP ((three + four) * mfive) == -35) && (fromMP (four * (three + mfive)) == -8)