isIEEE _ = True
instance Show Float where
- showsPrec x = showSigned showFloat x
+ showsPrec x = showSignedFloat showFloat x
showList = showList__ (showsPrec 0)
\end{code}
isIEEE _ = True
instance Show Double where
- showsPrec x = showSigned showFloat x
+ showsPrec x = showSignedFloat showFloat x
showList = showList__ (showsPrec 0)
\end{code}
"realToFrac/Double->Double" realToFrac = id :: Double -> Double
#-}
\end{code}
+
+%*********************************************************
+%* *
+\subsection{Utils}
+%* *
+%*********************************************************
+
+\begin{code}
+showSignedFloat :: (RealFloat a)
+ => (a -> ShowS) -- ^ a function that can show unsigned values
+ -> Int -- ^ the precedence of the enclosing context
+ -> a -- ^ the value to show
+ -> ShowS
+showSignedFloat showPos p x
+ | x < 0 || isNegativeZero x
+ = showParen (p > 6) (showChar '-' . showPos (-x))
+ | otherwise = showPos x
+\end{code}