{-# OPTIONS_HADDOCK show-extensions #-}

-- |
-- Module      :  Phladiprelio.DataG
-- Copyright   :  (c) Oleksandr Zhabenko 2020-2023
-- License     :  MIT
-- Stability   :  Experimental
-- Maintainer  :  oleksandr.zhabenko@yahoo.com
--
-- Simplified version of the @phonetic-languages-common@ and @phonetic-languages-general@ packages.
-- Uses less dependencies.

{-# LANGUAGE BangPatterns, FlexibleContexts, NoImplicitPrelude #-}

module Phladiprelio.DataG where

import GHC.Base
import GHC.Num ((-))
import GHC.Real
import qualified Data.Foldable as F
import Data.SubG
import Data.MinMax.Preconditions
import Phladiprelio.Basis

maximumEl
  :: (F.Foldable t2, Ord c) => FuncRep2 (t a) b c
  -> t2 (t a)
  -> Result t a b c
maximumEl :: forall (t2 :: * -> *) c (t :: * -> *) a b.
(Foldable t2, Ord c) =>
FuncRep2 (t a) b c -> t2 (t a) -> Result t a b c
maximumEl !FuncRep2 (t a) b c
frep2 t2 (t a)
data0 =
  let !l :: t a
l = forall (t :: * -> *) a.
Foldable t =>
(a -> a -> Ordering) -> t a -> a
F.maximumBy (\t a
x t a
y -> forall a. Ord a => a -> a -> Ordering
compare (forall a b c. FuncRep2 a b c -> a -> c
getAC FuncRep2 (t a) b c
frep2 t a
x) (forall a b c. FuncRep2 a b c -> a -> c
getAC FuncRep2 (t a) b c
frep2 t a
y)) t2 (t a)
data0
      !m :: b
m = forall a b c. FuncRep2 a b c -> a -> b
getAB FuncRep2 (t a) b c
frep2 t a
l
      !tm :: c
tm = forall a b c. FuncRep2 a b c -> b -> c
getBC FuncRep2 (t a) b c
frep2 b
m in R {line :: t a
line = t a
l, propertiesF :: b
propertiesF = b
m, transPropertiesF :: c
transPropertiesF = c
tm}
{-# INLINE maximumEl #-}

minMaximumEls
  :: (InsertLeft t2 (t a), Monoid (t2 (t a)), Ord (t a), Ord c) => FuncRep2 (t a) b c
  -> t2 (t a)
  -> (Result t a b c,Result t a b c)
minMaximumEls :: forall (t2 :: * -> *) (t :: * -> *) a c b.
(InsertLeft t2 (t a), Monoid (t2 (t a)), Ord (t a), Ord c) =>
FuncRep2 (t a) b c -> t2 (t a) -> (Result t a b c, Result t a b c)
minMaximumEls !FuncRep2 (t a) b c
frep2 t2 (t a)
data0 =
  let (!t a
ln,!t a
lx) = forall a (t :: * -> *).
(Ord a, InsertLeft t a, Monoid (t a)) =>
(a -> a -> Ordering) -> t a -> (a, a)
minMax11ByC (\t a
x t a
y -> forall a. Ord a => a -> a -> Ordering
compare (forall a b c. FuncRep2 a b c -> a -> c
getAC FuncRep2 (t a) b c
frep2 t a
x) (forall a b c. FuncRep2 a b c -> a -> c
getAC FuncRep2 (t a) b c
frep2 t a
y)) t2 (t a)
data0
      !mn :: b
mn = forall a b c. FuncRep2 a b c -> a -> b
getAB FuncRep2 (t a) b c
frep2 t a
ln
      !mx :: b
mx = forall a b c. FuncRep2 a b c -> a -> b
getAB FuncRep2 (t a) b c
frep2 t a
lx
      !tmn :: c
tmn = forall a b c. FuncRep2 a b c -> b -> c
getBC FuncRep2 (t a) b c
frep2 b
mn
      !tmx :: c
tmx = forall a b c. FuncRep2 a b c -> b -> c
getBC FuncRep2 (t a) b c
frep2 b
mx in (R {line :: t a
line = t a
ln, propertiesF :: b
propertiesF = b
mn, transPropertiesF :: c
transPropertiesF = c
tmn}, R {line :: t a
line = t a
lx, propertiesF :: b
propertiesF = b
mx, transPropertiesF :: c
transPropertiesF = c
tmx})
{-# INLINE minMaximumEls #-}

maximumElR
  :: (F.Foldable t2, Ord c) => t2 (Result t a b c)
  -> Result t a b c
maximumElR :: forall (t2 :: * -> *) c (t :: * -> *) a b.
(Foldable t2, Ord c) =>
t2 (Result t a b c) -> Result t a b c
maximumElR = forall (t :: * -> *) a.
Foldable t =>
(a -> a -> Ordering) -> t a -> a
F.maximumBy (\Result t a b c
x Result t a b c
y -> forall a. Ord a => a -> a -> Ordering
compare (forall (t :: * -> *) a b c. Result t a b c -> c
transPropertiesF Result t a b c
x) (forall (t :: * -> *) a b c. Result t a b c -> c
transPropertiesF Result t a b c
y))
{-# INLINE maximumElR #-}

minMaximumElRs
  :: (InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)), Ord (t a), Ord b, Ord c) => t2 (Result t a b c)
  -> (Result t a b c,Result t a b c)
minMaximumElRs :: forall (t2 :: * -> *) (t :: * -> *) a b c.
(InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)),
 Ord (t a), Ord b, Ord c) =>
t2 (Result t a b c) -> (Result t a b c, Result t a b c)
minMaximumElRs = forall a (t :: * -> *).
(Ord a, InsertLeft t a, Monoid (t a)) =>
(a -> a -> Ordering) -> t a -> (a, a)
minMax11ByC (\Result t a b c
x Result t a b c
y -> forall a. Ord a => a -> a -> Ordering
compare (forall (t :: * -> *) a b c. Result t a b c -> c
transPropertiesF Result t a b c
x) (forall (t :: * -> *) a b c. Result t a b c -> c
transPropertiesF Result t a b c
y))
{-# INLINE minMaximumElRs #-}

-----------------------------------------------------------------------------------

-- | The second argument must be not empty for the function to work correctly.
innerPartitioning
  :: (InsertLeft t2 (t a), Monoid (t2 (t a)), InsertLeft t2 c, Monoid (t2 c), Ord c) => FuncRep2 (t a) b c
  -> t2 (t a)
  -> (t2 (t a), t2 (t a))
innerPartitioning :: forall (t2 :: * -> *) (t :: * -> *) a c b.
(InsertLeft t2 (t a), Monoid (t2 (t a)), InsertLeft t2 c,
 Monoid (t2 c), Ord c) =>
FuncRep2 (t a) b c -> t2 (t a) -> (t2 (t a), t2 (t a))
innerPartitioning !FuncRep2 (t a) b c
frep2 t2 (t a)
data0 =
  let !l :: c
l = forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
F.maximum forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) b a.
(InsertLeft t b, Monoid (t b)) =>
(a -> b) -> t a -> t b
mapG (forall (t :: * -> *) a b c. FuncRep2 (t a) b c -> t a -> c
toTransPropertiesF' FuncRep2 (t a) b c
frep2) forall a b. (a -> b) -> a -> b
$ t2 (t a)
data0 in forall (t :: * -> *) a.
(InsertLeft t a, Monoid (t a)) =>
(a -> Bool) -> t a -> (t a, t a)
partitionG ((forall a. Eq a => a -> a -> Bool
== c
l) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. FuncRep2 a b c -> a -> c
getAC FuncRep2 (t a) b c
frep2) t2 (t a)
data0
{-# INLINE innerPartitioning #-}

-- | The first argument must be not empty for the function to work correctly.
innerPartitioningR
  :: (InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)), InsertLeft t2 c, Monoid (t2 c), Ord c) => t2 (Result t a b c)
  -> (t2 (Result t a b c), t2 (Result t a b c))
