packages feed

phonetic-languages-basis-0.1.1.0: Phonetic/Languages/Basis.hs

{-# 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 #-}

data Result2 a b c = R2 {line2 :: !a, propertiesF2 :: !b,  transPropertiesF2 :: !c} deriving Eq

instance (Ord a, Ord b, Ord c) => Ord (Result2 a b c) where
  compare x y
    = case compare (transPropertiesF2 x) (transPropertiesF2 y) of
       !EQ -> case compare (propertiesF2 x) (propertiesF2 y) of
              !EQ -> compare (line2 x) (line2 y)
              !z -> z
       !z0 -> z0
  {-# INLINE compare #-}