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