innerPartitioningR :: forall (t2 :: * -> *) (t :: * -> *) a b c.
(InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)),
 InsertLeft t2 c, Monoid (t2 c), Ord c) =>
t2 (Result t a b c) -> (t2 (Result t a b c), t2 (Result t a b c))
innerPartitioningR t2 (Result t a b c)
dataR =
  let !l :: c
l = forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
F.maximum forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) b a.
(InsertLeft t b, Monoid (t b)) =>
(a -> b) -> t a -> t b
mapG forall (t :: * -> *) a b c. Result t a b c -> c
transPropertiesF forall a b. (a -> b) -> a -> b
$ t2 (Result t a b c)
dataR in forall (t :: * -> *) a.
(InsertLeft t a, Monoid (t a)) =>
(a -> Bool) -> t a -> (t a, t a)
partitionG ((forall a. Eq a => a -> a -> Bool
== c
l) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a b c. Result t a b c -> c
transPropertiesF) t2 (Result t a b c)
dataR
{-# INLINE innerPartitioningR #-}

maximumGroupsClassification
  :: (InsertLeft t2 (t a), Monoid (t2 (t a)), Ord c, InsertLeft t2 c, Monoid (t2 c), Integral d) => d
  -> FuncRep2 (t a) b c
  -> (t2 (t a), t2 (t a))
  -> (t2 (t a), t2 (t a))
maximumGroupsClassification :: forall (t2 :: * -> *) (t :: * -> *) a c d b.
(InsertLeft t2 (t a), Monoid (t2 (t a)), Ord c, InsertLeft t2 c,
 Monoid (t2 c), Integral d) =>
d
-> FuncRep2 (t a) b c
-> (t2 (t a), t2 (t a))
-> (t2 (t a), t2 (t a))
maximumGroupsClassification !d
nGroups !FuncRep2 (t a) b c
frep2 (t2 (t a)
dataT,t2 (t a)
dataF)
 | forall (t :: * -> *) a. Foldable t => t a -> Bool
F.null t2 (t a)
dataF = (t2 (t a)
dataT,forall a. Monoid a => a
mempty)
 | d
nGroups forall a. Ord a => a -> a -> Bool
<= d
0 = (t2 (t a)
dataT,t2 (t a)
dataF)
 | Bool
otherwise = forall (t2 :: * -> *) (t :: * -> *) a c d b.
(InsertLeft t2 (t a), Monoid (t2 (t a)), Ord c, InsertLeft t2 c,
 Monoid (t2 c), Integral d) =>
d
-> FuncRep2 (t a) b c
-> (t2 (t a), t2 (t a))
-> (t2 (t a), t2 (t a))
maximumGroupsClassification (d
nGroups forall a. Num a => a -> a -> a
- d
1) FuncRep2 (t a) b c
frep2 (t2 (t a)
dataT forall a. Monoid a => a -> a -> a
`mappend` t2 (t a)
partT,t2 (t a)
partF)
     where (!t2 (t a)
partT,!t2 (t a)
partF) = forall (t2 :: * -> *) (t :: * -> *) a c b.
(InsertLeft t2 (t a), Monoid (t2 (t a)), InsertLeft t2 c,
 Monoid (t2 c), Ord c) =>
FuncRep2 (t a) b c -> t2 (t a) -> (t2 (t a), t2 (t a))
innerPartitioning FuncRep2 (t a) b c
frep2 t2 (t a)
dataF
{-# NOINLINE maximumGroupsClassification #-}

maximumGroupsClassification1
  :: (InsertLeft t2 (t a), Monoid (t2 (t a)), Ord c, InsertLeft t2 c, Monoid (t2 c), Integral d) => d
  -> FuncRep2 (t a) b c
  -> t2 (t a)
  -> (t2 (t a), t2 (t a))
maximumGroupsClassification1 :: forall (t2 :: * -> *) (t :: * -> *) a c d b.
(InsertLeft t2 (t a), Monoid (t2 (t a)), Ord c, InsertLeft t2 c,
 Monoid (t2 c), Integral d) =>
d -> FuncRep2 (t a) b c -> t2 (t a) -> (t2 (t a), t2 (t a))
maximumGroupsClassification1 !d
nGroups !FuncRep2 (t a) b c
frep2 t2 (t a)
data0
 | forall (t :: * -> *) a. Foldable t => t a -> Bool
F.null t2 (t a)
data0 = (forall a. Monoid a => a
mempty,forall a. Monoid a => a
mempty)
 | d
nGroups forall a. Ord a => a -> a -> Bool
<= d
0 = forall (t2 :: * -> *) (t :: * -> *) a c b.
(InsertLeft t2 (t a), Monoid (t2 (t a)), InsertLeft t2 c,
 Monoid (t2 c), Ord c) =>
FuncRep2 (t a) b c -> t2 (t a) -> (t2 (t a), t2 (t a))
innerPartitioning FuncRep2 (t a) b c
frep2 t2 (t a)
data0
 | Bool
otherwise = forall (t2 :: * -> *) (t :: * -> *) a c d b.
(InsertLeft t2 (t a), Monoid (t2 (t a)), Ord c, InsertLeft t2 c,
 Monoid (t2 c), Integral d) =>
d
-> FuncRep2 (t a) b c
-> (t2 (t a), t2 (t a))
-> (t2 (t a), t2 (t a))
maximumGroupsClassification (d
nGroups forall a. Num a => a -> a -> a
- d
1) FuncRep2 (t a) b c
frep2 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t2 :: * -> *) (t :: * -> *) a c b.
(InsertLeft t2 (t a), Monoid (t2 (t a)), InsertLeft t2 c,
 Monoid (t2 c), Ord c) =>
FuncRep2 (t a) b c -> t2 (t a) -> (t2 (t a), t2 (t a))
innerPartitioning FuncRep2 (t a) b c
frep2 forall a b. (a -> b) -> a -> b
$ t2 (t a)
data0
{-# NOINLINE maximumGroupsClassification1 #-}

maximumGroupsClassificationR2
  :: (InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)), Ord c, InsertLeft t2 c, Monoid (t2 c), Integral d) => d
  -> (t2 (Result t a b c), t2 (Result t a b c))
  -> (t2 (Result t a b c), t2 (Result t a b c))
