Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Przemyslaw Kaminski
haskell-gargantext
Commits
0cbdda21
Commit
0cbdda21
authored
Sep 18, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TREE] adding type NodeTree.
parent
99e95bb1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
27 deletions
+42
-27
Node.hs
src/Gargantext/API/Node.hs
+2
-2
Main.hs
src/Gargantext/Core/Types/Main.hs
+40
-25
No files found.
src/Gargantext/API/Node.hs
View file @
0cbdda21
...
...
@@ -49,7 +49,7 @@ import Gargantext.Database.Facet (FacetDoc, getDocFacet
import
Gargantext.TextFlow
import
Gargantext.Viz.Graph
(
Graph
)
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.Types.Main
(
Tree
)
import
Gargantext.Core.Types.Main
(
Tree
,
NodeTree
)
import
Gargantext.Text.Terms
(
TermType
(
..
))
-------------------------------------------------------------------
-------------------------------------------------------------------
...
...
@@ -112,7 +112,7 @@ type GraphAPI = Get '[JSON] Graph
graphAPI
::
Connection
->
NodeId
->
Server
GraphAPI
graphAPI
_
_
=
liftIO
$
textFlow
(
Mono
EN
)
(
Contexts
contextText
)
type
TreeAPI
=
Get
'[
J
SON
]
(
Tree
NodeT
yp
e
)
type
TreeAPI
=
Get
'[
J
SON
]
(
Tree
NodeT
re
e
)
treeAPI
::
Connection
->
NodeId
->
Server
TreeAPI
treeAPI
_
_
=
undefined
...
...
src/Gargantext/Core/Types/Main.hs
View file @
0cbdda21
...
...
@@ -15,18 +15,21 @@ Portability : POSIX
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
-----------------------------------------------------------------------
-
-----------------------------------------------------------------------
module
Gargantext.Core.Types.Main
where
------------------------------------------------------------------------
import
Data.Aeson
(
FromJSON
,
ToJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Eq
(
Eq
())
import
Data.Monoid
((
<>
))
import
Data.Text
(
Text
)
import
Data.Swagger
import
Gargantext.Database.Types.Node
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
Gargantext.Prelude
import
GHC.Generics
(
Generic
)
...
...
@@ -34,44 +37,36 @@ import Test.QuickCheck (elements)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
------------------------------------------------------------------------
-- All the Database is structred like a hierarchical Tree
data
Tree
a
=
NodeT
a
[
Tree
a
]
deriving
(
Show
,
Read
,
Eq
,
Generic
)
instance
ToJSON
(
Tree
NodeType
)
instance
FromJSON
(
Tree
NodeType
)
instance
ToSchema
(
Tree
NodeType
)
instance
Arbitrary
(
Tree
NodeType
)
where
arbitrary
=
elements
[
userTree
,
userTree
]
data
NodeTree
=
NodeTree
{
_nt_name
::
Text
,
_nt_type
::
NodeType
,
_nt_id
::
Int
}
deriving
(
Show
,
Read
,
Generic
)
-- data Tree a = NodeT a [Tree a]
-- same as Data.Tree
leafT
::
a
->
Tree
a
leafT
x
=
NodeT
x
[]
$
(
deriveJSON
(
unPrefix
"_nt_"
)
''
N
odeTree
)
------------------------------------------------------------------------
-- Garg Network is a network of all Garg nodes
--gargNetwork = undefined
-- | Garg Node is Database Schema Typed as specification
-- gargNode gathers all the Nodes of all users on one Node
gargNode
::
[
Tree
NodeT
yp
e
]
gargNode
::
[
Tree
NodeT
re
e
]
gargNode
=
[
userTree
]
-- | User Tree simplified
userTree
::
Tree
NodeT
yp
e
userTree
=
NodeT
NodeUser
[
projectTree
]
userTree
::
Tree
NodeT
re
e
userTree
=
NodeT
(
NodeTree
"user A"
NodeUser
1
)
[
projectTree
]
-- | Project Tree
projectTree
::
Tree
NodeT
yp
e
projectTree
=
NodeT
Project
[
corpusTree
]
projectTree
::
Tree
NodeT
re
e
projectTree
=
NodeT
(
NodeTree
"Project A"
Project
2
)
[
corpusTree
]
-- | Corpus Tree
corpusTree
::
Tree
NodeT
yp
e
corpusTree
=
NodeT
NodeCorpus
(
[
leafT
Document
]
<>
[
leafT
Lists
]
<>
[
leafT
Metrics
]
<>
[
leafT
Classification
]
corpusTree
::
Tree
NodeT
re
e
corpusTree
=
NodeT
(
NodeTree
"Corpus A"
NodeCorpus
3
)
(
[
leafT
$
NodeTree
"Doc"
Document
4
]
<>
[
leafT
(
NodeTree
"List A"
Lists
5
)
]
<>
[
leafT
(
NodeTree
"Metrics A"
Metrics
6
)
]
<>
[
leafT
(
NodeTree
"Class A"
Classification
7
)
]
)
-- TODO make instances of Nodes
...
...
@@ -135,3 +130,23 @@ type ParentId = NodeId
type
Limit
=
Int
type
Offset
=
Int
------------------------------------------------------------------------
-- All the Database is structred like a hierarchical Tree
data
Tree
a
=
NodeT
a
[
Tree
a
]
deriving
(
Show
,
Read
,
Eq
,
Generic
)
instance
ToJSON
(
Tree
NodeTree
)
instance
FromJSON
(
Tree
NodeTree
)
instance
ToSchema
NodeTree
instance
ToSchema
(
Tree
NodeTree
)
instance
Arbitrary
(
Tree
NodeTree
)
where
arbitrary
=
elements
[
userTree
,
userTree
]
-- data Tree a = NodeT a [Tree a]
-- same as Data.Tree
leafT
::
a
->
Tree
a
leafT
x
=
NodeT
x
[]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment