]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Core/Flow.hs
[FIX] mkNode.
[gargantext.git] / src / Gargantext / Core / Flow.hs
1 {-|
2 Module : Gargantext.Core.Flow
3 Description : Core Flow main Types
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 -}
11
12 {-# LANGUAGE ConstraintKinds #-}
13 {-# LANGUAGE RankNTypes #-}
14 {-# LANGUAGE ConstrainedClassMethods #-}
15
16 module Gargantext.Core.Flow where
17
18 import Control.Lens (Lens')
19 import Data.Map (Map)
20 import Data.Text (Text)
21 import Gargantext.Text.Terms (TermType)
22 import Gargantext.Core (Lang)
23 import Gargantext.Database.Schema.Ngrams (Ngrams, NgramsType)
24 import Gargantext.Core.Types.Main (HashId)
25 import Gargantext.Database.Types.Node -- (HyperdataDocument(..))
26 import Gargantext.Database.Node.Contact -- (HyperdataContact(..))
27 import Gargantext.Database.Node.Document.Insert (AddUniqId, InsertDb)
28 import Gargantext.Database.Utils (Cmd)
29
30 type FlowCorpus a = ( AddUniqId a
31 , UniqId a
32 , InsertDb a
33 , ExtractNgramsT a
34 , HasText a
35 )
36
37 class UniqId a
38 where
39 uniqId :: Lens' a (Maybe HashId)
40
41 class ExtractNgramsT h
42 where
43 extractNgramsT :: HasText h => TermType Lang -> h -> Cmd err (Map Ngrams (Map NgramsType Int))
44
45 class HasText h
46 where
47 hasText :: h -> [Text]
48
49 ------------------------------------------------------------------------
50
51 instance UniqId HyperdataDocument
52 where
53 uniqId = hyperdataDocument_uniqId
54
55 instance UniqId HyperdataContact
56 where
57 uniqId = hc_uniqId
58
59