maximumGroupsClassificationR2 :: forall (t2 :: * -> *) (t :: * -> *) a b c d.
(InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)),
 Ord c, InsertLeft t2 c, Monoid (t2 c), Integral d) =>
d
-> (t2 (Result t a b c), t2 (Result t a b c))
-> (t2 (Result t a b c), t2 (Result t a b c))
maximumGroupsClassificationR2 !d
nGroups (t2 (Result t a b c)
dataT,t2 (Result t a b c)
dataF)
 | forall (t :: * -> *) a. Foldable t => t a -> Bool
F.null t2 (Result t a b c)
dataF = (t2 (Result t a b c)
dataT,forall a. Monoid a => a
mempty)
 | d
nGroups forall a. Ord a => a -> a -> Bool
<= d
0 = (t2 (Result t a b c)
dataT,t2 (Result t a b c)
dataF)
 | Bool
otherwise = forall (t2 :: * -> *) (t :: * -> *) a b c d.
(InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)),
 Ord c, InsertLeft t2 c, Monoid (t2 c), Integral d) =>
d
-> (t2 (Result t a b c), t2 (Result t a b c))
-> (t2 (Result t a b c), t2 (Result t a b c))
maximumGroupsClassificationR2 (d
nGroups forall a. Num a => a -> a -> a
- d
1) (t2 (Result t a b c)
dataT forall a. Monoid a => a -> a -> a
`mappend` t2 (Result t a b c)
partT,t2 (Result t a b c)
partF)
     where (!t2 (Result t a b c)
partT,!t2 (Result t a b c)
partF) = forall (t2 :: * -> *) (t :: * -> *) a b c.
(InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)),
 InsertLeft t2 c, Monoid (t2 c), Ord c) =>
