{-# OPTIONS_HADDOCK show-extensions #-}
{-# LANGUAGE BangPatterns, NoImplicitPrelude #-}
module Aftovolio.StrictVG (
uniquenessVariants2GNBL
, uniquenessVariants2GNPBL
) where
import GHC.Base
import GHC.Num ((-))
import Aftovolio.PermutationsArr
import qualified Data.Foldable as F
import Data.InsertLeft (InsertLeft(..))
import GHC.Arr
uniquenessVariants2GNBL ::
(Eq a, F.Foldable t, InsertLeft t a, Monoid (t a), Monoid (t (t a))) => a
-> (t a -> [a])
-> ((t (t a)) -> [[a]])
-> ([a] -> t a)
-> [Array Int Int]
-> t (t a)
-> [t a]
uniquenessVariants2GNBL :: forall a (t :: * -> *).
(Eq a, Foldable t, InsertLeft t a, Monoid (t a),
Monoid (t (t a))) =>
a
-> (t a -> [a])
-> (t (t a) -> [[a]])
-> ([a] -> t a)
-> [Array Int Int]
-> t (t a)
-> [t a]
uniquenessVariants2GNBL !a
hd t a -> [a]
f1 t (t a) -> [[a]]
f2 [a] -> t a
f3 [Array Int Int]
perms !t (t a)
subs = t a
-> t a
-> a
-> (t a -> [a])
-> (t (t a) -> [[a]])
-> ([a] -> t a)
-> [Array Int Int]
-> t (t a)
-> [t a]
forall a (t :: * -> *).
(Eq a, Foldable t, InsertLeft t a, Monoid (t a),
Monoid (t (t a))) =>
t a
-> t a
-> a
-> (t a -> [a])
-> (t (t a) -> [[a]])
-> ([a] -> t a)
-> [Array Int Int]
-> t (t a)
-> [t a]
uniquenessVariants2GNPBL t a
forall a. Monoid a => a
mempty t a
forall a. Monoid a => a
mempty a
hd t a -> [a]
f1 t (t a) -> [[a]]
f2 [a] -> t a
f3 [Array Int Int]
perms t (t a)
subs
{-# INLINE uniquenessVariants2GNBL #-}
{-# SPECIALIZE uniquenessVariants2GNBL :: Char -> (String -> String) -> ([String] -> [String]) -> (String -> String) -> [Array Int Int] -> [String] -> [String] #-}
uniquenessVariants2GNPBL ::
(Eq a, F.Foldable t, InsertLeft t a, Monoid (t a), Monoid (t (t a))) => t a
-> t a
-> a
-> (t a -> [a])
-> ((t (t a)) -> [[a]])
-> ([a] -> t a)
-> [Array Int Int]
-> t (t a)
-> [t a]
uniquenessVariants2GNPBL :: forall a (t :: * -> *).
(Eq a, Foldable t, InsertLeft t a, Monoid (t a),
Monoid (t (t a))) =>
t a
-> t a
-> a
-> (t a -> [a])
-> (t (t a) -> [[a]])
-> ([a] -> t a)
-> [Array Int Int]
-> t (t a)
-> [t a]
uniquenessVariants2GNPBL !t a
ts !t a
us !a
hd t a -> [a]
f1 t (t a) -> [[a]]
f2 [a] -> t a
f3 [Array Int Int]
perms !t (t a)
subs
| t (t a) -> Bool
forall a. t a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
F.null t (t a)
subs = [t a]
forall a. Monoid a => a
mempty
| Bool
otherwise = ([a] -> t a) -> [[a]] -> [t a]
forall a b. (a -> b) -> [a] -> [b]
map [a] -> t a
f3 [[a]]
ns
where !uss :: t (t a)
uss = (a
hd a -> t a -> t a
forall (t :: * -> *) a. InsertLeft t a => a -> t a -> t a
%@ t a
us) t a -> t (t a) -> t (t a)
forall (t :: * -> *) a. InsertLeft t a => t a -> t (t a) -> t (t a)
%^ t (t a)
forall a. Monoid a => a
mempty
!base0 :: [[a]]
base0 = ([a] -> [a]) -> [[a]] -> [[a]]
forall a b. (a -> b) -> [a] -> [b]
map (a
hd a -> [a] -> [a]
forall (t :: * -> *) a. InsertLeft t a => a -> t a -> t a
%@) ([[a]] -> [[a]]) -> (t (t a) -> [[a]]) -> t (t a) -> [[a]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. t (t a) -> [[a]]
f2 (t (t a) -> [[a]]) -> t (t a) -> [[a]]
forall a b. (a -> b) -> a -> b
$ t (t a)
subs
!l :: Int
l = [[a]] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
F.length [[a]]
base0
!baseArr :: Array Int [a]
baseArr = (Int, Int) -> [[a]] -> Array Int [a]
forall i e. Ix i => (i, i) -> [e] -> Array i e
listArray (Int
0,Int
l Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) [[a]]
base0
!ns :: [[a]]
ns = t a
-> t (t a)
-> (t a -> [a])
-> (t (t a) -> [[a]])
-> [Array Int Int]
-> Array Int [a]
-> [[a]]
forall a (t :: * -> *).
(Eq a, Foldable t, InsertLeft t a, Monoid (t a),
Monoid (t (t a))) =>
t a
-> t (t a)
-> (t a -> [a])
-> (t (t a) -> [[a]])
-> [Array Int Int]
-> Array Int [a]
-> [[a]]
universalSetGL t a
ts t (t a)
uss t a -> [a]
f1 t (t a) -> [[a]]
f2 [Array Int Int]
perms Array Int [a]
baseArr
{-# INLINE uniquenessVariants2GNPBL #-}
{-# SPECIALIZE uniquenessVariants2GNPBL :: String -> String -> Char -> (String -> String) -> ([String] -> [String]) -> (String -> String) -> [Array Int Int] -> [String] -> [String] #-}