úÎA³>/      !"#$%&'()*+,-. (c) Henning Thielemann 2007-2010haskell@henning-thielemann.destable Haskell 98Safe"BxInstances of this class must ensure non-negative values. We cannot enforce this by types, but the type class constraint  NonNegative.CC avoids accidental usage of types which allow for negative numbers.9The Monoid superclass contributes a zero and an addition.split x y == (m,(b,d)) means that  b == (x<=y),  m == min x y, d == max x y - min x y , that is  d == abs(x-y).¤We have chosen this function as base function, since it provides comparison and subtraction in one go, which is important for replacing common structures like #if x<=y then f(x-y) else g(y-x)Rthat lead to a memory leak for peano numbers. We have choosen the simple check x<=y instead of a full-blown compare, since we want Zero <= undefined3 for peano numbers. Because of undefined values . is in general not commutative in the sense Nlet (m0,(b0,d0)) = split x y (m1,(b1,d1)) = split y x in m0==m1 && d0==d1ÏThe result values are in the order in which they are generated for Peano numbers. We have chosen the nested pair instead of a triple in order to prevent a memory leak that occurs if you only use b and d and ignore m]. This is demonstrated by test cases Chunky.splitSpaceLeak3 and Chunky.splitSpaceLeak4.,Default implementation for wrapped types of / and 0 class.ILeft biased maximum of a list of numbers that can also be empty. It holds maximum [] == zeroIn 8switchDifferenceNegative x y branchXminusY branchYminusX the function  branchXminusY is applied to x-y/ if this difference is non-negative, otherwise  branchYminusX is applied to y-x.In CswitchDifferenceOrdering x y branchZero branchXminusY branchYminusX  x -| y == max 0 (x-y)pThe default implementation is not efficient, because it compares the values and then subtracts, again, if safe.  max 0 (x-y)K is more elegant and efficient but not possible in the general case, since x-y% may already yield a negative number.   6 (c) Henning Thielemann 2008-2010haskell@henning-thielemann.destable Haskell 98Safe1A ÙA chunky non-negative number is a list of non-negative numbers. It represents the sum of the list elements. It is possible to represent a finite number with infinitely many chunks by using an infinite number of zeros.Note the following problems:>Addition is commutative only for finite representations. E.g. let y = min (1+y) 2 in y is defined, let y = min (y+1) 2 in y is not. <This routine exposes the inner structure of the lazy number.Remove zero chunks.1XThis routine exposes the inner structure of the lazy number and is actually the same as  ¬. It was considered dangerous, but you can observe the lazy structure in tying-the-knot applications anyway. So the explicit revelation of the chunks seems not to be worse.2lThis instance is not correct with respect to the equality check if the involved numbers contain zero chunks. 31 45 (c) Henning Thielemann 2008-2010haskell@henning-thielemann.destable Haskell 98Safe2ï   (c) Henning Thielemann 2007-2010haskell@henning-thielemann.destable Haskell 98Safe> ]Convert a number to a non-negative number. If a negative number is given, an error is raised.ŠConvert a number to a non-negative number. A negative number will be replaced by zero. Use this function with care since it may hide bugs.×Wrap a number into a non-negative number without doing checks. This routine exists entirely for efficiency reasons and must be used only in cases where you are absolutely sure, that the input number is non-negative.6'Results are not checked for positivity.7'Results are not checked for positivity.=name of the calling function to be used in the error message  89:      !"#$%&'()*+,-./0123456*789:;8<=)non-negative-0.1.2-EXUt2er1wE98Q5e7Iin6KGNumeric.NonNegative.ClassNumeric.NonNegative.ChunkyNumeric.NonNegative.Wrapper!Numeric.NonNegative.ChunkyPrivateCsplit splitDefaultzeroaddsummaximumswitchDifferenceNegativeswitchDifferenceOrdering-|T fromChunks fromNumbertoChunkstoNumber normalizeisNull isPositive divModStrictDoubleFloatRationalRatioIntegerInt fromNumberMsgfromNumberClipfromNumberUnsafe $fArbitraryT $fFloatingT $fRealFracT $fFractionalT $fIntegralT $fBoundedT$fEnumT$fRealT$fNumT$fCT $fMonoidT $fSemigroupT$fShowT$fEqT$fOrdTghc-prim GHC.ClassesOrdbaseGHC.NumNumtoChunksUnsafefromChunksUnsafeConsdeconsliftlift2unwrap