t2 (Result t a b c) -> (t2 (Result t a b c), t2 (Result t a b c))
innerPartitioningR t2 (Result t a b c)
dataF
{-# NOINLINE maximumGroupsClassificationR2 #-}

maximumGroupsClassificationR
  :: (InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)), InsertLeft t2 c, Monoid (t2 c), Ord c, Integral d) => d
  -> t2 (Result t a b c)
  -> (t2 (Result t a b c), t2 (Result t a b c))
maximumGroupsClassificationR :: forall (t2 :: * -> *) (t :: * -> *) a b c d.
(InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)),
 InsertLeft t2 c, Monoid (t2 c), Ord c, Integral d) =>
d
-> t2 (Result t a b c)
-> (t2 (Result t a b c), t2 (Result t a b c))
maximumGroupsClassificationR !d
nGroups t2 (Result t a b c)
dataR
 | forall (t :: * -> *) a. Foldable t => t a -> Bool
F.null t2 (Result t a b c)
dataR = (forall a. Monoid a => a
mempty,forall a. Monoid a => a
mempty)
 | d
nGroups forall a. Ord a => a -> a -> Bool
<= d
0 = forall (t2 :: * -> *) (t :: * -> *) a b c.
(InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)),
 InsertLeft t2 c, Monoid (t2 c), Ord c) =>
t2 (Result t a b c) -> (t2 (Result t a b c), t2 (Result t a b c))
innerPartitioningR t2 (Result t a b c)
dataR
 | Bool
otherwise = forall (t2 :: * -> *) (t :: * -> *) a b c d.
(InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)),
 Ord c, InsertLeft t2 c, Monoid (t2 c), Integral d) =>
d
-> (t2 (Result t a b c), t2 (Result t a b c))
-> (t2 (Result t a b c), t2 (Result t a b c))
maximumGroupsClassificationR2 (d
nGroups forall a. Num a => a -> a -> a
- d
1) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t2 :: * -> *) (t :: * -> *) a b c.
(InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)),
 InsertLeft t2 c, Monoid (t2 c), Ord c) =>
