{-# OPTIONS_HADDOCK show-extensions #-}
{-# LANGUAGE BangPatterns #-}
module Phonetic.Languages.Simplified.StrictVG.Base (
uniquenessVariants2GNBL
, uniquenessVariants2GNPBL
) where
import Phonetic.Languages.Permutations.Arr
import Phonetic.Languages.Simplified.DataG.Base
import qualified Data.Foldable as F
import Data.SubG
import GHC.Arr
import Data.Monoid
uniquenessVariants2GNBL ::
(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
-> (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 #-}
uniquenessVariants2GNPBL ::
(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
-> 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 (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 (t :: * -> *) a. Foldable t => t a -> Int
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 #-}