{-# LANGUAGE Safe #-}
module Data.Functor.Classes (
Eq1(..), eq1,
Ord1(..), compare1,
Read1(..), readsPrec1, readPrec1,
liftReadListDefault, liftReadListPrecDefault,
Show1(..), showsPrec1,
Eq2(..), eq2,
Ord2(..), compare2,
Read2(..), readsPrec2, readPrec2,
liftReadList2Default, liftReadListPrec2Default,
Show2(..), showsPrec2,
readsData, readData,
readsUnaryWith, readUnaryWith,
readsBinaryWith, readBinaryWith,
showsUnaryWith,
showsBinaryWith,
readsUnary,
readsUnary1,
readsBinary1,
showsUnary,
showsUnary1,
showsBinary1,
) where
import Control.Applicative (Alternative((<|>)), Const(Const))
import Data.Functor.Identity (Identity(Identity))
import Data.Proxy (Proxy(Proxy))
import Data.List.NonEmpty (NonEmpty(..))
import Data.Ord (Down(Down))
import Data.Complex (Complex((:+)))
import GHC.Tuple (Solo (..))
import GHC.Read (expectP, list, paren)
import Text.ParserCombinators.ReadPrec (ReadPrec, readPrec_to_S, readS_to_Prec)
import Text.Read (Read(..), parens, prec, step)
import Text.Read.Lex (Lexeme(..))
import Text.Show (showListWith)
class Eq1 f where
liftEq :: (a -> b -> Bool) -> f a -> f b -> Bool
eq1 :: (Eq1 f, Eq a) => f a -> f a -> Bool
eq1 :: forall (f :: * -> *) a. (Eq1 f, Eq a) => f a -> f a -> Bool
eq1 = forall (f :: * -> *) a b.
Eq1 f =>
(a -> b -> Bool) -> f a -> f b -> Bool
liftEq forall a. Eq a => a -> a -> Bool
(==)
class (Eq1 f) => Ord1 f where
liftCompare :: (a -> b -> Ordering) -> f a -> f b -> Ordering
compare1 :: (Ord1 f, Ord a) => f a -> f a -> Ordering
compare1 :: forall (f :: * -> *) a. (Ord1 f, Ord a) => f a -> f a -> Ordering
compare1 = forall (f :: * -> *) a b.
Ord1 f =>
(a -> b -> Ordering) -> f a -> f b -> Ordering
liftCompare forall a. Ord a => a -> a -> Ordering
compare
class Read1 f where
{-# MINIMAL liftReadsPrec | liftReadPrec #-}
liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (f a)
liftReadsPrec Int -> ReadS a
rp ReadS [a]
rl = forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S forall a b. (a -> b) -> a -> b
$
forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec (f a)
liftReadPrec (forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec Int -> ReadS a
rp) (forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec (forall a b. a -> b -> a
const ReadS [a]
rl))
liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [f a]
liftReadList Int -> ReadS a
rp ReadS [a]
rl = forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S
(forall a. ReadPrec a -> ReadPrec [a]
list forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec (f a)
liftReadPrec (forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec Int -> ReadS a
rp) (forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec (forall a b. a -> b -> a
const ReadS [a]
rl))) Int
0
liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (f a)
liftReadPrec ReadPrec a
rp ReadPrec [a]
rl = forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec forall a b. (a -> b) -> a -> b
$
forall (f :: * -> *) a.
Read1 f =>
(Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (f a)
liftReadsPrec (forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S ReadPrec a
rp) (forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S ReadPrec [a]
rl Int
0)
liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]
liftReadListPrec ReadPrec a
rp ReadPrec [a]
rl = forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec forall a b. (a -> b) -> a -> b
$ \Int
_ ->
forall (f :: * -> *) a.
Read1 f =>
(Int -> ReadS a) -> ReadS [a] -> ReadS [f a]
liftReadList (forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S ReadPrec a
rp) (forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S ReadPrec [a]
rl Int
0)
readsPrec1 :: (Read1 f, Read a) => Int -> ReadS (f a)
readsPrec1 :: forall (f :: * -> *) a. (Read1 f, Read a) => Int -> ReadS (f a)
readsPrec1 = forall (f :: * -> *) a.
Read1 f =>
(Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (f a)
liftReadsPrec forall a. Read a => Int -> ReadS a
readsPrec forall a. Read a => ReadS [a]
readList
readPrec1 :: (Read1 f, Read a) => ReadPrec (f a)
readPrec1 :: forall (f :: * -> *) a. (Read1 f, Read a) => ReadPrec (f a)
readPrec1 = forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec (f a)
liftReadPrec forall a. Read a => ReadPrec a
readPrec forall a. Read a => ReadPrec [a]
readListPrec
liftReadListDefault :: Read1 f => (Int -> ReadS a) -> ReadS [a] -> ReadS [f a]
liftReadListDefault :: forall (f :: * -> *) a.
Read1 f =>
(Int -> ReadS a) -> ReadS [a] -> ReadS [f a]
liftReadListDefault Int -> ReadS a
rp ReadS [a]
rl = forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S
(forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]
liftReadListPrec (forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec Int -> ReadS a
rp) (forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec (forall a b. a -> b -> a
const ReadS [a]
rl))) Int
0
liftReadListPrecDefault :: Read1 f => ReadPrec a -> ReadPrec [a]
-> ReadPrec [f a]
liftReadListPrecDefault :: forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]
liftReadListPrecDefault ReadPrec a
rp ReadPrec [a]
rl = forall a. ReadPrec a -> ReadPrec [a]
list (forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec (f a)
liftReadPrec ReadPrec a
rp ReadPrec [a]
rl)
class Show1 f where
liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) ->
Int -> f a -> ShowS
liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) ->
[f a] -> ShowS
liftShowList Int -> a -> ShowS
sp [a] -> ShowS
sl = forall a. (a -> ShowS) -> [a] -> ShowS
showListWith (forall (f :: * -> *) a.
Show1 f =>
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS
liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
sl Int
0)
showsPrec1 :: (Show1 f, Show a) => Int -> f a -> ShowS
showsPrec1 :: forall (f :: * -> *) a. (Show1 f, Show a) => Int -> f a -> ShowS
showsPrec1 = forall (f :: * -> *) a.
Show1 f =>
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS
liftShowsPrec forall a. Show a => Int -> a -> ShowS
showsPrec forall a. Show a => [a] -> ShowS
showList
class Eq2 f where
liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool
eq2 :: (Eq2 f, Eq a, Eq b) => f a b -> f a b -> Bool
eq2 :: forall (f :: * -> * -> *) a b.
(Eq2 f, Eq a, Eq b) =>
f a b -> f a b -> Bool
eq2 = forall (f :: * -> * -> *) a b c d.
Eq2 f =>
(a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool
liftEq2 forall a. Eq a => a -> a -> Bool
(==) forall a. Eq a => a -> a -> Bool
(==)
class (Eq2 f) => Ord2 f where
liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) ->
f a c -> f b d -> Ordering
compare2 :: (Ord2 f, Ord a, Ord b) => f a b -> f a b -> Ordering
compare2 :: forall (f :: * -> * -> *) a b.
(Ord2 f, Ord a, Ord b) =>
f a b -> f a b -> Ordering
compare2 = forall (f :: * -> * -> *) a b c d.
Ord2 f =>
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> f a c -> f b d -> Ordering
liftCompare2 forall a. Ord a => a -> a -> Ordering
compare forall a. Ord a => a -> a -> Ordering
compare
class Read2 f where
{-# MINIMAL liftReadsPrec2 | liftReadPrec2 #-}
liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] ->
(Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (f a b)
liftReadsPrec2 Int -> ReadS a
rp1 ReadS [a]
rl1 Int -> ReadS b
rp2 ReadS [b]
rl2 = forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S forall a b. (a -> b) -> a -> b
$
forall (f :: * -> * -> *) a b.
Read2 f =>
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (f a b)
liftReadPrec2 (forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec Int -> ReadS a
rp1) (forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec (forall a b. a -> b -> a
const ReadS [a]
rl1))
(forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec Int -> ReadS b
rp2) (forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec (forall a b. a -> b -> a
const ReadS [b]
rl2))
liftReadList2 :: (Int -> ReadS a) -> ReadS [a] ->
(Int -> ReadS b) -> ReadS [b] -> ReadS [f a b]
liftReadList2 Int -> ReadS a
rp1 ReadS [a]
rl1 Int -> ReadS b
rp2 ReadS [b]
rl2 = forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S
(forall a. ReadPrec a -> ReadPrec [a]
list forall a b. (a -> b) -> a -> b
$ forall (f :: * -> * -> *) a b.
Read2 f =>
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (f a b)
liftReadPrec2 (forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec Int -> ReadS a
rp1) (forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec (forall a b. a -> b -> a
const ReadS [a]
rl1))
(forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec Int -> ReadS b
rp2) (forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec (forall a b. a -> b -> a
const ReadS [b]
rl2))) Int
0
liftReadPrec2 :: ReadPrec a -> ReadPrec [a] ->
ReadPrec b -> ReadPrec [b] -> ReadPrec (f a b)
liftReadPrec2 ReadPrec a
rp1 ReadPrec [a]
rl1 ReadPrec b
rp2 ReadPrec [b]
rl2 = forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec forall a b. (a -> b) -> a -> b
$
forall (f :: * -> * -> *) a b.
Read2 f =>
(Int -> ReadS a)
-> ReadS [a]
-> (Int -> ReadS b)
-> ReadS [b]
-> Int
-> ReadS (f a b)
liftReadsPrec2 (forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S ReadPrec a
rp1) (forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S ReadPrec [a]
rl1 Int
0)
(forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S ReadPrec b
rp2) (forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S ReadPrec [b]
rl2 Int
0)
liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] ->
ReadPrec b -> ReadPrec [b] -> ReadPrec [f a b]
liftReadListPrec2 ReadPrec a
rp1 ReadPrec [a]
rl1 ReadPrec b
rp2 ReadPrec [b]
rl2 = forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec forall a b. (a -> b) -> a -> b
$ \Int
_ ->
forall (f :: * -> * -> *) a b.
Read2 f =>
(Int -> ReadS a)
-> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [f a b]
liftReadList2 (forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S ReadPrec a
rp1) (forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S ReadPrec [a]
rl1 Int
0)
(forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S ReadPrec b
rp2) (forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S ReadPrec [b]
rl2 Int
0)
readsPrec2 :: (Read2 f, Read a, Read b) => Int -> ReadS (f a b)
readsPrec2 :: forall (f :: * -> * -> *) a b.
(Read2 f, Read a, Read b) =>
Int -> ReadS (f a b)
readsPrec2 = forall (f :: * -> * -> *) a b.
Read2 f =>
(Int -> ReadS a)
-> ReadS [a]
-> (Int -> ReadS b)
-> ReadS [b]
-> Int
-> ReadS (f a b)
liftReadsPrec2 forall a. Read a => Int -> ReadS a
readsPrec forall a. Read a => ReadS [a]
readList forall a. Read a => Int -> ReadS a
readsPrec forall a. Read a => ReadS [a]
readList
readPrec2 :: (Read2 f, Read a, Read b) => ReadPrec (f a b)
readPrec2 :: forall (f :: * -> * -> *) a b.
(Read2 f, Read a, Read b) =>
ReadPrec (f a b)
readPrec2 = forall (f :: * -> * -> *) a b.
Read2 f =>
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (f a b)
liftReadPrec2 forall a. Read a => ReadPrec a
readPrec forall a. Read a => ReadPrec [a]
readListPrec forall a. Read a => ReadPrec a
readPrec forall a. Read a => ReadPrec [a]
readListPrec
liftReadList2Default :: Read2 f => (Int -> ReadS a) -> ReadS [a] ->
(Int -> ReadS b) -> ReadS [b] ->ReadS [f a b]
liftReadList2Default :: forall (f :: * -> * -> *) a b.
Read2 f =>
(Int -> ReadS a)
-> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [f a b]
liftReadList2Default Int -> ReadS a
rp1 ReadS [a]
rl1 Int -> ReadS b
rp2 ReadS [b]
rl2 = forall a. ReadPrec a -> Int -> ReadS a
readPrec_to_S
(forall (f :: * -> * -> *) a b.
Read2 f =>
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [f a b]
liftReadListPrec2 (forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec Int -> ReadS a
rp1) (forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec (forall a b. a -> b -> a
const ReadS [a]
rl1))
(forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec Int -> ReadS b
rp2) (forall a. (Int -> ReadS a) -> ReadPrec a
readS_to_Prec (forall a b. a -> b -> a
const ReadS [b]
rl2))) Int
0
liftReadListPrec2Default :: Read2 f => ReadPrec a -> ReadPrec [a] ->
ReadPrec b -> ReadPrec [b] -> ReadPrec [f a b]
liftReadListPrec2Default :: forall (f :: * -> * -> *) a b.
Read2 f =>
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [f a b]
liftReadListPrec2Default ReadPrec a
rp1 ReadPrec [a]
rl1 ReadPrec b
rp2 ReadPrec [b]
rl2 = forall a. ReadPrec a -> ReadPrec [a]
list (forall (f :: * -> * -> *) a b.
Read2 f =>
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (f a b)
liftReadPrec2 ReadPrec a
rp1 ReadPrec [a]
rl1 ReadPrec b
rp2 ReadPrec [b]
rl2)
class Show2 f where
liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) ->
(Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> f a b -> ShowS
liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) ->
(Int -> b -> ShowS) -> ([b] -> ShowS) -> [f a b] -> ShowS
liftShowList2 Int -> a -> ShowS
sp1 [a] -> ShowS
sl1 Int -> b -> ShowS
sp2 [b] -> ShowS
sl2 =
forall a. (a -> ShowS) -> [a] -> ShowS
showListWith (forall (f :: * -> * -> *) a b.
Show2 f =>
(Int -> a -> ShowS)
-> ([a] -> ShowS)
-> (Int -> b -> ShowS)
-> ([b] -> ShowS)
-> Int
-> f a b
-> ShowS
liftShowsPrec2 Int -> a -> ShowS
sp1 [a] -> ShowS
sl1 Int -> b -> ShowS
sp2 [b] -> ShowS
sl2 Int
0)
showsPrec2 :: (Show2 f, Show a, Show b) => Int -> f a b -> ShowS
showsPrec2 :: forall (f :: * -> * -> *) a b.
(Show2 f, Show a, Show b) =>
Int -> f a b -> ShowS
showsPrec2 = forall (f :: * -> * -> *) a b.
Show2 f =>
(Int -> a -> ShowS)
-> ([a] -> ShowS)
-> (Int -> b -> ShowS)
-> ([b] -> ShowS)
-> Int
-> f a b
-> ShowS
liftShowsPrec2 forall a. Show a => Int -> a -> ShowS
showsPrec forall a. Show a => [a] -> ShowS
showList forall a. Show a => Int -> a -> ShowS
showsPrec forall a. Show a => [a] -> ShowS
showList
instance Eq1 Maybe where
liftEq :: forall a b. (a -> b -> Bool) -> Maybe a -> Maybe b -> Bool
liftEq a -> b -> Bool
_ Maybe a
Nothing Maybe b
Nothing = Bool
True
liftEq a -> b -> Bool
_ Maybe a
Nothing (Just b
_) = Bool
False
liftEq a -> b -> Bool
_ (Just a
_) Maybe b
Nothing = Bool
False
liftEq a -> b -> Bool
eq (Just a
x) (Just b
y) = a -> b -> Bool
eq a
x b
y
instance Ord1 Maybe where
liftCompare :: forall a b. (a -> b -> Ordering) -> Maybe a -> Maybe b -> Ordering
liftCompare a -> b -> Ordering
_ Maybe a
Nothing Maybe b
Nothing = Ordering
EQ
liftCompare a -> b -> Ordering
_ Maybe a
Nothing (Just b
_) = Ordering
LT
liftCompare a -> b -> Ordering
_ (Just a
_) Maybe b
Nothing = Ordering
GT
liftCompare a -> b -> Ordering
comp (Just a
x) (Just b
y) = a -> b -> Ordering
comp a
x b
y
instance Read1 Maybe where
liftReadPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec (Maybe a)
liftReadPrec ReadPrec a
rp ReadPrec [a]
_ =
forall a. ReadPrec a -> ReadPrec a
parens (Lexeme -> ReadPrec ()
expectP (String -> Lexeme
Ident String
"Nothing") forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Maybe a
Nothing)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
forall a. ReadPrec a -> ReadPrec a
readData (forall a t. ReadPrec a -> String -> (a -> t) -> ReadPrec t
readUnaryWith ReadPrec a
rp String
"Just" forall a. a -> Maybe a
Just)
liftReadListPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec [Maybe a]
liftReadListPrec = forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]
liftReadListPrecDefault
liftReadList :: forall a. (Int -> ReadS a) -> ReadS [a] -> ReadS [Maybe a]
liftReadList = forall (f :: * -> *) a.
Read1 f =>
(Int -> ReadS a) -> ReadS [a] -> ReadS [f a]
liftReadListDefault
instance Show1 Maybe where
liftShowsPrec :: forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Maybe a -> ShowS
liftShowsPrec Int -> a -> ShowS
_ [a] -> ShowS
_ Int
_ Maybe a
Nothing = String -> ShowS
showString String
"Nothing"
liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (Just a
x) = forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp String
"Just" Int
d a
x
instance Eq1 [] where
liftEq :: forall a b. (a -> b -> Bool) -> [a] -> [b] -> Bool
liftEq a -> b -> Bool
_ [] [] = Bool
True
liftEq a -> b -> Bool
_ [] (b
_:[b]
_) = Bool
False
liftEq a -> b -> Bool
_ (a
_:[a]
_) [] = Bool
False
liftEq a -> b -> Bool
eq (a
x:[a]
xs) (b
y:[b]
ys) = a -> b -> Bool
eq a
x b
y Bool -> Bool -> Bool
&& forall (f :: * -> *) a b.
Eq1 f =>
(a -> b -> Bool) -> f a -> f b -> Bool
liftEq a -> b -> Bool
eq [a]
xs [b]
ys
instance Ord1 [] where
liftCompare :: forall a b. (a -> b -> Ordering) -> [a] -> [b] -> Ordering
liftCompare a -> b -> Ordering
_ [] [] = Ordering
EQ
liftCompare a -> b -> Ordering
_ [] (b
_:[b]
_) = Ordering
LT
liftCompare a -> b -> Ordering
_ (a
_:[a]
_) [] = Ordering
GT
liftCompare a -> b -> Ordering
comp (a
x:[a]
xs) (b
y:[b]
ys) = a -> b -> Ordering
comp a
x b
y forall a. Monoid a => a -> a -> a
`mappend` forall (f :: * -> *) a b.
Ord1 f =>
(a -> b -> Ordering) -> f a -> f b -> Ordering
liftCompare a -> b -> Ordering
comp [a]
xs [b]
ys
instance Read1 [] where
liftReadPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec [a]
liftReadPrec ReadPrec a
_ ReadPrec [a]
rl = ReadPrec [a]
rl
liftReadListPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec [[a]]
liftReadListPrec = forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]
liftReadListPrecDefault
liftReadList :: forall a. (Int -> ReadS a) -> ReadS [a] -> ReadS [[a]]
liftReadList = forall (f :: * -> *) a.
Read1 f =>
(Int -> ReadS a) -> ReadS [a] -> ReadS [f a]
liftReadListDefault
instance Show1 [] where
liftShowsPrec :: forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> [a] -> ShowS
liftShowsPrec Int -> a -> ShowS
_ [a] -> ShowS
sl Int
_ = [a] -> ShowS
sl
instance Eq1 NonEmpty where
liftEq :: forall a b. (a -> b -> Bool) -> NonEmpty a -> NonEmpty b -> Bool
liftEq a -> b -> Bool
eq (a
a :| [a]
as) (b
b :| [b]
bs) = a -> b -> Bool
eq a
a b
b Bool -> Bool -> Bool
&& forall (f :: * -> *) a b.
Eq1 f =>
(a -> b -> Bool) -> f a -> f b -> Bool
liftEq a -> b -> Bool
eq [a]
as [b]
bs
instance Ord1 NonEmpty where
liftCompare :: forall a b.
(a -> b -> Ordering) -> NonEmpty a -> NonEmpty b -> Ordering
liftCompare a -> b -> Ordering
cmp (a
a :| [a]
as) (b
b :| [b]
bs) = a -> b -> Ordering
cmp a
a b
b forall a. Monoid a => a -> a -> a
`mappend` forall (f :: * -> *) a b.
Ord1 f =>
(a -> b -> Ordering) -> f a -> f b -> Ordering
liftCompare a -> b -> Ordering
cmp [a]
as [b]
bs
instance Read1 NonEmpty where
liftReadsPrec :: forall a.
(Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (NonEmpty a)
liftReadsPrec Int -> ReadS a
rdP ReadS [a]
rdL Int
p String
s = forall a. Bool -> ReadS a -> ReadS a
readParen (Int
p forall a. Ord a => a -> a -> Bool
> Int
5) (\String
s' -> do
(a
a, String
s'') <- Int -> ReadS a
rdP Int
6 String
s'
(String
":|", String
s''') <- ReadS String
lex String
s''
([a]
as, String
s'''') <- ReadS [a]
rdL String
s'''
forall (m :: * -> *) a. Monad m => a -> m a
return (a
a forall a. a -> [a] -> NonEmpty a
:| [a]
as, String
s'''')) String
s
instance Show1 NonEmpty where
liftShowsPrec :: forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> NonEmpty a -> ShowS
liftShowsPrec Int -> a -> ShowS
shwP [a] -> ShowS
shwL Int
p (a
a :| [a]
as) = Bool -> ShowS -> ShowS
showParen (Int
p forall a. Ord a => a -> a -> Bool
> Int
5) forall a b. (a -> b) -> a -> b
$
Int -> a -> ShowS
shwP Int
6 a
a forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" :| " forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> ShowS
shwL [a]
as
instance Eq2 (,) where
liftEq2 :: forall a b c d.
(a -> b -> Bool) -> (c -> d -> Bool) -> (a, c) -> (b, d) -> Bool
liftEq2 a -> b -> Bool
e1 c -> d -> Bool
e2 (a
x1, c
y1) (b
x2, d
y2) = a -> b -> Bool
e1 a
x1 b
x2 Bool -> Bool -> Bool
&& c -> d -> Bool
e2 c
y1 d
y2
instance Ord2 (,) where
liftCompare2 :: forall a b c d.
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> (a, c) -> (b, d) -> Ordering
liftCompare2 a -> b -> Ordering
comp1 c -> d -> Ordering
comp2 (a
x1, c
y1) (b
x2, d
y2) =
a -> b -> Ordering
comp1 a
x1 b
x2 forall a. Monoid a => a -> a -> a
`mappend` c -> d -> Ordering
comp2 c
y1 d
y2
instance Read2 (,) where
liftReadPrec2 :: forall a b.
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (a, b)
liftReadPrec2 ReadPrec a
rp1 ReadPrec [a]
_ ReadPrec b
rp2 ReadPrec [b]
_ = forall a. ReadPrec a -> ReadPrec a
parens forall a b. (a -> b) -> a -> b
$ forall a. ReadPrec a -> ReadPrec a
paren forall a b. (a -> b) -> a -> b
$ do
a
x <- ReadPrec a
rp1
Lexeme -> ReadPrec ()
expectP (String -> Lexeme
Punc String
",")
b
y <- ReadPrec b
rp2
forall (m :: * -> *) a. Monad m => a -> m a
return (a
x,b
y)
liftReadListPrec2 :: forall a b.
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [(a, b)]
liftReadListPrec2 = forall (f :: * -> * -> *) a b.
Read2 f =>
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [f a b]
liftReadListPrec2Default
liftReadList2 :: forall a b.
(Int -> ReadS a)
-> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [(a, b)]
liftReadList2 = forall (f :: * -> * -> *) a b.
Read2 f =>
(Int -> ReadS a)
-> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [f a b]
liftReadList2Default
instance Show2 (,) where
liftShowsPrec2 :: forall a b.
(Int -> a -> ShowS)
-> ([a] -> ShowS)
-> (Int -> b -> ShowS)
-> ([b] -> ShowS)
-> Int
-> (a, b)
-> ShowS
liftShowsPrec2 Int -> a -> ShowS
sp1 [a] -> ShowS
_ Int -> b -> ShowS
sp2 [b] -> ShowS
_ Int
_ (a
x, b
y) =
Char -> ShowS
showChar Char
'(' forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> ShowS
sp1 Int
0 a
x forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
',' forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> b -> ShowS
sp2 Int
0 b
y forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
')'
instance Eq1 Solo where
liftEq :: forall a b. (a -> b -> Bool) -> Solo a -> Solo b -> Bool
liftEq a -> b -> Bool
eq (Solo a
a) (Solo b
b) = a
a a -> b -> Bool
`eq` b
b
instance (Eq a) => Eq1 ((,) a) where
liftEq :: forall a b. (a -> b -> Bool) -> (a, a) -> (a, b) -> Bool
liftEq = forall (f :: * -> * -> *) a b c d.
Eq2 f =>
(a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool
liftEq2 forall a. Eq a => a -> a -> Bool
(==)
instance Ord1 Solo where
liftCompare :: forall a b. (a -> b -> Ordering) -> Solo a -> Solo b -> Ordering
liftCompare a -> b -> Ordering
cmp (Solo a
a) (Solo b
b) = a -> b -> Ordering
cmp a
a b
b
instance (Ord a) => Ord1 ((,) a) where
liftCompare :: forall a b. (a -> b -> Ordering) -> (a, a) -> (a, b) -> Ordering
liftCompare = forall (f :: * -> * -> *) a b c d.
Ord2 f =>
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> f a c -> f b d -> Ordering
liftCompare2 forall a. Ord a => a -> a -> Ordering
compare
instance Read1 Solo where
liftReadPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec (Solo a)
liftReadPrec ReadPrec a
rp ReadPrec [a]
_ = forall a. ReadPrec a -> ReadPrec a
readData (forall a t. ReadPrec a -> String -> (a -> t) -> ReadPrec t
readUnaryWith ReadPrec a
rp String
"Solo" forall a. a -> Solo a
Solo)
liftReadListPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec [Solo a]
liftReadListPrec = forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]
liftReadListPrecDefault
liftReadList :: forall a. (Int -> ReadS a) -> ReadS [a] -> ReadS [Solo a]
liftReadList = forall (f :: * -> *) a.
Read1 f =>
(Int -> ReadS a) -> ReadS [a] -> ReadS [f a]
liftReadListDefault
instance (Read a) => Read1 ((,) a) where
liftReadPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec (a, a)
liftReadPrec = forall (f :: * -> * -> *) a b.
Read2 f =>
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (f a b)
liftReadPrec2 forall a. Read a => ReadPrec a
readPrec forall a. Read a => ReadPrec [a]
readListPrec
liftReadListPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec [(a, a)]
liftReadListPrec = forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]
liftReadListPrecDefault
liftReadList :: forall a. (Int -> ReadS a) -> ReadS [a] -> ReadS [(a, a)]
liftReadList = forall (f :: * -> *) a.
Read1 f =>
(Int -> ReadS a) -> ReadS [a] -> ReadS [f a]
liftReadListDefault
instance Show1 Solo where
liftShowsPrec :: forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Solo a -> ShowS
liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (Solo a
x) = forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp String
"Solo" Int
d a
x
instance (Show a) => Show1 ((,) a) where
liftShowsPrec :: forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> (a, a) -> ShowS
liftShowsPrec = forall (f :: * -> * -> *) a b.
Show2 f =>
(Int -> a -> ShowS)
-> ([a] -> ShowS)
-> (Int -> b -> ShowS)
-> ([b] -> ShowS)
-> Int
-> f a b
-> ShowS
liftShowsPrec2 forall a. Show a => Int -> a -> ShowS
showsPrec forall a. Show a => [a] -> ShowS
showList
instance Eq a => Eq2 ((,,) a) where
liftEq2 :: forall a b c d.
(a -> b -> Bool)
-> (c -> d -> Bool) -> (a, a, c) -> (a, b, d) -> Bool
liftEq2 a -> b -> Bool
e1 c -> d -> Bool
e2 (a
u1, a
x1, c
y1) (a
v1, b
x2, d
y2) =
a
u1 forall a. Eq a => a -> a -> Bool
== a
v1 Bool -> Bool -> Bool
&&
a -> b -> Bool
e1 a
x1 b
x2 Bool -> Bool -> Bool
&& c -> d -> Bool
e2 c
y1 d
y2
instance Ord a => Ord2 ((,,) a) where
liftCompare2 :: forall a b c d.
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> (a, a, c) -> (a, b, d) -> Ordering
liftCompare2 a -> b -> Ordering
comp1 c -> d -> Ordering
comp2 (a
u1, a
x1, c
y1) (a
v1, b
x2, d
y2) =
forall a. Ord a => a -> a -> Ordering
compare a
u1 a
v1 forall a. Monoid a => a -> a -> a
`mappend`
a -> b -> Ordering
comp1 a
x1 b
x2 forall a. Monoid a => a -> a -> a
`mappend` c -> d -> Ordering
comp2 c
y1 d
y2
instance Read a => Read2 ((,,) a) where
liftReadPrec2 :: forall a b.
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (a, a, b)
liftReadPrec2 ReadPrec a
rp1 ReadPrec [a]
_ ReadPrec b
rp2 ReadPrec [b]
_ = forall a. ReadPrec a -> ReadPrec a
parens forall a b. (a -> b) -> a -> b
$ forall a. ReadPrec a -> ReadPrec a
paren forall a b. (a -> b) -> a -> b
$ do
a
x1 <- forall a. Read a => ReadPrec a
readPrec
Lexeme -> ReadPrec ()
expectP (String -> Lexeme
Punc String
",")
a
y1 <- ReadPrec a
rp1
Lexeme -> ReadPrec ()
expectP (String -> Lexeme
Punc String
",")
b
y2 <- ReadPrec b
rp2
forall (m :: * -> *) a. Monad m => a -> m a
return (a
x1,a
y1,b
y2)
liftReadListPrec2 :: forall a b.
ReadPrec a
-> ReadPrec [a]
-> ReadPrec b
-> ReadPrec [b]
-> ReadPrec [(a, a, b)]
liftReadListPrec2 = forall (f :: * -> * -> *) a b.
Read2 f =>
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [f a b]
liftReadListPrec2Default
liftReadList2 :: forall a b.
(Int -> ReadS a)
-> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [(a, a, b)]
liftReadList2 = forall (f :: * -> * -> *) a b.
Read2 f =>
(Int -> ReadS a)
-> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [f a b]
liftReadList2Default
instance Show a => Show2 ((,,) a) where
liftShowsPrec2 :: forall a b.
(Int -> a -> ShowS)
-> ([a] -> ShowS)
-> (Int -> b -> ShowS)
-> ([b] -> ShowS)
-> Int
-> (a, a, b)
-> ShowS
liftShowsPrec2 Int -> a -> ShowS
sp1 [a] -> ShowS
_ Int -> b -> ShowS
sp2 [b] -> ShowS
_ Int
_ (a
x1,a
y1,b
y2)
= Char -> ShowS
showChar Char
'(' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => Int -> a -> ShowS
showsPrec Int
0 a
x1
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
',' forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> ShowS
sp1 Int
0 a
y1
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
',' forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> b -> ShowS
sp2 Int
0 b
y2
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
')'
instance (Eq a, Eq b) => Eq1 ((,,) a b) where
liftEq :: forall a b. (a -> b -> Bool) -> (a, b, a) -> (a, b, b) -> Bool
liftEq = forall (f :: * -> * -> *) a b c d.
Eq2 f =>
(a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool
liftEq2 forall a. Eq a => a -> a -> Bool
(==)
instance (Ord a, Ord b) => Ord1 ((,,) a b) where
liftCompare :: forall a b.
(a -> b -> Ordering) -> (a, b, a) -> (a, b, b) -> Ordering
liftCompare = forall (f :: * -> * -> *) a b c d.
Ord2 f =>
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> f a c -> f b d -> Ordering
liftCompare2 forall a. Ord a => a -> a -> Ordering
compare
instance (Read a, Read b) => Read1 ((,,) a b) where
liftReadPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec (a, b, a)
liftReadPrec = forall (f :: * -> * -> *) a b.
Read2 f =>
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (f a b)
liftReadPrec2 forall a. Read a => ReadPrec a
readPrec forall a. Read a => ReadPrec [a]
readListPrec
liftReadListPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec [(a, b, a)]
liftReadListPrec = forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]
liftReadListPrecDefault
liftReadList :: forall a. (Int -> ReadS a) -> ReadS [a] -> ReadS [(a, b, a)]
liftReadList = forall (f :: * -> *) a.
Read1 f =>
(Int -> ReadS a) -> ReadS [a] -> ReadS [f a]
liftReadListDefault
instance (Show a, Show b) => Show1 ((,,) a b) where
liftShowsPrec :: forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> (a, b, a) -> ShowS
liftShowsPrec = forall (f :: * -> * -> *) a b.
Show2 f =>
(Int -> a -> ShowS)
-> ([a] -> ShowS)
-> (Int -> b -> ShowS)
-> ([b] -> ShowS)
-> Int
-> f a b
-> ShowS
liftShowsPrec2 forall a. Show a => Int -> a -> ShowS
showsPrec forall a. Show a => [a] -> ShowS
showList
instance (Eq a, Eq b) => Eq2 ((,,,) a b) where
liftEq2 :: forall a b c d.
(a -> b -> Bool)
-> (c -> d -> Bool) -> (a, b, a, c) -> (a, b, b, d) -> Bool
liftEq2 a -> b -> Bool
e1 c -> d -> Bool
e2 (a
u1, b
u2, a
x1, c
y1) (a
v1, b
v2, b
x2, d
y2) =
a
u1 forall a. Eq a => a -> a -> Bool
== a
v1 Bool -> Bool -> Bool
&&
b
u2 forall a. Eq a => a -> a -> Bool
== b
v2 Bool -> Bool -> Bool
&&
a -> b -> Bool
e1 a
x1 b
x2 Bool -> Bool -> Bool
&& c -> d -> Bool
e2 c
y1 d
y2
instance (Ord a, Ord b) => Ord2 ((,,,) a b) where
liftCompare2 :: forall a b c d.
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> (a, b, a, c) -> (a, b, b, d) -> Ordering
liftCompare2 a -> b -> Ordering
comp1 c -> d -> Ordering
comp2 (a
u1, b
u2, a
x1, c
y1) (a
v1, b
v2, b
x2, d
y2) =
forall a. Ord a => a -> a -> Ordering
compare a
u1 a
v1 forall a. Monoid a => a -> a -> a
`mappend`
forall a. Ord a => a -> a -> Ordering
compare b
u2 b
v2 forall a. Monoid a => a -> a -> a
`mappend`
a -> b -> Ordering
comp1 a
x1 b
x2 forall a. Monoid a => a -> a -> a
`mappend` c -> d -> Ordering
comp2 c
y1 d
y2
instance (Read a, Read b) => Read2 ((,,,) a b) where
liftReadPrec2 :: forall a b.
ReadPrec a
-> ReadPrec [a]
-> ReadPrec b
-> ReadPrec [b]
-> ReadPrec (a, b, a, b)
liftReadPrec2 ReadPrec a
rp1 ReadPrec [a]
_ ReadPrec b
rp2 ReadPrec [b]
_ = forall a. ReadPrec a -> ReadPrec a
parens forall a b. (a -> b) -> a -> b
$ forall a. ReadPrec a -> ReadPrec a
paren forall a b. (a -> b) -> a -> b
$ do
a
x1 <- forall a. Read a => ReadPrec a
readPrec
Lexeme -> ReadPrec ()
expectP (String -> Lexeme
Punc String
",")
b
x2 <- forall a. Read a => ReadPrec a
readPrec
Lexeme -> ReadPrec ()
expectP (String -> Lexeme
Punc String
",")
a
y1 <- ReadPrec a
rp1
Lexeme -> ReadPrec ()
expectP (String -> Lexeme
Punc String
",")
b
y2 <- ReadPrec b
rp2
forall (m :: * -> *) a. Monad m => a -> m a
return (a
x1,b
x2,a
y1,b
y2)
liftReadListPrec2 :: forall a b.
ReadPrec a
-> ReadPrec [a]
-> ReadPrec b
-> ReadPrec [b]
-> ReadPrec [(a, b, a, b)]
liftReadListPrec2 = forall (f :: * -> * -> *) a b.
Read2 f =>
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [f a b]
liftReadListPrec2Default
liftReadList2 :: forall a b.
(Int -> ReadS a)
-> ReadS [a]
-> (Int -> ReadS b)
-> ReadS [b]
-> ReadS [(a, b, a, b)]
liftReadList2 = forall (f :: * -> * -> *) a b.
Read2 f =>
(Int -> ReadS a)
-> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [f a b]
liftReadList2Default
instance (Show a, Show b) => Show2 ((,,,) a b) where
liftShowsPrec2 :: forall a b.
(Int -> a -> ShowS)
-> ([a] -> ShowS)
-> (Int -> b -> ShowS)
-> ([b] -> ShowS)
-> Int
-> (a, b, a, b)
-> ShowS
liftShowsPrec2 Int -> a -> ShowS
sp1 [a] -> ShowS
_ Int -> b -> ShowS
sp2 [b] -> ShowS
_ Int
_ (a
x1,b
x2,a
y1,b
y2)
= Char -> ShowS
showChar Char
'(' forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => Int -> a -> ShowS
showsPrec Int
0 a
x1
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
0 b
x2
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
',' forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> ShowS
sp1 Int
0 a
y1
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
',' forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> b -> ShowS
sp2 Int
0 b
y2
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
')'
instance (Eq a, Eq b, Eq c) => Eq1 ((,,,) a b c) where
liftEq :: forall a b.
(a -> b -> Bool) -> (a, b, c, a) -> (a, b, c, b) -> Bool
liftEq = forall (f :: * -> * -> *) a b c d.
Eq2 f =>
(a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool
liftEq2 forall a. Eq a => a -> a -> Bool
(==)
instance (Ord a, Ord b, Ord c) => Ord1 ((,,,) a b c) where
liftCompare :: forall a b.
(a -> b -> Ordering) -> (a, b, c, a) -> (a, b, c, b) -> Ordering
liftCompare = forall (f :: * -> * -> *) a b c d.
Ord2 f =>
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> f a c -> f b d -> Ordering
liftCompare2 forall a. Ord a => a -> a -> Ordering
compare
instance (Read a, Read b, Read c) => Read1 ((,,,) a b c) where
liftReadPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec (a, b, c, a)
liftReadPrec = forall (f :: * -> * -> *) a b.
Read2 f =>
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (f a b)
liftReadPrec2 forall a. Read a => ReadPrec a
readPrec forall a. Read a => ReadPrec [a]
readListPrec
liftReadListPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec [(a, b, c, a)]
liftReadListPrec = forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]
liftReadListPrecDefault
liftReadList :: forall a. (Int -> ReadS a) -> ReadS [a] -> ReadS [(a, b, c, a)]
liftReadList = forall (f :: * -> *) a.
Read1 f =>
(Int -> ReadS a) -> ReadS [a] -> ReadS [f a]
liftReadListDefault
instance (Show a, Show b, Show c) => Show1 ((,,,) a b c) where
liftShowsPrec :: forall a.
(Int -> a -> ShowS)
-> ([a] -> ShowS) -> Int -> (a, b, c, a) -> ShowS
liftShowsPrec = forall (f :: * -> * -> *) a b.
Show2 f =>
(Int -> a -> ShowS)
-> ([a] -> ShowS)
-> (Int -> b -> ShowS)
-> ([b] -> ShowS)
-> Int
-> f a b
-> ShowS
liftShowsPrec2 forall a. Show a => Int -> a -> ShowS
showsPrec forall a. Show a => [a] -> ShowS
showList
instance Eq2 Either where
liftEq2 :: forall a b c d.
(a -> b -> Bool)
-> (c -> d -> Bool) -> Either a c -> Either b d -> Bool
liftEq2 a -> b -> Bool
e1 c -> d -> Bool
_ (Left a
x) (Left b
y) = a -> b -> Bool
e1 a
x b
y
liftEq2 a -> b -> Bool
_ c -> d -> Bool
_ (Left a
_) (Right d
_) = Bool
False
liftEq2 a -> b -> Bool
_ c -> d -> Bool
_ (Right c
_) (Left b
_) = Bool
False
liftEq2 a -> b -> Bool
_ c -> d -> Bool
e2 (Right c
x) (Right d
y) = c -> d -> Bool
e2 c
x d
y
instance Ord2 Either where
liftCompare2 :: forall a b c d.
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> Either a c -> Either b d -> Ordering
liftCompare2 a -> b -> Ordering
comp1 c -> d -> Ordering
_ (Left a
x) (Left b
y) = a -> b -> Ordering
comp1 a
x b
y
liftCompare2 a -> b -> Ordering
_ c -> d -> Ordering
_ (Left a
_) (Right d
_) = Ordering
LT
liftCompare2 a -> b -> Ordering
_ c -> d -> Ordering
_ (Right c
_) (Left b
_) = Ordering
GT
liftCompare2 a -> b -> Ordering
_ c -> d -> Ordering
comp2 (Right c
x) (Right d
y) = c -> d -> Ordering
comp2 c
x d
y
instance Read2 Either where
liftReadPrec2 :: forall a b.
ReadPrec a
-> ReadPrec [a]
-> ReadPrec b
-> ReadPrec [b]
-> ReadPrec (Either a b)
liftReadPrec2 ReadPrec a
rp1 ReadPrec [a]
_ ReadPrec b
rp2 ReadPrec [b]
_ = forall a. ReadPrec a -> ReadPrec a
readData forall a b. (a -> b) -> a -> b
$
forall a t. ReadPrec a -> String -> (a -> t) -> ReadPrec t
readUnaryWith ReadPrec a
rp1 String
"Left" forall a b. a -> Either a b
Left forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
forall a t. ReadPrec a -> String -> (a -> t) -> ReadPrec t
readUnaryWith ReadPrec b
rp2 String
"Right" forall a b. b -> Either a b
Right
liftReadListPrec2 :: forall a b.
ReadPrec a
-> ReadPrec [a]
-> ReadPrec b
-> ReadPrec [b]
-> ReadPrec [Either a b]
liftReadListPrec2 = forall (f :: * -> * -> *) a b.
Read2 f =>
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [f a b]
liftReadListPrec2Default
liftReadList2 :: forall a b.
(Int -> ReadS a)
-> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Either a b]
liftReadList2 = forall (f :: * -> * -> *) a b.
Read2 f =>
(Int -> ReadS a)
-> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [f a b]
liftReadList2Default
instance Show2 Either where
liftShowsPrec2 :: forall a b.
(Int -> a -> ShowS)
-> ([a] -> ShowS)
-> (Int -> b -> ShowS)
-> ([b] -> ShowS)
-> Int
-> Either a b
-> ShowS
liftShowsPrec2 Int -> a -> ShowS
sp1 [a] -> ShowS
_ Int -> b -> ShowS
_ [b] -> ShowS
_ Int
d (Left a
x) = forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp1 String
"Left" Int
d a
x
liftShowsPrec2 Int -> a -> ShowS
_ [a] -> ShowS
_ Int -> b -> ShowS
sp2 [b] -> ShowS
_ Int
d (Right b
x) = forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> b -> ShowS
sp2 String
"Right" Int
d b
x
instance (Eq a) => Eq1 (Either a) where
liftEq :: forall a b. (a -> b -> Bool) -> Either a a -> Either a b -> Bool
liftEq = forall (f :: * -> * -> *) a b c d.
Eq2 f =>
(a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool
liftEq2 forall a. Eq a => a -> a -> Bool
(==)
instance (Ord a) => Ord1 (Either a) where
liftCompare :: forall a b.
(a -> b -> Ordering) -> Either a a -> Either a b -> Ordering
liftCompare = forall (f :: * -> * -> *) a b c d.
Ord2 f =>
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> f a c -> f b d -> Ordering
liftCompare2 forall a. Ord a => a -> a -> Ordering
compare
instance (Read a) => Read1 (Either a) where
liftReadPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec (Either a a)
liftReadPrec = forall (f :: * -> * -> *) a b.
Read2 f =>
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (f a b)
liftReadPrec2 forall a. Read a => ReadPrec a
readPrec forall a. Read a => ReadPrec [a]
readListPrec
liftReadListPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec [Either a a]
liftReadListPrec = forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]
liftReadListPrecDefault
liftReadList :: forall a. (Int -> ReadS a) -> ReadS [a] -> ReadS [Either a a]
liftReadList = forall (f :: * -> *) a.
Read1 f =>
(Int -> ReadS a) -> ReadS [a] -> ReadS [f a]
liftReadListDefault
instance (Show a) => Show1 (Either a) where
liftShowsPrec :: forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Either a a -> ShowS
liftShowsPrec = forall (f :: * -> * -> *) a b.
Show2 f =>
(Int -> a -> ShowS)
-> ([a] -> ShowS)
-> (Int -> b -> ShowS)
-> ([b] -> ShowS)
-> Int
-> f a b
-> ShowS
liftShowsPrec2 forall a. Show a => Int -> a -> ShowS
showsPrec forall a. Show a => [a] -> ShowS
showList
instance Eq1 Identity where
liftEq :: forall a b. (a -> b -> Bool) -> Identity a -> Identity b -> Bool
liftEq a -> b -> Bool
eq (Identity a
x) (Identity b
y) = a -> b -> Bool
eq a
x b
y
instance Ord1 Identity where
liftCompare :: forall a b.
(a -> b -> Ordering) -> Identity a -> Identity b -> Ordering
liftCompare a -> b -> Ordering
comp (Identity a
x) (Identity b
y) = a -> b -> Ordering
comp a
x b
y
instance Read1 Identity where
liftReadPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec (Identity a)
liftReadPrec ReadPrec a
rp ReadPrec [a]
_ = forall a. ReadPrec a -> ReadPrec a
readData forall a b. (a -> b) -> a -> b
$
forall a t. ReadPrec a -> String -> (a -> t) -> ReadPrec t
readUnaryWith ReadPrec a
rp String
"Identity" forall a. a -> Identity a
Identity
liftReadListPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec [Identity a]
liftReadListPrec = forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]
liftReadListPrecDefault
liftReadList :: forall a. (Int -> ReadS a) -> ReadS [a] -> ReadS [Identity a]
liftReadList = forall (f :: * -> *) a.
Read1 f =>
(Int -> ReadS a) -> ReadS [a] -> ReadS [f a]
liftReadListDefault
instance Show1 Identity where
liftShowsPrec :: forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Identity a -> ShowS
liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (Identity a
x) = forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp String
"Identity" Int
d a
x
instance Eq2 Const where
liftEq2 :: forall a b c d.
(a -> b -> Bool)
-> (c -> d -> Bool) -> Const a c -> Const b d -> Bool
liftEq2 a -> b -> Bool
eq c -> d -> Bool
_ (Const a
x) (Const b
y) = a -> b -> Bool
eq a
x b
y
instance Ord2 Const where
liftCompare2 :: forall a b c d.
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> Const a c -> Const b d -> Ordering
liftCompare2 a -> b -> Ordering
comp c -> d -> Ordering
_ (Const a
x) (Const b
y) = a -> b -> Ordering
comp a
x b
y
instance Read2 Const where
liftReadPrec2 :: forall a b.
ReadPrec a
-> ReadPrec [a]
-> ReadPrec b
-> ReadPrec [b]
-> ReadPrec (Const a b)
liftReadPrec2 ReadPrec a
rp ReadPrec [a]
_ ReadPrec b
_ ReadPrec [b]
_ = forall a. ReadPrec a -> ReadPrec a
readData forall a b. (a -> b) -> a -> b
$
forall a t. ReadPrec a -> String -> (a -> t) -> ReadPrec t
readUnaryWith ReadPrec a
rp String
"Const" forall {k} a (b :: k). a -> Const a b
Const
liftReadListPrec2 :: forall a b.
ReadPrec a
-> ReadPrec [a]
-> ReadPrec b
-> ReadPrec [b]
-> ReadPrec [Const a b]
liftReadListPrec2 = forall (f :: * -> * -> *) a b.
Read2 f =>
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [f a b]
liftReadListPrec2Default
liftReadList2 :: forall a b.
(Int -> ReadS a)
-> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [Const a b]
liftReadList2 = forall (f :: * -> * -> *) a b.
Read2 f =>
(Int -> ReadS a)
-> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [f a b]
liftReadList2Default
instance Show2 Const where
liftShowsPrec2 :: forall a b.
(Int -> a -> ShowS)
-> ([a] -> ShowS)
-> (Int -> b -> ShowS)
-> ([b] -> ShowS)
-> Int
-> Const a b
-> ShowS
liftShowsPrec2 Int -> a -> ShowS
sp [a] -> ShowS
_ Int -> b -> ShowS
_ [b] -> ShowS
_ Int
d (Const a
x) = forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp String
"Const" Int
d a
x
instance (Eq a) => Eq1 (Const a) where
liftEq :: forall a b. (a -> b -> Bool) -> Const a a -> Const a b -> Bool
liftEq = forall (f :: * -> * -> *) a b c d.
Eq2 f =>
(a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool
liftEq2 forall a. Eq a => a -> a -> Bool
(==)
instance (Ord a) => Ord1 (Const a) where
liftCompare :: forall a b.
(a -> b -> Ordering) -> Const a a -> Const a b -> Ordering
liftCompare = forall (f :: * -> * -> *) a b c d.
Ord2 f =>
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> f a c -> f b d -> Ordering
liftCompare2 forall a. Ord a => a -> a -> Ordering
compare
instance (Read a) => Read1 (Const a) where
liftReadPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec (Const a a)
liftReadPrec = forall (f :: * -> * -> *) a b.
Read2 f =>
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (f a b)
liftReadPrec2 forall a. Read a => ReadPrec a
readPrec forall a. Read a => ReadPrec [a]
readListPrec
liftReadListPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec [Const a a]
liftReadListPrec = forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]
liftReadListPrecDefault
liftReadList :: forall a. (Int -> ReadS a) -> ReadS [a] -> ReadS [Const a a]
liftReadList = forall (f :: * -> *) a.
Read1 f =>
(Int -> ReadS a) -> ReadS [a] -> ReadS [f a]
liftReadListDefault
instance (Show a) => Show1 (Const a) where
liftShowsPrec :: forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Const a a -> ShowS
liftShowsPrec = forall (f :: * -> * -> *) a b.
Show2 f =>
(Int -> a -> ShowS)
-> ([a] -> ShowS)
-> (Int -> b -> ShowS)
-> ([b] -> ShowS)
-> Int
-> f a b
-> ShowS
liftShowsPrec2 forall a. Show a => Int -> a -> ShowS
showsPrec forall a. Show a => [a] -> ShowS
showList
instance Eq1 Proxy where
liftEq :: forall a b. (a -> b -> Bool) -> Proxy a -> Proxy b -> Bool
liftEq a -> b -> Bool
_ Proxy a
_ Proxy b
_ = Bool
True
instance Ord1 Proxy where
liftCompare :: forall a b. (a -> b -> Ordering) -> Proxy a -> Proxy b -> Ordering
liftCompare a -> b -> Ordering
_ Proxy a
_ Proxy b
_ = Ordering
EQ
instance Show1 Proxy where
liftShowsPrec :: forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Proxy a -> ShowS
liftShowsPrec Int -> a -> ShowS
_ [a] -> ShowS
_ Int
_ Proxy a
_ = String -> ShowS
showString String
"Proxy"
instance Read1 Proxy where
liftReadPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec (Proxy a)
liftReadPrec ReadPrec a
_ ReadPrec [a]
_ = forall a. ReadPrec a -> ReadPrec a
parens (Lexeme -> ReadPrec ()
expectP (String -> Lexeme
Ident String
"Proxy") forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall {k} (t :: k). Proxy t
Proxy)
liftReadListPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec [Proxy a]
liftReadListPrec = forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]
liftReadListPrecDefault
liftReadList :: forall a. (Int -> ReadS a) -> ReadS [a] -> ReadS [Proxy a]
liftReadList = forall (f :: * -> *) a.
Read1 f =>
(Int -> ReadS a) -> ReadS [a] -> ReadS [f a]
liftReadListDefault
instance Eq1 Down where
liftEq :: forall a b. (a -> b -> Bool) -> Down a -> Down b -> Bool
liftEq a -> b -> Bool
eq (Down a
x) (Down b
y) = a -> b -> Bool
eq a
x b
y
instance Ord1 Down where
liftCompare :: forall a b. (a -> b -> Ordering) -> Down a -> Down b -> Ordering
liftCompare a -> b -> Ordering
comp (Down a
x) (Down b
y) = a -> b -> Ordering
comp a
x b
y
instance Read1 Down where
liftReadsPrec :: forall a. (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Down a)
liftReadsPrec Int -> ReadS a
rp ReadS [a]
_ = forall a. (String -> ReadS a) -> Int -> ReadS a
readsData forall a b. (a -> b) -> a -> b
$
forall a t.
(Int -> ReadS a) -> String -> (a -> t) -> String -> ReadS t
readsUnaryWith Int -> ReadS a
rp String
"Down" forall a. a -> Down a
Down
instance Show1 Down where
liftShowsPrec :: forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Down a -> ShowS
liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (Down a
x) = forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp String
"Down" Int
d a
x
instance Eq1 Complex where
liftEq :: forall a b. (a -> b -> Bool) -> Complex a -> Complex b -> Bool
liftEq a -> b -> Bool
eq (a
x :+ a
y) (b
u :+ b
v) = a -> b -> Bool
eq a
x b
u Bool -> Bool -> Bool
&& a -> b -> Bool
eq a
y b
v
instance Read1 Complex where
liftReadPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec (Complex a)
liftReadPrec ReadPrec a
rp ReadPrec [a]
_ = forall a. ReadPrec a -> ReadPrec a
parens forall a b. (a -> b) -> a -> b
$ forall a. Int -> ReadPrec a -> ReadPrec a
prec Int
complexPrec forall a b. (a -> b) -> a -> b
$ do
a
x <- forall a. ReadPrec a -> ReadPrec a
step ReadPrec a
rp
Lexeme -> ReadPrec ()
expectP (String -> Lexeme
Symbol String
":+")
a
y <- forall a. ReadPrec a -> ReadPrec a
step ReadPrec a
rp
forall (m :: * -> *) a. Monad m => a -> m a
return (a
x forall a. a -> a -> Complex a
:+ a
y)
where
complexPrec :: Int
complexPrec = Int
6
liftReadListPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec [Complex a]
liftReadListPrec = forall (f :: * -> *) a.
Read1 f =>
ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]
liftReadListPrecDefault
liftReadList :: forall a. (Int -> ReadS a) -> ReadS [a] -> ReadS [Complex a]
liftReadList = forall (f :: * -> *) a.
Read1 f =>
(Int -> ReadS a) -> ReadS [a] -> ReadS [f a]
liftReadListDefault
instance Show1 Complex where
liftShowsPrec :: forall a.
(Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Complex a -> ShowS
liftShowsPrec Int -> a -> ShowS
sp [a] -> ShowS
_ Int
d (a
x :+ a
y) = Bool -> ShowS -> ShowS
showParen (Int
d forall a. Ord a => a -> a -> Bool
> Int
complexPrec) forall a b. (a -> b) -> a -> b
$
Int -> a -> ShowS
sp (Int
complexPrecforall a. Num a => a -> a -> a
+Int
1) a
x forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
" :+ " forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> ShowS
sp (Int
complexPrecforall a. Num a => a -> a -> a
+Int
1) a
y
where
complexPrec :: Int
complexPrec = Int
6
readsData :: (String -> ReadS a) -> Int -> ReadS a
readsData :: forall a. (String -> ReadS a) -> Int -> ReadS a
readsData String -> ReadS a
reader Int
d =
forall a. Bool -> ReadS a -> ReadS a
readParen (Int
d forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$ \ String
r -> [(a, String)
res | (String
kw,String
s) <- ReadS String
lex String
r, (a, String)
res <- String -> ReadS a
reader String
kw String
s]
readData :: ReadPrec a -> ReadPrec a
readData :: forall a. ReadPrec a -> ReadPrec a
readData ReadPrec a
reader = forall a. ReadPrec a -> ReadPrec a
parens forall a b. (a -> b) -> a -> b
$ forall a. Int -> ReadPrec a -> ReadPrec a
prec Int
10 ReadPrec a
reader
readsUnaryWith :: (Int -> ReadS a) -> String -> (a -> t) -> String -> ReadS t
readsUnaryWith :: forall a t.
(Int -> ReadS a) -> String -> (a -> t) -> String -> ReadS t
readsUnaryWith Int -> ReadS a
rp String
name a -> t
cons String
kw String
s =
[(a -> t
cons a
x,String
t) | String
kw forall a. Eq a => a -> a -> Bool
== String
name, (a
x,String
t) <- Int -> ReadS a
rp Int
11 String
s]
readUnaryWith :: ReadPrec a -> String -> (a -> t) -> ReadPrec t
readUnaryWith :: forall a t. ReadPrec a -> String -> (a -> t) -> ReadPrec t
readUnaryWith ReadPrec a
rp String
name a -> t
cons = do
Lexeme -> ReadPrec ()
expectP forall a b. (a -> b) -> a -> b
$ String -> Lexeme
Ident String
name
a
x <- forall a. ReadPrec a -> ReadPrec a
step ReadPrec a
rp
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ a -> t
cons a
x
readsBinaryWith :: (Int -> ReadS a) -> (Int -> ReadS b) ->
String -> (a -> b -> t) -> String -> ReadS t
readsBinaryWith :: forall a b t.
(Int -> ReadS a)
-> (Int -> ReadS b) -> String -> (a -> b -> t) -> String -> ReadS t
readsBinaryWith Int -> ReadS a
rp1 Int -> ReadS b
rp2 String
name a -> b -> t
cons String
kw String
s =
[(a -> b -> t
cons a
x b
y,String
u) | String
kw forall a. Eq a => a -> a -> Bool
== String
name, (a
x,String
t) <- Int -> ReadS a
rp1 Int
11 String
s, (b
y,String
u) <- Int -> ReadS b
rp2 Int
11 String
t]
readBinaryWith :: ReadPrec a -> ReadPrec b ->
String -> (a -> b -> t) -> ReadPrec t
readBinaryWith :: forall a b t.
ReadPrec a -> ReadPrec b -> String -> (a -> b -> t) -> ReadPrec t
readBinaryWith ReadPrec a
rp1 ReadPrec b
rp2 String
name a -> b -> t
cons = do
Lexeme -> ReadPrec ()
expectP forall a b. (a -> b) -> a -> b
$ String -> Lexeme
Ident String
name
a
x <- forall a. ReadPrec a -> ReadPrec a
step ReadPrec a
rp1
b
y <- forall a. ReadPrec a -> ReadPrec a
step ReadPrec b
rp2
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ a -> b -> t
cons a
x b
y
showsUnaryWith :: (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith :: forall a. (Int -> a -> ShowS) -> String -> Int -> a -> ShowS
showsUnaryWith Int -> a -> ShowS
sp String
name Int
d a
x = Bool -> ShowS -> ShowS
showParen (Int
d forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
name forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
' ' forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> ShowS
sp Int
11 a
x
showsBinaryWith :: (Int -> a -> ShowS) -> (Int -> b -> ShowS) ->
String -> Int -> a -> b -> ShowS
showsBinaryWith :: forall a b.
(Int -> a -> ShowS)
-> (Int -> b -> ShowS) -> String -> Int -> a -> b -> ShowS
showsBinaryWith Int -> a -> ShowS
sp1 Int -> b -> ShowS
sp2 String
name Int
d a
x b
y = Bool -> ShowS -> ShowS
showParen (Int
d forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
name forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
' ' forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> ShowS
sp1 Int
11 a
x forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
' ' forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> b -> ShowS
sp2 Int
11 b
y
{-# DEPRECATED readsUnary "Use 'readsUnaryWith' to define 'liftReadsPrec'" #-}
readsUnary :: (Read a) => String -> (a -> t) -> String -> ReadS t
readsUnary :: forall a t. Read a => String -> (a -> t) -> String -> ReadS t
readsUnary String
name a -> t
cons String
kw String
s =
[(a -> t
cons a
x,String
t) | String
kw forall a. Eq a => a -> a -> Bool
== String
name, (a
x,String
t) <- forall a. Read a => Int -> ReadS a
readsPrec Int
11 String
s]
{-# DEPRECATED readsUnary1 "Use 'readsUnaryWith' to define 'liftReadsPrec'" #-}
readsUnary1 :: (Read1 f, Read a) => String -> (f a -> t) -> String -> ReadS t
readsUnary1 :: forall (f :: * -> *) a t.
(Read1 f, Read a) =>
String -> (f a -> t) -> String -> ReadS t
readsUnary1 String
name f a -> t
cons String
kw String
s =
[(f a -> t
cons f a
x,String
t) | String
kw forall a. Eq a => a -> a -> Bool
== String
name, (f a
x,String
t) <- forall (f :: * -> *) a. (Read1 f, Read a) => Int -> ReadS (f a)
readsPrec1 Int
11 String
s]
{-# DEPRECATED readsBinary1
"Use 'readsBinaryWith' to define 'liftReadsPrec'" #-}
readsBinary1 :: (Read1 f, Read1 g, Read a) =>
String -> (f a -> g a -> t) -> String -> ReadS t
readsBinary1 :: forall (f :: * -> *) (g :: * -> *) a t.
(Read1 f, Read1 g, Read a) =>
String -> (f a -> g a -> t) -> String -> ReadS t
readsBinary1 String
name f a -> g a -> t
cons String
kw String
s =
[(f a -> g a -> t
cons f a
x g a
y,String
u) | String
kw forall a. Eq a => a -> a -> Bool
== String
name,
(f a
x,String
t) <- forall (f :: * -> *) a. (Read1 f, Read a) => Int -> ReadS (f a)
readsPrec1 Int
11 String
s, (g a
y,String
u) <- forall (f :: * -> *) a. (Read1 f, Read a) => Int -> ReadS (f a)
readsPrec1 Int
11 String
t]
{-# DEPRECATED showsUnary "Use 'showsUnaryWith' to define 'liftShowsPrec'" #-}
showsUnary :: (Show a) => String -> Int -> a -> ShowS
showsUnary :: forall a. Show a => String -> Int -> a -> ShowS
showsUnary String
name Int
d a
x = Bool -> ShowS -> ShowS
showParen (Int
d forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
name 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
x
{-# DEPRECATED showsUnary1 "Use 'showsUnaryWith' to define 'liftShowsPrec'" #-}
showsUnary1 :: (Show1 f, Show a) => String -> Int -> f a -> ShowS
showsUnary1 :: forall (f :: * -> *) a.
(Show1 f, Show a) =>
String -> Int -> f a -> ShowS
showsUnary1 String
name Int
d f a
x = Bool -> ShowS -> ShowS
showParen (Int
d forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
name 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 (f :: * -> *) a. (Show1 f, Show a) => Int -> f a -> ShowS
showsPrec1 Int
11 f a
x
{-# DEPRECATED showsBinary1
"Use 'showsBinaryWith' to define 'liftShowsPrec'" #-}
showsBinary1 :: (Show1 f, Show1 g, Show a) =>
String -> Int -> f a -> g a -> ShowS
showsBinary1 :: forall (f :: * -> *) (g :: * -> *) a.
(Show1 f, Show1 g, Show a) =>
String -> Int -> f a -> g a -> ShowS
showsBinary1 String
name Int
d f a
x g a
y = Bool -> ShowS -> ShowS
showParen (Int
d forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
name 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 (f :: * -> *) a. (Show1 f, Show a) => Int -> f a -> ShowS
showsPrec1 Int
11 f a
x 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 (f :: * -> *) a. (Show1 f, Show a) => Int -> f a -> ShowS
showsPrec1 Int
11 g a
y