t2 (Result t a b c) -> (t2 (Result t a b c), t2 (Result t a b c))
innerPartitioningR forall a b. (a -> b) -> a -> b
$ t2 (Result t a b c)
dataR
{-# NOINLINE maximumGroupsClassificationR #-}

toResultR
  :: FuncRep2 (t a) b c
  -> t a
  -> Result t a b c
toResultR :: forall (t :: * -> *) a b c.
FuncRep2 (t a) b c -> t a -> Result t a b c
toResultR !FuncRep2 (t a) b c
frep2 !t a
ys = R { line :: t a
line = t a
ys, propertiesF :: b
propertiesF = b
m, transPropertiesF :: c
transPropertiesF = c
tm}
  where !m :: b
m = forall a b c. FuncRep2 a b c -> a -> b
getAB FuncRep2 (t a) b c
frep2 t a
ys
        !tm :: c
tm = forall a b c. FuncRep2 a b c -> b -> c
getBC FuncRep2 (t a) b c
frep2 b
m
{-# INLINE toResultR #-}

toPropertiesF'
  :: FuncRep2 (t a) b c
  -> t a
  -> b
toPropertiesF' :: forall (t :: * -> *) a b c. FuncRep2 (t a) b c -> t a -> b
toPropertiesF' !FuncRep2 (t a) b c
frep2 !t a
ys = forall a b c. FuncRep2 a b c -> a -> b
getAB FuncRep2 (t a) b c
frep2 t a
ys
{-# INLINE toPropertiesF' #-}

toTransPropertiesF'
  :: FuncRep2 (t a) b c
  -> t a
  -> c
toTransPropertiesF' :: forall (t :: * -> *) a b c. FuncRep2 (t a) b c -> t a -> c
toTransPropertiesF' !FuncRep2 (t a) b c
frep2 !t a
ys = forall a b c. FuncRep2 a b c -> a -> c
getAC FuncRep2 (t a) b c
frep2 t a
ys
{-# INLINE toTransPropertiesF' #-}

-- | The second argument must be not empty for the function to work correctly.
partiR
  :: (InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)), InsertLeft t2 c) => (c -> Bool)
  -> t2 (Result t a b c)
  -> (t2 (Result t a b c), t2 (Result t a b c))
partiR :: forall (t2 :: * -> *) (t :: * -> *) a b c.
(InsertLeft t2 (Result t a b c), Monoid (t2 (Result t a b c)),
 InsertLeft t2 c) =>
(c -> Bool)
-> t2 (Result t a b c)
-> (t2 (Result t a b c), t2 (Result t a b c))
partiR c -> Bool
p t2 (Result t a b c)
dataR = forall (t :: * -> *) a.
(InsertLeft t a, Monoid (t a)) =>
(a -> Bool) -> t a -> (t a, t a)
partitionG (c -> Bool
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a b c. Result t a b c -> c
transPropertiesF) t2 (Result t a b c)
dataR
{-# INLINE partiR #-}

-----------------------------------------------------------

maximumEl2
  :: (F.Foldable t2, Ord c) => FuncRep2 a b c
  -> t2 a
  -> Result2 a b c
maximumEl2 :: forall (t2 :: * -> *) c a b.
(Foldable t2, Ord c) =>
FuncRep2 a b c -> t2 a -> Result2 a b c
maximumEl2 !FuncRep2 a b c
frep2 t2 a
data0 =
  let !l :: a
l = forall (t :: * -> *) a.
Foldable t =>
(a -> a -> Ordering) -> t a -> a
F.maximumBy (\a
x a
y -> forall a. Ord a => a -> a -> Ordering
compare (forall a b c. FuncRep2 a b c -> a -> c
getAC FuncRep2 a b c
frep2 a
x) (forall a b c. FuncRep2 a b c -> a -> c
getAC FuncRep2 a b c
frep2 a
y)) t2 a
data0
      !m :: b
m = forall a b c. FuncRep2 a b c -> a -> b
getAB FuncRep2 a b c
frep2 a
l
      !tm :: c
tm = forall a b c. FuncRep2 a b c -> b -> c
getBC FuncRep2 a b c
frep2 b
m in R2 {line2 :: a
line2 = a
l, propertiesF2 :: b
propertiesF2 = b
m, transPropertiesF2 :: c
transPropertiesF2 = c
tm}
{-# INLINE maximumEl2 #-}

minMaximumEls2
  :: (InsertLeft t2 a, Monoid (t2 a), Ord a, Ord c) => FuncRep2 a b c
  -> t2 a
  -> (Result2 a b c,Result2 a b c)
minMaximumEls2 :: forall (t2 :: * -> *) a c b.
(InsertLeft t2 a, Monoid (t2 a), Ord a, Ord c) =>
FuncRep2 a b c -> t2 a -> (Result2 a b c, Result2 a b c)
minMaximumEls2 !FuncRep2 a b c
frep2 t2 a
data0 =
  let (!a
ln,!a
lx) = forall a (t :: * -> *).
(Ord a, InsertLeft t a, Monoid (t a)) =>
(a -> a -> Ordering) -> t a -> (a, a)
minMax11ByC (\a
x a
y -> forall a. Ord a => a -> a -> Ordering
compare (forall a b c. FuncRep2 a b c -> a -> c
getAC FuncRep2 a b c
frep2 a
x) (forall a b c. FuncRep2 a b c -> a -> c
getAC FuncRep2 a b c
frep2 a
y)) t2 a
data0
      !mn :: b
mn = forall a b c. FuncRep2 a b c -> a -> b
getAB FuncRep2 a b c
frep2 a
ln
      !mx :: b
mx = forall a b c. FuncRep2 a b c -> a -> b
getAB FuncRep2 a b c
frep2 a
lx
      !tmn :: c
tmn = forall a b c. FuncRep2 a b c -> b -> c
getBC FuncRep2 a b c
frep2 b
mn
      !tmx :: c
tmx = forall a b c. FuncRep2 a b c -> b -> c
getBC FuncRep2 a b c
frep2 b
mx in (R2 {line2 :: a
line2 = a
ln, propertiesF2 :: b
propertiesF2 = b
mn, transPropertiesF2 :: c
transPropertiesF2 = c
tmn}, R2 {line2 :: a
line2 = a
lx, propertiesF2 :: b
propertiesF2 = b
mx, transPropertiesF2 :: c
transPropertiesF2 = c
tmx})
{-# INLINE minMaximumEls2 #-}

maximumElR2
  :: (F.Foldable t2, Ord c) => t2 (Result2 a b c)
  -> Result2 a b c
maximumElR2 :: forall (t2 :: * -> *) c a b.
(Foldable t2, Ord c) =>
t2 (Result2 a b c) -> Result2 a b c
maximumElR2 = forall (t :: * -> *) a.
Foldable t =>
(a -> a -> Ordering) -> t a -> a
F.maximumBy (\Result2 a b c
x Result2 a b c
y -> forall a. Ord a => a -> a -> Ordering
compare (forall a b c. Result2 a b c -> c
transPropertiesF2 Result2 a b c
x) (forall a b c. Result2 a b c -> c
transPropertiesF2 Result2 a b c
y))
{-# INLINE maximumElR2 #-}

minMaximumElRs2
  :: (InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)), Ord a, Ord b, Ord c) => t2 (Result2 a b c)
  -> (Result2 a b c,Result2 a b c)
minMaximumElRs2 :: forall (t2 :: * -> *) a b c.
(InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)), Ord a,
 Ord b, Ord c) =>
t2 (Result2 a b c) -> (Result2 a b c, Result2 a b c)
minMaximumElRs2 = forall a (t :: * -> *).
(Ord a, InsertLeft t a, Monoid (t a)) =>
(a -> a -> Ordering) -> t a -> (a, a)
minMax11ByC (\Result2 a b c
x Result2 a b c
y -> forall a. Ord a => a -> a -> Ordering
compare (forall a b c. Result2 a b c -> c
transPropertiesF2 Result2 a b c
x) (forall a b c. Result2 a b c -> c
transPropertiesF2 Result2 a b c
y))
{-# INLINE minMaximumElRs2 #-}

-----------------------------------------------------------------------------------

-- | The second argument must be not empty for the function to work correctly.
innerPartitioning2
  :: (InsertLeft t2 a, Monoid (t2 a), InsertLeft t2 c, Monoid (t2 c), Ord c) => FuncRep2 a b c
  -> t2 a
  -> (t2 a, t2 a)
innerPartitioning2 :: forall (t2 :: * -> *) a c b.
(InsertLeft t2 a, Monoid (t2 a), InsertLeft t2 c, Monoid (t2 c),
 Ord c) =>
FuncRep2 a b c -> t2 a -> (t2 a, t2 a)
innerPartitioning2 !FuncRep2 a b c
frep2 t2 a
data0 =
  let !l :: c
l = forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
F.maximum forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) b a.
(InsertLeft t b, Monoid (t b)) =>
(a -> b) -> t a -> t b
mapG (forall a b c. FuncRep2 a b c -> a -> c
toTransPropertiesF'2 FuncRep2 a b c
frep2) forall a b. (a -> b) -> a -> b
$ t2 a
data0 in forall (t :: * -> *) a.
(InsertLeft t a, Monoid (t a)) =>
(a -> Bool) -> t a -> (t a, t a)
partitionG ((forall a. Eq a => a -> a -> Bool
== c
l) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. FuncRep2 a b c -> a -> c
getAC FuncRep2 a b c
frep2) t2 a
data0
{-# INLINE innerPartitioning2 #-}

-- | The first argument must be not empty for the function to work correctly.
innerPartitioningR2
  :: (InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)), InsertLeft t2 c, Monoid (t2 c), Ord c) => t2 (Result2 a b c)
  -> (t2 (Result2 a b c), t2 (Result2 a b c))
innerPartitioningR2 :: forall (t2 :: * -> *) a b c.
(InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)),
 InsertLeft t2 c, Monoid (t2 c), Ord c) =>
