phonetic-languages-simplified-properties-array-common (empty) → 0.1.0.0
raw patch · 5 files changed
+157/−0 lines, 5 filesdep +basedep +phonetic-languages-basisdep +phonetic-languages-rhythmicitysetup-changed
Dependencies added: base, phonetic-languages-basis, phonetic-languages-rhythmicity
Files
- CHANGELOG.md +7/−0
- LICENSE +20/−0
- Phonetic/Languages/Array/Ukrainian/Common.hs +106/−0
- Setup.hs +2/−0
- phonetic-languages-simplified-properties-array-common.cabal +22/−0
+ CHANGELOG.md view
@@ -0,0 +1,7 @@+# Revision history for phonetic-languages-simplified-properties-array-common++## 0.1.0.0 -- 2022-05-31++* First version. Released on an unsuspecting world. Is taken from the phonetic-languages-simplified-properties-array+package.+
+ 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/Array/Ukrainian/Common.hs view
@@ -0,0 +1,106 @@+{-# OPTIONS_HADDOCK show-extensions #-}++-- |+-- Module : Phonetic.Languages.Array.Ukrainian.Common+-- Copyright : (c) OleksandrZhabenko 2020-2022+-- License : MIT+-- Stability : Experimental+-- Maintainer : olexandr543@yahoo.com+--+-- Generalization of the functionality of the DobutokO.Poetry.Norms+-- and DobutokO.Poetry.Norms.Extended modules+-- from the @dobutokO-poetry@ package. Instead of vectors, uses arrays.++{-# LANGUAGE CPP, BangPatterns #-}++module Phonetic.Languages.Array.Ukrainian.Common where++#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__>=710+/* code that applies only to GHC 7.10.* and higher versions */+import GHC.Base (mconcat)+#endif+#endif++import Phonetic.Languages.Basis+import Languages.Rhythmicity+import Languages.Rhythmicity.Factor+import Data.Maybe (fromMaybe,isNothing)+import Rhythmicity.PolyRhythm+import Text.Read (readMaybe)++#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__==708+/* code that applies only to GHC 7.8.* */+mconcat = concat+#endif+#endif++procRhythm23F+ :: (Ord c) => (Double -> c)+ -> String+ -> (String -> Coeffs2 -> String -> Double)+ -> Coeffs2+ -> FuncRep2 String Double c+procRhythm23F h choice g coeffs = Phonetic.Languages.Basis.D (g choice coeffs) h+{-# INLINE procRhythm23F #-}++parseChRhEndMaybe :: ParseChRh -> Maybe Int+parseChRhEndMaybe (P0 _) = Nothing+parseChRhEndMaybe (P1 _ _ n) = Just n+parseChRhEndMaybe (P2 _ _ _ n) = Just n++eval23Coeffs :: Coeffs2 -> [Double] -> Double+eval23Coeffs (CF2 x y) = evalRhythmicity23K (fromMaybe 1.0 x) (fromMaybe 1.0 y)+eval23Coeffs CF0 = evalRhythmicity23+{-# INLINE eval23Coeffs #-}++eval23CoeffsF :: Double -> Coeffs2 -> [Double] -> Double+eval23CoeffsF k (CF2 x y) = evalRhythmicity23KF k (fromMaybe 1.0 x) (fromMaybe 1.0 y)+eval23CoeffsF k CF0 = evalRhythmicity23F k+{-# INLINE eval23CoeffsF #-}++data CoeffTwo a = CF0 | CF2 (Maybe a) (Maybe a) deriving (Eq)++isEmpty :: CoeffTwo a -> Bool+isEmpty CF0 = True+isEmpty _ = False++isPair :: CoeffTwo a -> Bool+isPair CF0 = False+isPair _ = True++fstCF :: CoeffTwo a -> Maybe a+fstCF (CF2 x _) = x+fstCF _ = Nothing++sndCF :: CoeffTwo a -> Maybe a+sndCF (CF2 _ y) = y+sndCF _ = Nothing++readCF :: String -> Coeffs2+readCF xs+ | any (== '_') xs = let (!ys,!zs) = (\(ks,ts) -> (readMaybe ks::Maybe Double,readMaybe (drop 1 ts)::Maybe Double)) . break (== '_') $ xs in+ if (isNothing ys && isNothing zs) then CF0 else CF2 ys zs+ | otherwise = CF0++type Coeffs2 = CoeffTwo Double++--------------------------------------------------------------------------------------------++eval23 = evalRhythmicity23 . mconcat+{-# INLINE eval23 #-}++eval23K k2 k3 = evalRhythmicity23K k2 k3 . mconcat+{-# INLINE eval23K #-}++eval23F k = evalRhythmicity23F k . mconcat+{-# INLINE eval23F #-}++eval23KF k k2 k3 = evalRhythmicity23KF k k2 k3 . mconcat+{-# INLINE eval23KF #-}++words1 xs = if null ts then [] else w : words1 s'' -- Practically this is an optimized versio>+ where ts = dropWhile (< 1) xs+ (w, s'') = span (> 0) ts+{-# NOINLINE words1 #-}
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ phonetic-languages-simplified-properties-array-common.cabal view
@@ -0,0 +1,22 @@+name: phonetic-languages-simplified-properties-array-common+version: 0.1.0.0+synopsis: Common functionality for 'with-tuples' and old version of properties. +description: The common functionality for phonetic-languages-simplified-properties-array and phonetic-languages-simplified-properties-array-old packages.+homepage: https://hackage.haskell.org/package/phonetic-languages-simplified-properties-array-common+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.Array.Ukrainian.Common+ -- other-modules:+ other-extensions: BangPatterns, CPP+ build-depends: base >=4.8 && <5, phonetic-languages-rhythmicity ==0.9.2.0, phonetic-languages-basis ==0.1.0.0+ -- hs-source-dirs:+ default-language: Haskell2010