{-# OPTIONS_GHC -Wno-orphans #-} module Phylomemy.Indexation where import Data.Eq (Eq) import Data.Map.Strict qualified as Map import Data.Monoid (Monoid (..)) import Data.Ord (Ord) import Data.Set qualified as Set import Data.Text.Short (ShortText) import Data.Time (UTCTime) import Data.Validity (Validity (..), declare, delve, trivialValidation) import Data.Validity.Map () import Data.Validity.Set () import Data.Validity.Time () import GHC.Generics (Generic) import Text.Show (Show) type Date = UTCTime -- | A contiguous sequence of n terms newtype Ngram = Ngram ShortText deriving (Eq, Generic, Ord) deriving stock (Show) instance Validity Ngram where validate = trivialValidation -- | A 'Root' is a set of `Ngram`s conveying the same meaning -- (according to the analyst). data Root = Root { rootLabel :: Ngram , rootEquivalents :: Set.Set Ngram } deriving (Eq, Generic, Ord, Show) instance Validity Root where validate r = mconcat [ delve "rootLabel" (rootLabel r) , declare "The rootLabel is not a member of the rootEquivalents" (Set.notMember (rootLabel r) (rootEquivalents r)) , delve "rootEquivalents" (rootEquivalents r) ] type Foundations = Set.Set Root data Document = Document { documentDate :: Date , documentRoots :: Map.Map Root () } deriving (Eq, Generic, Show) instance Validity Document data Period = Period { periodBegin :: Date , periodEnd :: Date -- , periodScales :: [Scale] } deriving (Eq, Generic, Show) instance Validity Period type Vocabulary = Map.Map Root ()