t2 (Result2 a b c) -> (t2 (Result2 a b c), t2 (Result2 a b c))
innerPartitioningR2 t2 (Result2 a b c)
dataR =
  let !l :: c
l = forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
F.maximum forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) b a.
(InsertLeft t b, Monoid (t b)) =>
(a -> b) -> t a -> t b
mapG forall a b c. Result2 a b c -> c
transPropertiesF2 forall a b. (a -> b) -> a -> b
$ t2 (Result2 a b c)
dataR in forall (t :: * -> *) a.
(InsertLeft t a, Monoid (t a)) =>
(a -> Bool) -> t a -> (t a, t a)
partitionG ((forall a. Eq a => a -> a -> Bool
== c
l) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. Result2 a b c -> c
transPropertiesF2) t2 (Result2 a b c)
dataR
{-# INLINE innerPartitioningR2 #-}

maximumGroupsClassification2
  :: (InsertLeft t2 a, Monoid (t2 a), Ord c, InsertLeft t2 c, Monoid (t2 c), Integral d) => d
  -> FuncRep2 a b c
  -> (t2 a, t2 a)
  -> (t2 a, t2 a)
maximumGroupsClassification2 :: forall (t2 :: * -> *) a c d b.
(InsertLeft t2 a, Monoid (t2 a), Ord c, InsertLeft t2 c,
 Monoid (t2 c), Integral d) =>
d -> FuncRep2 a b c -> (t2 a, t2 a) -> (t2 a, t2 a)
maximumGroupsClassification2 !d
nGroups !FuncRep2 a b c
frep2 (t2 a
dataT,t2 a
dataF)
 | forall (t :: * -> *) a. Foldable t => t a -> Bool
F.null t2 a
dataF = (t2 a
dataT,forall a. Monoid a => a
mempty)
 | d
nGroups forall a. Ord a => a -> a -> Bool
<= d
0 = (t2 a
dataT,t2 a
dataF)
 | Bool
otherwise = forall (t2 :: * -> *) a c d b.
(InsertLeft t2 a, Monoid (t2 a), Ord c, InsertLeft t2 c,
 Monoid (t2 c), Integral d) =>
d -> FuncRep2 a b c -> (t2 a, t2 a) -> (t2 a, t2 a)
maximumGroupsClassification2 (d
nGroups forall a. Num a => a -> a -> a
- d
1) FuncRep2 a b c
frep2 (t2 a
dataT forall a. Monoid a => a -> a -> a
`mappend` t2 a
partT,t2 a
partF)
     where (!t2 a
partT,!t2 a
partF) = forall (t2 :: * -> *) a c b.
(InsertLeft t2 a, Monoid (t2 a), InsertLeft t2 c, Monoid (t2 c),
 Ord c) =>
FuncRep2 a b c -> t2 a -> (t2 a, t2 a)
innerPartitioning2 FuncRep2 a b c
frep2 t2 a
dataF
{-# NOINLINE maximumGroupsClassification2 #-}

maximumGroupsClassification12
  :: (InsertLeft t2 a, Monoid (t2 a), Ord c, InsertLeft t2 c, Monoid (t2 c), Integral d) => d
  -> FuncRep2 a b c
  -> t2 a
  -> (t2 a, t2 a)
maximumGroupsClassification12 :: forall (t2 :: * -> *) a c d b.
(InsertLeft t2 a, Monoid (t2 a), Ord c, InsertLeft t2 c,
 Monoid (t2 c), Integral d) =>
d -> FuncRep2 a b c -> t2 a -> (t2 a, t2 a)
maximumGroupsClassification12 !d
nGroups !FuncRep2 a b c
frep2 t2 a
data0
 | forall (t :: * -> *) a. Foldable t => t a -> Bool
F.null t2 a
data0 = (forall a. Monoid a => a
mempty,forall a. Monoid a => a
mempty)
 | d
nGroups forall a. Ord a => a -> a -> Bool
<= d
0 = forall (t2 :: * -> *) a c b.
(InsertLeft t2 a, Monoid (t2 a), InsertLeft t2 c, Monoid (t2 c),
 Ord c) =>
FuncRep2 a b c -> t2 a -> (t2 a, t2 a)
innerPartitioning2 FuncRep2 a b c
frep2 t2 a
data0
 | Bool
otherwise = forall (t2 :: * -> *) a c d b.
(InsertLeft t2 a, Monoid (t2 a), Ord c, InsertLeft t2 c,
 Monoid (t2 c), Integral d) =>
d -> FuncRep2 a b c -> (t2 a, t2 a) -> (t2 a, t2 a)
maximumGroupsClassification2 (d
nGroups forall a. Num a => a -> a -> a
- d
1) FuncRep2 a b c
frep2 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t2 :: * -> *) a c b.
(InsertLeft t2 a, Monoid (t2 a), InsertLeft t2 c, Monoid (t2 c),
 Ord c) =>
FuncRep2 a b c -> t2 a -> (t2 a, t2 a)
innerPartitioning2 FuncRep2 a b c
frep2 forall a b. (a -> b) -> a -> b
$ t2 a
data0
{-# NOINLINE maximumGroupsClassification12 #-}

maximumGroupsClassificationR2_2
  :: (InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)), Ord c, InsertLeft t2 c, Monoid (t2 c), Integral d) => d
  -> (t2 (Result2 a b c), t2 (Result2 a b c))
  -> (t2 (Result2 a b c), t2 (Result2 a b c))
