]> Git — Sourcephile - literate-phylomemy.git/blob - tests/Phylomemy/IndexationSpec.hs
init
[literate-phylomemy.git] / tests / Phylomemy / IndexationSpec.hs
1 {-# OPTIONS_GHC -Wno-orphans #-}
2
3 module Phylomemy.IndexationSpec where
4
5 import Data.Eq (Eq)
6 import Data.Function ((.))
7 import Data.Functor ((<$>))
8 import Data.GenValidity
9 import Data.GenValidity.Map ()
10 import Data.GenValidity.Sequence ()
11 import Data.GenValidity.Set ()
12 import Data.GenValidity.Text ()
13 import Data.GenValidity.Time ()
14 import Data.Int (Int)
15 import Data.Ord (Ord)
16 import Data.Sequence qualified as Seq
17 import Data.Text.Short (ShortText)
18 import Data.Text.Short qualified as ShortText
19 import Data.Time (UTCTime)
20 import Data.Validity.Map ()
21 import Data.Validity.Set ()
22 import Data.Validity.Text ()
23 import GHC.Generics (Generic)
24 import Test.Syd
25 import Test.Syd.Validity
26 import Text.Show (Show (..))
27 import Prelude (Num)
28
29 import Phylomemy
30
31 import Clustering.FrequentItemSet.BruteForce qualified as Clustering
32
33 instance Validity ShortText where
34 validate = trivialValidation
35 instance GenValid ShortText where
36 genValid = ShortText.fromText <$> genValid
37 shrinkValid = (ShortText.fromText <$>) . shrinkValid . ShortText.toText
38 instance GenValid Ngram
39 instance GenValid Root
40 instance (Validity pos, GenValid pos) => GenValid (Document pos)
41 instance GenValid CoOccurences where
42 genValid = genValidStructurallyWithoutExtraChecking
43 shrinkValid = shrinkValidStructurallyWithoutExtraFiltering
44 instance (Ord item, Validity item, Validity a, GenValid item, GenValid a) => GenValid (Clustering.Transaction item a)
45 instance (Ord pos, Validity pos, GenValid pos) => GenValid (Range pos)
46
47 newtype Pos = Pos Int
48 deriving (Eq, Ord, Show, Num, Generic)
49 instance ShowHuman Pos where
50 showHuman (Pos x) = show x
51 instance Validity Pos
52 instance GenValid Pos
53
54 type Rang = Range Pos
55
56 spec :: Spec
57 spec = do
58 genValidSpec @(Document UTCTime)
59 monoidSpec @CoOccurences
60 genValidSpec @Cluster
61 genValidSpec @(Clustering.Transaction Root (Document ()))
62 genValidSpec @(Rang :-> Clustering.Transaction Root (Document ()))
63 genValidSpec @(Rang :-> Cluster :-> Seq.Seq (Clustering.Transaction Root (Document Pos)))