{-# LANGUAGE CPP #-}
{-# LANGUAGE Safe #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Yaya.Containers.Pattern.Map
( MapF (BinF, TipF),
eqMapF,
compareMapF,
readMapFPrec,
showsMapFPrec,
)
where
import "base" Control.Applicative
( Alternative ((<|>)),
Applicative ((<*>)),
(*>),
)
import "base" Control.Category (Category ((.)))
import "base" Data.Bool (Bool (False, True), (&&))
import "base" Data.Eq (Eq ((==)))
import "base" Data.Foldable (Foldable)
import "base" Data.Function (($))
import "base" Data.Functor (Functor (fmap), (<$), (<$>))
import "base" Data.Int (Int)
import "base" Data.Ord (Ord (compare, (<=)), Ordering (EQ, GT, LT))
import "base" Data.Semigroup ((<>))
import "base" Data.Traversable (Traversable)
import qualified "base" Data.Tuple as Tuple
import "base" GHC.Generics (Generic, Generic1)
import "base" GHC.Read (expectP)
import "base" Text.Read
( Read (readListPrec, readPrec),
ReadPrec,
parens,
prec,
step,
)
import qualified "base" Text.Read.Lex as Lex
import qualified "containers" Data.Map.Internal as Map
import "yaya" Yaya.Fold
( Projectable (project),
Recursive (cata),
Steppable (embed),
)
import "base" Prelude (Num ((+)))
#if MIN_VERSION_base(4, 18, 0)
import "base" Data.Functor.Classes
( Eq1,
Eq2 (liftEq2),
Ord1,
Ord2 (liftCompare2),
Read1 (liftReadPrec),
Read2 (liftReadPrec2),
Show1,
Show2 (liftShowsPrec2),
)
import "base" Text.Show (Show (showsPrec), ShowS, showParen, showString)
#else
import "base" Data.Functor.Classes
( Eq1 (liftEq),
Eq2 (liftEq2),
Ord1 (liftCompare),
Ord2 (liftCompare2),
Read1 (liftReadPrec),
Read2 (liftReadPrec2),
Show1 (liftShowsPrec),
Show2 (liftShowsPrec2),
)
import "base" Text.Show
( Show (showList, showsPrec),
ShowS,
showParen,
showString,
)
#endif
data MapF k v r = TipF | BinF Map.Size k ~v r r
deriving stock
( MapF k v r -> MapF k v r -> Bool
(MapF k v r -> MapF k v r -> Bool)
-> (MapF k v r -> MapF k v r -> Bool) -> Eq (MapF k v r)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall k v r.
(Eq k, Eq v, Eq r) =>
MapF k v r -> MapF k v r -> Bool
$c== :: forall k v r.
(Eq k, Eq v, Eq r) =>
MapF k v r -> MapF k v r -> Bool
== :: MapF k v r -> MapF k v r -> Bool
$c/= :: forall k v r.
(Eq k, Eq v, Eq r) =>
MapF k v r -> MapF k v r -> Bool
/= :: MapF k v r -> MapF k v r -> Bool
Eq,
Eq (MapF k v r)
Eq (MapF k v r) =>
(MapF k v r -> MapF k v r -> Ordering)
-> (MapF k v r -> MapF k v r -> Bool)
-> (MapF k v r -> MapF k v r -> Bool)
-> (MapF k v r -> MapF k v r -> Bool)
-> (MapF k v r -> MapF k v r -> Bool)
-> (MapF k v r -> MapF k v r -> MapF k v r)
-> (MapF k v r -> MapF k v r -> MapF k v r)
-> Ord (MapF k v r)
MapF k v r -> MapF k v r -> Bool
MapF k v r -> MapF k v r -> Ordering
MapF k v r -> MapF k v r -> MapF k v r
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall k v r. (Ord k, Ord v, Ord r) => Eq (MapF k v r)
forall k v r.
(Ord k, Ord v, Ord r) =>
MapF k v r -> MapF k v r -> Bool
forall k v r.
(Ord k, Ord v, Ord r) =>
MapF k v r -> MapF k v r -> Ordering
forall k v r.
(Ord k, Ord v, Ord r) =>
MapF k v r -> MapF k v r -> MapF k v r
$ccompare :: forall k v r.
(Ord k, Ord v, Ord r) =>
MapF k v r -> MapF k v r -> Ordering
compare :: MapF k v r -> MapF k v r -> Ordering
$c< :: forall k v r.
(Ord k, Ord v, Ord r) =>
MapF k v r -> MapF k v r -> Bool
< :: MapF k v r -> MapF k v r -> Bool
$c<= :: forall k v r.
(Ord k, Ord v, Ord r) =>
MapF k v r -> MapF k v r -> Bool
<= :: MapF k v r -> MapF k v r -> Bool
$c> :: forall k v r.
(Ord k, Ord v, Ord r) =>
MapF k v r -> MapF k v r -> Bool
> :: MapF k v r -> MapF k v r -> Bool
$c>= :: forall k v r.
(Ord k, Ord v, Ord r) =>
MapF k v r -> MapF k v r -> Bool
>= :: MapF k v r -> MapF k v r -> Bool
$cmax :: forall k v r.
(Ord k, Ord v, Ord r) =>
MapF k v r -> MapF k v r -> MapF k v r
max :: MapF k v r -> MapF k v r -> MapF k v r
$cmin :: forall k v r.
(Ord k, Ord v, Ord r) =>
MapF k v r -> MapF k v r -> MapF k v r
min :: MapF k v r -> MapF k v r -> MapF k v r
Ord,
(forall x. MapF k v r -> Rep (MapF k v r) x)
-> (forall x. Rep (MapF k v r) x -> MapF k v r)
-> Generic (MapF k v r)
forall x. Rep (MapF k v r) x -> MapF k v r
forall x. MapF k v r -> Rep (MapF k v r) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall k v r x. Rep (MapF k v r) x -> MapF k v r
forall k v r x. MapF k v r -> Rep (MapF k v r) x
$cfrom :: forall k v r x. MapF k v r -> Rep (MapF k v r) x
from :: forall x. MapF k v r -> Rep (MapF k v r) x
$cto :: forall k v r x. Rep (MapF k v r) x -> MapF k v r
to :: forall x. Rep (MapF k v r) x -> MapF k v r
Generic,
ReadPrec [MapF k v r]
ReadPrec (MapF k v r)
Size -> ReadS (MapF k v r)
ReadS [MapF k v r]
(Size -> ReadS (MapF k v r))
-> ReadS [MapF k v r]
-> ReadPrec (MapF k v r)
-> ReadPrec [MapF k v r]
-> Read (MapF k v r)
forall a.
(Size -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
forall k v r. (Read k, Read v, Read r) => ReadPrec [MapF k v r]
forall k v r. (Read k, Read v, Read r) => ReadPrec (MapF k v r)
forall k v r.
(Read k, Read v, Read r) =>
Size -> ReadS (MapF k v r)
forall k v r. (Read k, Read v, Read r) => ReadS [MapF k v r]
$creadsPrec :: forall k v r.
(Read k, Read v, Read r) =>
Size -> ReadS (MapF k v r)
readsPrec :: Size -> ReadS (MapF k v r)
$creadList :: forall k v r. (Read k, Read v, Read r) => ReadS [MapF k v r]
readList :: ReadS [MapF k v r]
$creadPrec :: forall k v r. (Read k, Read v, Read r) => ReadPrec (MapF k v r)
readPrec :: ReadPrec (MapF k v r)
$creadListPrec :: forall k v r. (Read k, Read v, Read r) => ReadPrec [MapF k v r]
readListPrec :: ReadPrec [MapF k v r]
Read,
Size -> MapF k v r -> ShowS
[MapF k v r] -> ShowS
MapF k v r -> String
(Size -> MapF k v r -> ShowS)
-> (MapF k v r -> String)
-> ([MapF k v r] -> ShowS)
-> Show (MapF k v r)
forall a.
(Size -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k v r.
(Show k, Show v, Show r) =>
Size -> MapF k v r -> ShowS
forall k v r. (Show k, Show v, Show r) => [MapF k v r] -> ShowS
forall k v r. (Show k, Show v, Show r) => MapF k v r -> String
$cshowsPrec :: forall k v r.
(Show k, Show v, Show r) =>
Size -> MapF k v r -> ShowS
showsPrec :: Size -> MapF k v r -> ShowS
$cshow :: forall k v r. (Show k, Show v, Show r) => MapF k v r -> String
show :: MapF k v r -> String
$cshowList :: forall k v r. (Show k, Show v, Show r) => [MapF k v r] -> ShowS
showList :: [MapF k v r] -> ShowS
Show,
(forall m. Monoid m => MapF k v m -> m)
-> (forall m a. Monoid m => (a -> m) -> MapF k v a -> m)
-> (forall m a. Monoid m => (a -> m) -> MapF k v a -> m)
-> (forall a b. (a -> b -> b) -> b -> MapF k v a -> b)
-> (forall a b. (a -> b -> b) -> b -> MapF k v a -> b)
-> (forall b a. (b -> a -> b) -> b -> MapF k v a -> b)
-> (forall b a. (b -> a -> b) -> b -> MapF k v a -> b)
-> (forall a. (a -> a -> a) -> MapF k v a -> a)
-> (forall a. (a -> a -> a) -> MapF k v a -> a)
-> (forall a. MapF k v a -> [a])
-> (forall a. MapF k v a -> Bool)
-> (forall a. MapF k v a -> Size)
-> (forall a. Eq a => a -> MapF k v a -> Bool)
-> (forall a. Ord a => MapF k v a -> a)
-> (forall a. Ord a => MapF k v a -> a)
-> (forall a. Num a => MapF k v a -> a)
-> (forall a. Num a => MapF k v a -> a)
-> Foldable (MapF k v)
forall a. Eq a => a -> MapF k v a -> Bool
forall a. Num a => MapF k v a -> a
forall a. Ord a => MapF k v a -> a
forall m. Monoid m => MapF k v m -> m
forall a. MapF k v a -> Bool
forall a. MapF k v a -> Size
forall a. MapF k v a -> [a]
forall a. (a -> a -> a) -> MapF k v a -> a
forall m a. Monoid m => (a -> m) -> MapF k v a -> m
forall b a. (b -> a -> b) -> b -> MapF k v a -> b
forall a b. (a -> b -> b) -> b -> MapF k v a -> b
forall k v a. Eq a => a -> MapF k v a -> Bool
forall k v a. Num a => MapF k v a -> a
forall k v a. Ord a => MapF k v a -> a
forall k v m. Monoid m => MapF k v m -> m
forall k v a. MapF k v a -> Bool
forall k v a. MapF k v a -> Size
forall k v a. MapF k v a -> [a]
forall k v a. (a -> a -> a) -> MapF k v a -> a
forall k v m a. Monoid m => (a -> m) -> MapF k v a -> m
forall k v b a. (b -> a -> b) -> b -> MapF k v a -> b
forall k v a b. (a -> b -> b) -> b -> MapF k v a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Size)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall k v m. Monoid m => MapF k v m -> m
fold :: forall m. Monoid m => MapF k v m -> m
$cfoldMap :: forall k v m a. Monoid m => (a -> m) -> MapF k v a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> MapF k v a -> m
$cfoldMap' :: forall k v m a. Monoid m => (a -> m) -> MapF k v a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> MapF k v a -> m
$cfoldr :: forall k v a b. (a -> b -> b) -> b -> MapF k v a -> b
foldr :: forall a b. (a -> b -> b) -> b -> MapF k v a -> b
$cfoldr' :: forall k v a b. (a -> b -> b) -> b -> MapF k v a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> MapF k v a -> b
$cfoldl :: forall k v b a. (b -> a -> b) -> b -> MapF k v a -> b
foldl :: forall b a. (b -> a -> b) -> b -> MapF k v a -> b
$cfoldl' :: forall k v b a. (b -> a -> b) -> b -> MapF k v a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> MapF k v a -> b
$cfoldr1 :: forall k v a. (a -> a -> a) -> MapF k v a -> a
foldr1 :: forall a. (a -> a -> a) -> MapF k v a -> a
$cfoldl1 :: forall k v a. (a -> a -> a) -> MapF k v a -> a
foldl1 :: forall a. (a -> a -> a) -> MapF k v a -> a
$ctoList :: forall k v a. MapF k v a -> [a]
toList :: forall a. MapF k v a -> [a]
$cnull :: forall k v a. MapF k v a -> Bool
null :: forall a. MapF k v a -> Bool
$clength :: forall k v a. MapF k v a -> Size
length :: forall a. MapF k v a -> Size
$celem :: forall k v a. Eq a => a -> MapF k v a -> Bool
elem :: forall a. Eq a => a -> MapF k v a -> Bool
$cmaximum :: forall k v a. Ord a => MapF k v a -> a
maximum :: forall a. Ord a => MapF k v a -> a
$cminimum :: forall k v a. Ord a => MapF k v a -> a
minimum :: forall a. Ord a => MapF k v a -> a
$csum :: forall k v a. Num a => MapF k v a -> a
sum :: forall a. Num a => MapF k v a -> a
$cproduct :: forall k v a. Num a => MapF k v a -> a
product :: forall a. Num a => MapF k v a -> a
Foldable,
(forall a b. (a -> b) -> MapF k v a -> MapF k v b)
-> (forall a b. a -> MapF k v b -> MapF k v a)
-> Functor (MapF k v)
forall a b. a -> MapF k v b -> MapF k v a
forall a b. (a -> b) -> MapF k v a -> MapF k v b
forall k v a b. a -> MapF k v b -> MapF k v a
forall k v a b. (a -> b) -> MapF k v a -> MapF k v b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall k v a b. (a -> b) -> MapF k v a -> MapF k v b
fmap :: forall a b. (a -> b) -> MapF k v a -> MapF k v b
$c<$ :: forall k v a b. a -> MapF k v b -> MapF k v a
<$ :: forall a b. a -> MapF k v b -> MapF k v a
Functor,
(forall a. MapF k v a -> Rep1 (MapF k v) a)
-> (forall a. Rep1 (MapF k v) a -> MapF k v a)
-> Generic1 (MapF k v)
forall a. Rep1 (MapF k v) a -> MapF k v a
forall a. MapF k v a -> Rep1 (MapF k v) a
forall k v a. Rep1 (MapF k v) a -> MapF k v a
forall k v a. MapF k v a -> Rep1 (MapF k v) a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cfrom1 :: forall k v a. MapF k v a -> Rep1 (MapF k v) a
from1 :: forall a. MapF k v a -> Rep1 (MapF k v) a
$cto1 :: forall k v a. Rep1 (MapF k v) a -> MapF k v a
to1 :: forall a. Rep1 (MapF k v) a -> MapF k v a
Generic1,
Functor (MapF k v)
Foldable (MapF k v)
(Functor (MapF k v), Foldable (MapF k v)) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> MapF k v a -> f (MapF k v b))
-> (forall (f :: * -> *) a.
Applicative f =>
MapF k v (f a) -> f (MapF k v a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> MapF k v a -> m (MapF k v b))
-> (forall (m :: * -> *) a.
Monad m =>
MapF k v (m a) -> m (MapF k v a))
-> Traversable (MapF k v)
forall k v. Functor (MapF k v)
forall k v. Foldable (MapF k v)
forall k v (m :: * -> *) a.
Monad m =>
MapF k v (m a) -> m (MapF k v a)
forall k v (f :: * -> *) a.
Applicative f =>
MapF k v (f a) -> f (MapF k v a)
forall k v (m :: * -> *) a b.
Monad m =>
(a -> m b) -> MapF k v a -> m (MapF k v b)
forall k v (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> MapF k v a -> f (MapF k v b)
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => MapF k v (m a) -> m (MapF k v a)
forall (f :: * -> *) a.
Applicative f =>
MapF k v (f a) -> f (MapF k v a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> MapF k v a -> m (MapF k v b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> MapF k v a -> f (MapF k v b)
$ctraverse :: forall k v (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> MapF k v a -> f (MapF k v b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> MapF k v a -> f (MapF k v b)
$csequenceA :: forall k v (f :: * -> *) a.
Applicative f =>
MapF k v (f a) -> f (MapF k v a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
MapF k v (f a) -> f (MapF k v a)
$cmapM :: forall k v (m :: * -> *) a b.
Monad m =>
(a -> m b) -> MapF k v a -> m (MapF k v b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> MapF k v a -> m (MapF k v b)
$csequence :: forall k v (m :: * -> *) a.
Monad m =>
MapF k v (m a) -> m (MapF k v a)
sequence :: forall (m :: * -> *) a. Monad m => MapF k v (m a) -> m (MapF k v a)
Traversable
)
instance Projectable (->) (Map.Map k v) (MapF k v) where
project :: Coalgebra (->) (MapF k v) (Map k v)
project Map k v
Map.Tip = MapF k v (Map k v)
forall k v r. MapF k v r
TipF
project (Map.Bin Size
size k
k v
v Map k v
l Map k v
r) = Size -> k -> v -> Map k v -> Coalgebra (->) (MapF k v) (Map k v)
forall k v r. Size -> k -> v -> r -> r -> MapF k v r
BinF Size
size k
k v
v Map k v
l Map k v
r
instance Recursive (->) (Map.Map k v) (MapF k v) where
cata :: forall a. Algebra (->) (MapF k v) a -> Map k v -> a
cata Algebra (->) (MapF k v) a
φ = Algebra (->) (MapF k v) a
φ Algebra (->) (MapF k v) a
-> (Map k v -> MapF k v a) -> Map k v -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (Map k v -> a) -> MapF k v (Map k v) -> MapF k v a
forall a b. (a -> b) -> MapF k v a -> MapF k v b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Algebra (->) (MapF k v) a -> Map k v -> a
forall a. Algebra (->) (MapF k v) a -> Map k v -> a
forall {k} {k1} (c :: k -> k1 -> *) (t :: k) (f :: k1 -> k)
(a :: k1).
Recursive c t f =>
Algebra c f a -> c t a
cata Algebra (->) (MapF k v) a
φ) (MapF k v (Map k v) -> MapF k v a)
-> (Map k v -> MapF k v (Map k v)) -> Map k v -> MapF k v a
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Map k v -> MapF k v (Map k v)
forall {k} {k1} (c :: k -> k1 -> *) (t :: k) (f :: k -> k1).
Projectable c t f =>
Coalgebra c f t
project
instance Steppable (->) (Map.Map k v) (MapF k v) where
embed :: Algebra (->) (MapF k v) (Map k v)
embed MapF k v (Map k v)
TipF = Map k v
forall k a. Map k a
Map.Tip
embed (BinF Size
size k
k v
v Map k v
l Map k v
r) = Size -> k -> v -> Map k v -> Map k v -> Map k v
forall k a. Size -> k -> a -> Map k a -> Map k a -> Map k a
Map.Bin Size
size k
k v
v Map k v
l Map k v
r
eqMapF ::
(k -> k' -> Bool) ->
(v -> v' -> Bool) ->
(r -> r' -> Bool) ->
MapF k v r ->
MapF k' v' r' ->
Bool
eqMapF :: forall k k' v v' r r'.
(k -> k' -> Bool)
-> (v -> v' -> Bool)
-> (r -> r' -> Bool)
-> MapF k v r
-> MapF k' v' r'
-> Bool
eqMapF k -> k' -> Bool
eqK v -> v' -> Bool
eqV r -> r' -> Bool
eqR = ((MapF k v r, MapF k' v' r') -> Bool)
-> MapF k v r -> MapF k' v' r' -> Bool
forall a b c. ((a, b) -> c) -> a -> b -> c
Tuple.curry (((MapF k v r, MapF k' v' r') -> Bool)
-> MapF k v r -> MapF k' v' r' -> Bool)
-> ((MapF k v r, MapF k' v' r') -> Bool)
-> MapF k v r
-> MapF k' v' r'
-> Bool
forall a b. (a -> b) -> a -> b
$ \case
(MapF k v r
TipF, MapF k' v' r'
TipF) -> Bool
True
(BinF Size
size k
k v
v r
l r
r, BinF Size
size' k'
k' v'
v' r'
l' r'
r') ->
Size
size Size -> Size -> Bool
forall a. Eq a => a -> a -> Bool
== Size
size' Bool -> Bool -> Bool
&& k -> k' -> Bool
eqK k
k k'
k' Bool -> Bool -> Bool
&& v -> v' -> Bool
eqV v
v v'
v' Bool -> Bool -> Bool
&& r -> r' -> Bool
eqR r
l r'
l' Bool -> Bool -> Bool
&& r -> r' -> Bool
eqR r
r r'
r'
(MapF k v r
_, MapF k' v' r'
_) -> Bool
False
compareMapF ::
(k -> k' -> Ordering) ->
(v -> v' -> Ordering) ->
(r -> r' -> Ordering) ->
MapF k v r ->
MapF k' v' r' ->
Ordering
compareMapF :: forall k k' v v' r r'.
(k -> k' -> Ordering)
-> (v -> v' -> Ordering)
-> (r -> r' -> Ordering)
-> MapF k v r
-> MapF k' v' r'
-> Ordering
compareMapF k -> k' -> Ordering
compareK v -> v' -> Ordering
compareV r -> r' -> Ordering
compareR = ((MapF k v r, MapF k' v' r') -> Ordering)
-> MapF k v r -> MapF k' v' r' -> Ordering
forall a b c. ((a, b) -> c) -> a -> b -> c
Tuple.curry (((MapF k v r, MapF k' v' r') -> Ordering)
-> MapF k v r -> MapF k' v' r' -> Ordering)
-> ((MapF k v r, MapF k' v' r') -> Ordering)
-> MapF k v r
-> MapF k' v' r'
-> Ordering
forall a b. (a -> b) -> a -> b
$ \case
(MapF k v r
TipF, MapF k' v' r'
TipF) -> Ordering
EQ
(MapF k v r
TipF, BinF {}) -> Ordering
LT
(BinF {}, MapF k' v' r'
TipF) -> Ordering
GT
(BinF Size
size k
k v
v r
l r
r, BinF Size
size' k'
k' v'
v' r'
l' r'
r') ->
Size -> Size -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Size
size Size
size'
Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> k -> k' -> Ordering
compareK k
k k'
k'
Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> v -> v' -> Ordering
compareV v
v v'
v'
Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> r -> r' -> Ordering
compareR r
l r'
l'
Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> r -> r' -> Ordering
compareR r
r r'
r'
readMapFPrec :: ReadPrec k -> ReadPrec v -> ReadPrec r -> ReadPrec (MapF k v r)
readMapFPrec :: forall k v r.
ReadPrec k -> ReadPrec v -> ReadPrec r -> ReadPrec (MapF k v r)
readMapFPrec ReadPrec k
readPrecK ReadPrec v
readPrecV ReadPrec r
readPrecR =
let appPrec :: a
appPrec = a
10
in ReadPrec (MapF k v r) -> ReadPrec (MapF k v r)
forall a. ReadPrec a -> ReadPrec a
parens (ReadPrec (MapF k v r) -> ReadPrec (MapF k v r))
-> (ReadPrec (MapF k v r) -> ReadPrec (MapF k v r))
-> ReadPrec (MapF k v r)
-> ReadPrec (MapF k v r)
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Size -> ReadPrec (MapF k v r) -> ReadPrec (MapF k v r)
forall a. Size -> ReadPrec a -> ReadPrec a
prec Size
forall {a}. Num a => a
appPrec (ReadPrec (MapF k v r) -> ReadPrec (MapF k v r))
-> ReadPrec (MapF k v r) -> ReadPrec (MapF k v r)
forall a b. (a -> b) -> a -> b
$
MapF k v r
forall k v r. MapF k v r
TipF
MapF k v r -> ReadPrec () -> ReadPrec (MapF k v r)
forall a b. a -> ReadPrec b -> ReadPrec a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Lexeme -> ReadPrec ()
expectP (String -> Lexeme
Lex.Ident String
"TipF")
ReadPrec (MapF k v r)
-> ReadPrec (MapF k v r) -> ReadPrec (MapF k v r)
forall a. ReadPrec a -> ReadPrec a -> ReadPrec a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Lexeme -> ReadPrec ()
expectP (String -> Lexeme
Lex.Ident String
"BinF")
ReadPrec () -> ReadPrec (MapF k v r) -> ReadPrec (MapF k v r)
forall a b. ReadPrec a -> ReadPrec b -> ReadPrec b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ( Size -> k -> v -> r -> r -> MapF k v r
forall k v r. Size -> k -> v -> r -> r -> MapF k v r
BinF
(Size -> k -> v -> r -> r -> MapF k v r)
-> ReadPrec Size -> ReadPrec (k -> v -> r -> r -> MapF k v r)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ReadPrec Size -> ReadPrec Size
forall a. ReadPrec a -> ReadPrec a
step ReadPrec Size
forall a. Read a => ReadPrec a
readPrec
ReadPrec (k -> v -> r -> r -> MapF k v r)
-> ReadPrec k -> ReadPrec (v -> r -> r -> MapF k v r)
forall a b. ReadPrec (a -> b) -> ReadPrec a -> ReadPrec b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReadPrec k -> ReadPrec k
forall a. ReadPrec a -> ReadPrec a
step ReadPrec k
readPrecK
ReadPrec (v -> r -> r -> MapF k v r)
-> ReadPrec v -> ReadPrec (r -> r -> MapF k v r)
forall a b. ReadPrec (a -> b) -> ReadPrec a -> ReadPrec b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReadPrec v -> ReadPrec v
forall a. ReadPrec a -> ReadPrec a
step ReadPrec v
readPrecV
ReadPrec (r -> r -> MapF k v r)
-> ReadPrec r -> ReadPrec (r -> MapF k v r)
forall a b. ReadPrec (a -> b) -> ReadPrec a -> ReadPrec b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReadPrec r -> ReadPrec r
forall a. ReadPrec a -> ReadPrec a
step ReadPrec r
readPrecR
ReadPrec (r -> MapF k v r) -> ReadPrec r -> ReadPrec (MapF k v r)
forall a b. ReadPrec (a -> b) -> ReadPrec a -> ReadPrec b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReadPrec r -> ReadPrec r
forall a. ReadPrec a -> ReadPrec a
step ReadPrec r
readPrecR
)
showsMapFPrec ::
(Int -> k -> ShowS) ->
(Int -> v -> ShowS) ->
(Int -> r -> ShowS) ->
Int ->
MapF k v r ->
ShowS
showsMapFPrec :: forall k v r.
(Size -> k -> ShowS)
-> (Size -> v -> ShowS)
-> (Size -> r -> ShowS)
-> Size
-> MapF k v r
-> ShowS
showsMapFPrec Size -> k -> ShowS
showsPrecK Size -> v -> ShowS
showsPrecV Size -> r -> ShowS
showsPrecR Size
p =
let appPrec :: a
appPrec = a
10
nextPrec :: a
nextPrec = a
forall {a}. Num a => a
appPrec a -> a -> a
forall a. Num a => a -> a -> a
+ a
1
in \case
MapF k v r
TipF -> String -> ShowS
showString String
"TipF"
BinF Size
size k
k v
v r
l r
r ->
Bool -> ShowS -> ShowS
showParen (Size
forall {a}. Num a => a
nextPrec Size -> Size -> Bool
forall a. Ord a => a -> a -> Bool
<= Size
p) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"BinF "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Size -> Size -> ShowS
forall a. Show a => Size -> a -> ShowS
showsPrec Size
forall {a}. Num a => a
nextPrec Size
size
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Size -> k -> ShowS
showsPrecK Size
forall {a}. Num a => a
nextPrec k
k
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Size -> v -> ShowS
showsPrecV Size
forall {a}. Num a => a
nextPrec v
v
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Size -> r -> ShowS
showsPrecR Size
forall {a}. Num a => a
nextPrec r
l
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> ShowS
showString String
" "
ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Size -> r -> ShowS
showsPrecR Size
forall {a}. Num a => a
nextPrec r
r
#if MIN_VERSION_base(4, 18, 0)
instance (Eq k, Eq v) => Eq1 (MapF k v)
#else
instance (Eq k, Eq v) => Eq1 (MapF k v) where
liftEq = liftEq2 (==)
#endif
instance (Eq k) => Eq2 (MapF k) where
liftEq2 :: forall a b c d.
(a -> b -> Bool)
-> (c -> d -> Bool) -> MapF k a c -> MapF k b d -> Bool
liftEq2 = (k -> k -> Bool)
-> (a -> b -> Bool)
-> (c -> d -> Bool)
-> MapF k a c
-> MapF k b d
-> Bool
forall k k' v v' r r'.
(k -> k' -> Bool)
-> (v -> v' -> Bool)
-> (r -> r' -> Bool)
-> MapF k v r
-> MapF k' v' r'
-> Bool
eqMapF k -> k -> Bool
forall a. Eq a => a -> a -> Bool
(==)
#if MIN_VERSION_base(4, 18, 0)
instance (Ord k, Ord v) => Ord1 (MapF k v)
#else
instance (Ord k, Ord v) => Ord1 (MapF k v) where
liftCompare = liftCompare2 compare
#endif
instance (Ord k) => Ord2 (MapF k) where
liftCompare2 :: forall a b c d.
(a -> b -> Ordering)
-> (c -> d -> Ordering) -> MapF k a c -> MapF k b d -> Ordering
liftCompare2 = (k -> k -> Ordering)
-> (a -> b -> Ordering)
-> (c -> d -> Ordering)
-> MapF k a c
-> MapF k b d
-> Ordering
forall k k' v v' r r'.
(k -> k' -> Ordering)
-> (v -> v' -> Ordering)
-> (r -> r' -> Ordering)
-> MapF k v r
-> MapF k' v' r'
-> Ordering
compareMapF k -> k -> Ordering
forall a. Ord a => a -> a -> Ordering
compare
instance (Read k, Read v) => Read1 (MapF k v) where
liftReadPrec :: forall a. ReadPrec a -> ReadPrec [a] -> ReadPrec (MapF k v a)
liftReadPrec = ReadPrec v
-> ReadPrec [v]
-> ReadPrec a
-> ReadPrec [a]
-> ReadPrec (MapF k v a)
forall a b.
ReadPrec a
-> ReadPrec [a]
-> ReadPrec b
-> ReadPrec [b]
-> ReadPrec (MapF k a b)
forall (f :: * -> * -> *) a b.
Read2 f =>
ReadPrec a
-> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (f a b)
liftReadPrec2 ReadPrec v
forall a. Read a => ReadPrec a
readPrec ReadPrec [v]
forall a. Read a => ReadPrec [a]
readListPrec
instance (Read k) => Read2 (MapF k) where
liftReadPrec2 :: forall a b.
ReadPrec a
-> ReadPrec [a]
-> ReadPrec b
-> ReadPrec [b]
-> ReadPrec (MapF k a b)
liftReadPrec2 ReadPrec a
readPrecV ReadPrec [a]
_ ReadPrec b
readPrecR ReadPrec [b]
_ =
ReadPrec k -> ReadPrec a -> ReadPrec b -> ReadPrec (MapF k a b)
forall k v r.
ReadPrec k -> ReadPrec v -> ReadPrec r -> ReadPrec (MapF k v r)
readMapFPrec ReadPrec k
forall a. Read a => ReadPrec a
readPrec ReadPrec a
readPrecV ReadPrec b
readPrecR
#if MIN_VERSION_base(4, 18, 0)
instance (Show k, Show v) => Show1 (MapF k v)
#else
instance (Show k, Show v) => Show1 (MapF k v) where
liftShowsPrec = liftShowsPrec2 showsPrec showList
#endif
instance (Show k) => Show2 (MapF k) where
liftShowsPrec2 :: forall a b.
(Size -> a -> ShowS)
-> ([a] -> ShowS)
-> (Size -> b -> ShowS)
-> ([b] -> ShowS)
-> Size
-> MapF k a b
-> ShowS
liftShowsPrec2 Size -> a -> ShowS
showsPrecV [a] -> ShowS
_ Size -> b -> ShowS
showsPrecR [b] -> ShowS
_ =
(Size -> k -> ShowS)
-> (Size -> a -> ShowS)
-> (Size -> b -> ShowS)
-> Size
-> MapF k a b
-> ShowS
forall k v r.
(Size -> k -> ShowS)
-> (Size -> v -> ShowS)
-> (Size -> r -> ShowS)
-> Size
-> MapF k v r
-> ShowS
showsMapFPrec Size -> k -> ShowS
forall a. Show a => Size -> a -> ShowS
showsPrec Size -> a -> ShowS
showsPrecV Size -> b -> ShowS
showsPrecR