maximumGroupsClassificationR2_2 :: forall (t2 :: * -> *) a b c d.
(InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)), Ord c,
 InsertLeft t2 c, Monoid (t2 c), Integral d) =>
d
-> (t2 (Result2 a b c), t2 (Result2 a b c))
-> (t2 (Result2 a b c), t2 (Result2 a b c))
maximumGroupsClassificationR2_2 !d
nGroups (t2 (Result2 a b c)
dataT,t2 (Result2 a b c)
dataF)
 | forall (t :: * -> *) a. Foldable t => t a -> Bool
F.null t2 (Result2 a b c)
dataF = (t2 (Result2 a b c)
dataT,forall a. Monoid a => a
mempty)
 | d
nGroups forall a. Ord a => a -> a -> Bool
<= d
0 = (t2 (Result2 a b c)
dataT,t2 (Result2 a b c)
dataF)
 | Bool
otherwise = forall (t2 :: * -> *) a b c d.
(InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)), Ord c,
 InsertLeft t2 c, Monoid (t2 c), Integral d) =>
d
-> (t2 (Result2 a b c), t2 (Result2 a b c))
-> (t2 (Result2 a b c), t2 (Result2 a b c))
maximumGroupsClassificationR2_2 (d
nGroups forall a. Num a => a -> a -> a
- d
1) (t2 (Result2 a b c)
dataT forall a. Monoid a => a -> a -> a
`mappend` t2 (Result2 a b c)
partT,t2 (Result2 a b c)
partF)
     where (!t2 (Result2 a b c)
partT,!t2 (Result2 a b c)
partF) = forall (t2 :: * -> *) a b c.
(InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)),
 InsertLeft t2 c, Monoid (t2 c), Ord c) =>
