phonetic-languages-basis (empty) → 0.1.0.0
raw patch · 6 files changed
+171/−0 lines, 6 filesdep +basesetup-changed
Dependencies added: base
Files
- CHANGELOG.md +6/−0
- LICENSE +20/−0
- Phonetic/Languages/Basis.hs +32/−0
- Phonetic/Languages/UniquenessPeriodsG.hs +89/−0
- Setup.hs +2/−0
- phonetic-languages-basis.cabal +22/−0
+ CHANGELOG.md view
@@ -0,0 +1,6 @@+# Revision history for phonetic-languages-basis++## 0.1.0.0 -- 2022-05-31++* First version. Released on an unsuspecting world. Is taken from the phonetic-languages-simplified-base package to change the import and dependencies trees.+
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2020-2022 OleksandrZhabenko++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Phonetic/Languages/Basis.hs view
@@ -0,0 +1,32 @@+{-# OPTIONS_HADDOCK show-extensions #-}++-- |+-- Module : Phonetic.Languages.Basis+-- Copyright : (c) OleksandrZhabenko 2020-2022+-- License : MIT+-- Stability : Experimental+-- Maintainer : olexandr543@yahoo.com+--+-- Simplified version of the @phonetic-languages-common@ and @phonetic-languages-general@ packages.+-- Uses less dependencies.++{-# LANGUAGE BangPatterns, FlexibleContexts #-}++module Phonetic.Languages.Basis where++data Result t a b c = R {line :: !(t a), propertiesF :: !b, transPropertiesF :: !c} deriving Eq++instance (Ord (t a), Ord b, Ord c) => Ord (Result t a b c) where+ compare x y+ = case compare (transPropertiesF x) (transPropertiesF y) of+ !EQ -> case compare (propertiesF x) (propertiesF y) of+ !EQ -> compare (line x) (line y)+ !z -> z+ !z0 -> z0+ {-# INLINE compare #-}++data FuncRep2 a b c = D { getAB :: (a -> b), getBC :: (b -> c) }++getAC :: FuncRep2 a b c -> (a -> c)+getAC (D f g) = g . f+{-# INLINE getAC #-}
+ Phonetic/Languages/UniquenessPeriodsG.hs view
@@ -0,0 +1,89 @@+{-# OPTIONS_HADDOCK show-extensions #-}++-- |+-- Module : Phonetic.Languages.UniquenessPeriodsG+-- Copyright : (c) OleksandrZhabenko 2020-2022+-- License : MIT+-- Stability : Experimental+-- Maintainer : olexandr543@yahoo.com+--+-- Generalization of the uniqueness-periods and uniqueness-periods-general+-- packages functionality. Uses less dependencies.+--++{-# LANGUAGE BangPatterns #-}++module Phonetic.Languages.UniquenessPeriodsG (+ -- * List functions+ uniquenessPeriodsGG+ , uniquenessPeriodsG+ , uniquenessPeriodsGI8+ , diverse2GGL+ , diverse2GL+ , diverse2GLInt8+)where++import GHC.Int+import Data.List+import Data.Maybe (mapMaybe)++diverse2GGL :: (Foldable t, Ord a) => a -> [a] -> t a -> Int16+diverse2GGL delim whspss = sum . uniquenessPeriodsGG delim whspss+{-# INLINE diverse2GGL #-}++-- | A generalization of the uniquenessPeriods function of the @uniqueness-periods@ package.+uniquenessPeriodsGG :: (Foldable t, Ord a) => a -> [a] -> t a -> [Int16]+uniquenessPeriodsGG delim whspss ws+ | null ws = []+ | otherwise = mapMaybe (helpG sum whspss) . unfoldr f $ ks+ where !ks = indexedL delim ws+ !vs = mapMaybe g ks+ g x+ | (`elem` whspss) . snd $ x = Just (fst x)+ | otherwise = Nothing+ {-# INLINE g #-}+ f !x+ | null x = Nothing+ | otherwise = let !idX0 = snd . head $ x in Just . (\vws (v2,v3) -> ((helpUPV3 vws [] .+ map fst $ v2,snd . head $ v2),v3)) vs . partition (\(_,xs) -> xs == idX0) $ x+{-# INLINE uniquenessPeriodsGG #-}++-- | A variant of the 'diverse2GGL' function for 'Char'.+diverse2GL :: Foldable t => String -> t Char -> Int16+diverse2GL = diverse2GGL '\00'+{-# INLINE diverse2GL #-}++-- | A variant for the 'uniquenessPeriodsGG' function for 'Char'.+uniquenessPeriodsG :: Foldable t => String -> t Char -> [Int16]+uniquenessPeriodsG = uniquenessPeriodsGG '\00'+{-# INLINE uniquenessPeriodsG #-}++-- | A variant of the 'diverse2GGL' function for 'Int8'.+diverse2GLInt8 :: Foldable t => [Int8] -> t Int8 -> Int16+diverse2GLInt8 = diverse2GGL (-1::Int8)+{-# INLINE diverse2GLInt8 #-}++-- | A variant for the 'uniquenessPeriodsGG' function for 'Int8'.+uniquenessPeriodsGI8 :: Foldable t => [Int8] -> t Int8 -> [Int16]+uniquenessPeriodsGI8 = uniquenessPeriodsGG (-1::Int8)+{-# INLINE uniquenessPeriodsGI8 #-}++-- | The first and the third list arguments of numbers (if not empty) must be sorted in the ascending order.+helpUPV3 :: [Int16] -> [Int16] -> [Int16] -> [Int16]+helpUPV3 (z:zs) !acc (x:y:xs)+ | compare ((x - z) * (y - z)) 0 == LT = helpUPV3 zs ((y - x):acc) (y:xs)+ | compare y z == GT = helpUPV3 zs acc (x:y:xs)+ | otherwise = helpUPV3 (z:zs) acc (y:xs)+helpUPV3 _ !acc _ = acc++indexedL :: Foldable t => b -> t b -> [(Int16, b)]+indexedL y = foldr f v+ where v = [(1::Int16,y)]+ f x ((j,z):ys) = (j-1,x):(j,z):ys++helpG :: (Eq a) => ([b] -> b) -> [a] -> ([b], a) -> Maybe b+helpG h xs (ts, x)+ | null ts = Nothing+ | x `elem` xs = Nothing+ | otherwise = Just (h ts)+{-# INLINE helpG #-}
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ phonetic-languages-basis.cabal view
@@ -0,0 +1,22 @@+name: phonetic-languages-basis+version: 0.1.0.0+synopsis: A basics of the phonetic-languages functionality.+description: The common for different realizations functionality. Just the necessary one.+homepage: https://hackage.haskell.org/package/phonetic-languages-basis+license: MIT+license-file: LICENSE+author: OleksandrZhabenko+maintainer: olexandr543@yahoo.com+copyright: Oleksandr Zhabenko+category: Language,Math,Game+build-type: Simple+extra-source-files: CHANGELOG.md+cabal-version: >=1.10++library+ exposed-modules: Phonetic.Languages.Basis, Phonetic.Languages.UniquenessPeriodsG+ -- other-modules:+ other-extensions: BangPatterns, FlexibleContexts+ build-depends: base >=4.8 && <5+ -- hs-source-dirs:+ default-language: Haskell2010