module Statistics.Internal (
defaultShow1
, defaultShow2
, defaultReadPrecM1
, defaultReadPrecM2
, Show(..)
, Read(..)
) where
import Control.Applicative
import Control.Monad
import Text.Read
defaultShow1 :: (Show a) => String -> a -> Int -> ShowS
defaultShow1 con a n
= showParen (n >= 11)
( showString con
. showChar ' '
. showsPrec 11 a
)
defaultShow2 :: (Show a, Show b) => String -> a -> b -> Int -> ShowS
defaultShow2 con a b n
= showParen (n >= 11)
( showString con
. showChar ' '
. showsPrec 11 a
. showChar ' '
. showsPrec 11 b
)
defaultReadPrecM1 :: (Read a) => String -> (a -> Maybe r) -> ReadPrec r
defaultReadPrecM1 con f = parens $ prec 10 $ do
expect con
a <- readPrec
maybe empty return $ f a
defaultReadPrecM2 :: (Read a, Read b) => String -> (a -> b -> Maybe r) -> ReadPrec r
defaultReadPrecM2 con f = parens $ prec 10 $ do
expect con
a <- readPrec
b <- readPrec
maybe empty return $ f a b
expect :: String -> ReadPrec ()
expect str = do
Ident s <- lexP
guard (s == str)