t2 (Result2 a b c) -> (t2 (Result2 a b c), t2 (Result2 a b c))
innerPartitioningR2 t2 (Result2 a b c)
dataF
{-# NOINLINE maximumGroupsClassificationR2_2 #-}

maximumGroupsClassificationR_2
  :: (InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)), InsertLeft t2 c, Monoid (t2 c), Ord c, Integral d) => d
  -> t2 (Result2 a b c)
  -> (t2 (Result2 a b c), t2 (Result2 a b c))
maximumGroupsClassificationR_2 :: forall (t2 :: * -> *) a b c d.
(InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)),
 InsertLeft t2 c, Monoid (t2 c), Ord c, Integral d) =>
d -> t2 (Result2 a b c) -> (t2 (Result2 a b c), t2 (Result2 a b c))
maximumGroupsClassificationR_2 !d
nGroups t2 (Result2 a b c)
dataR
 | forall (t :: * -> *) a. Foldable t => t a -> Bool
F.null t2 (Result2 a b c)
dataR = (forall a. Monoid a => a
mempty,forall a. Monoid a => a
mempty)
 | d
nGroups forall a. Ord a => a -> a -> Bool
<= d
0 = forall (t2 :: * -> *) a b c.
(InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)),
 InsertLeft t2 c, Monoid (t2 c), Ord c) =>
t2 (Result2 a b c) -> (t2 (Result2 a b c), t2 (Result2 a b c))
innerPartitioningR2 t2 (Result2 a b c)
dataR
 | Bool
otherwise = forall (t2 :: * -> *) a b c d.
(InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)), Ord c,
 InsertLeft t2 c, Monoid (t2 c), Integral d) =>
d
-> (t2 (Result2 a b c), t2 (Result2 a b c))
-> (t2 (Result2 a b c), t2 (Result2 a b c))
maximumGroupsClassificationR2_2 (d
nGroups forall a. Num a => a -> a -> a
- d
1) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t2 :: * -> *) a b c.
(InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)),
 InsertLeft t2 c, Monoid (t2 c), Ord c) =>
t2 (Result2 a b c) -> (t2 (Result2 a b c), t2 (Result2 a b c))
innerPartitioningR2 forall a b. (a -> b) -> a -> b
$ t2 (Result2 a b c)
dataR
{-# NOINLINE maximumGroupsClassificationR_2 #-}

toResultR2
  :: FuncRep2 a b c
  -> a
  -> Result2 a b c
toResultR2 :: forall a b c. FuncRep2 a b c -> a -> Result2 a b c
toResultR2 !FuncRep2 a b c
frep2 !a
y = R2 { line2 :: a
line2 = a
y, propertiesF2 :: b
propertiesF2 = b
m, transPropertiesF2 :: c
transPropertiesF2 = c
tm}
  where !m :: b
m = forall a b c. FuncRep2 a b c -> a -> b
getAB FuncRep2 a b c
frep2 a
y
        !tm :: c
tm = forall a b c. FuncRep2 a b c -> b -> c
getBC FuncRep2 a b c
frep2 b
m
{-# INLINE toResultR2 #-}

toPropertiesF'2
  :: FuncRep2 a b c
  -> a
  -> b
toPropertiesF'2 :: forall a b c. FuncRep2 a b c -> a -> b
toPropertiesF'2 !FuncRep2 a b c
frep2 !a
y = forall a b c. FuncRep2 a b c -> a -> b
getAB FuncRep2 a b c
frep2 a
y
{-# INLINE toPropertiesF'2 #-}

toTransPropertiesF'2
  :: FuncRep2 a b c
  -> a
  -> c
toTransPropertiesF'2 :: forall a b c. FuncRep2 a b c -> a -> c
toTransPropertiesF'2 !FuncRep2 a b c
frep2 !a
y = forall a b c. FuncRep2 a b c -> a -> c
getAC FuncRep2 a b c
frep2 a
y
{-# INLINE toTransPropertiesF'2 #-}

-- | The second argument must be not empty for the function to work correctly.
partiR2
  :: (InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)), InsertLeft t2 c) => (c -> Bool)
  -> t2 (Result2 a b c)
  -> (t2 (Result2 a b c), t2 (Result2 a b c))
partiR2 :: forall (t2 :: * -> *) a b c.
(InsertLeft t2 (Result2 a b c), Monoid (t2 (Result2 a b c)),
 InsertLeft t2 c) =>
(c -> Bool)
-> t2 (Result2 a b c) -> (t2 (Result2 a b c), t2 (Result2 a b c))
partiR2 c -> Bool
p t2 (Result2 a b c)
dataR = forall (t :: * -> *) a.
(InsertLeft t a, Monoid (t a)) =>
(a -> Bool) -> t a -> (t a, t a)
partitionG (c -> Bool
p forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. Result2 a b c -> c
transPropertiesF2) t2 (Result2 a b c)
dataR
{-# INLINE partiR2 #-}