Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
11
Merge Requests
11
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
gargantext
haskell-gargantext
Commits
b50f2445
Commit
b50f2445
authored
Jun 13, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[BASHQL] doc + spec + first example.
parent
fa516072
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
32 deletions
+83
-32
Database.hs
src/Gargantext/Database.hs
+81
-30
Node.hs
src/Gargantext/Database/Node.hs
+1
-0
Prelude.hs
src/Gargantext/Prelude.hs
+1
-1
CSV.hs
src/Gargantext/Text/Parsers/CSV.hs
+0
-1
No files found.
src/Gargantext/Database.hs
View file @
b50f2445
{-|
Module : Gargantext.Database
Description :
Description :
Main commands of BASHQL a Domain Specific Language to deal with Gargantext Database.
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
Here is a longer description of this module, containing some
commentary with @some markup@.
* BASHQL = functional (Bash * SQL)
* Which language to chose when working with a database ? To make it
simple, instead of all common Object Relational Mapping (ORM) [1]
strategy used nowadays inspired more by object logic than functional
logic, the semantics of BASHQL focus on the function first.
* BASHQL focus on the function, i.e. use bash language function name,
and make it with SQL behind the scene. Then BASHQL is inspired more
by Bash language [2] than SQL and then follows its main commands as
specification and documentation.
* Main arguments:
1. Theoritical: database and FileSystems are each thought as a single
category, assumption based on theoretical work on databases by David Spivak [0].
2. Practical argument: basic bash commands are a daily practice among
developper community.
* How to help ?
1. Choose a command you like in Bash
2. Implement it in Haskell-SQL according to Gargantext Shema (Tree like
filesystem)
3. Translate it in BASHQL (follow previous implementations)
4. Make a pull request (enjoy the community)
* Implementation strategy: Functional adapations are made to the
gargantext languages options and SQL optimization are done continuously
during the project. For the Haskellish part, you may be inspired by
Turtle implementation written by Gabriel Gonzales [3] which shows how to
write Haskell bash translations.
* Semantics
- FileSystem is now a NodeSystem where each File is a Node in a Directed Graph (DG).
* References
[0] MIT Press has published "Category theory for the sciences". The book
can also be purchased on Amazon. Here are reviews by the MAA, by the
AMS, and by SIAM.
[1] https://en.wikipedia.org/wiki/Object-relational_mapping
[2] https://en.wikipedia.org/wiki/Bash_(Unix_shell)
[3] https://github.com/Gabriel439/Haskell-Turtle-Library
-}
{-# LANGUAGE NoImplicitPrelude #-}
module
Gargantext.Database
(
module
Gargantext
.
Database
.
Utils
-- , module Gargantext.Database.Instances
,
module
Gargantext
.
Database
.
User
,
module
Gargantext
.
Database
.
Node
,
module
Gargantext
.
Database
.
NodeNode
-- , module Gargantext.Database.Ngram
,
module
Gargantext
.
Database
.
NodeNgram
,
module
Gargantext
.
Database
.
NodeNodeNgram
,
module
Gargantext
.
Database
.
NodeNgramNgram
-- , module Gargantext.Database.Gargandb
-- , module Gargantext.Database.Simple
-- , module Gargantext.Database.InsertNode
-- , module Gargantext.Database.NodeType
)
where
import
Gargantext.Database.Utils
--import Gargantext.Database.Gargandb
import
Gargantext.Database.User
module
Gargantext.Database
(
module
Gargantext
.
Database
.
Utils
,
ls'
)
where
import
Gargantext.Core.Types
import
Gargantext.Database.Utils
(
connectGargandb
)
import
Gargantext.Database.Node
import
Gargantext.Database.NodeNode
--import Gargantext.Database.Ngram
import
Gargantext.Database.NodeNgram
import
Gargantext.Database.NodeNodeNgram
import
Gargantext.Database.NodeNgramNgram
--import Gargantext.Database.Simple
--import Gargantext.Database.NodeType
--import Gargantext.Database.InsertNode
import
Gargantext.Prelude
import
Database.PostgreSQL.Simple
(
Connection
)
import
Opaleye
hiding
(
FromField
)
import
Data.Aeson
-- type PWD = Node NodeId
-- type Path = [PWD]
-- pwd :: [Node NodeId] ->
ls
::
Connection
->
Int
->
IO
[
Node
Value
]
ls
conn
n
=
runQuery
conn
$
selectNodesWithParentID
n
ls'
::
IO
[
Node
Value
]
ls'
=
connectGargandb
"gargantext.ini"
>>=
\
c
->
ls
c
347474
-- ls' Maybe PWD
-- cd (Home UserId) | (Node NodeId)
-- cd Path
-- jump PWD
-- mk User
-- mk Dir
-- mk Corpus Parent_id (Empty|MyData)
-- mk CorpusWith
-- mk List
-- touch Dir
src/Gargantext/Database/Node.hs
View file @
b50f2445
...
...
@@ -164,6 +164,7 @@ getNodesWithParentId :: Connection -> Int
->
Maybe
Text
->
IO
[
Node
HyperdataDocument
]
getNodesWithParentId
conn
n
_
=
runQuery
conn
$
selectNodesWithParentID
n
selectNodesWithParentID
::
Int
->
Query
NodeRead
selectNodesWithParentID
n
=
proc
()
->
do
row
@
(
Node
_
_
_
parent_id
_
_
_
)
<-
queryNodeTable
-<
()
...
...
src/Gargantext/Prelude.hs
View file @
b50f2445
...
...
@@ -35,7 +35,7 @@ import Protolude ( Bool(True, False), Int, Double, Integer
,
Fractional
,
Num
,
Maybe
(
Just
,
Nothing
)
,
Enum
,
Bounded
,
Float
,
Floating
,
Char
,
IO
,
pure
,
(
<*>
),
(
<$>
),
panic
,
pure
,
(
>>=
),
(
=<<
),
(
<*>
),
(
<$>
),
panic
,
putStrLn
,
head
,
flip
,
Ord
,
Integral
,
Foldable
,
RealFrac
,
Monad
,
filter
...
...
src/Gargantext/Text/Parsers/CSV.hs
View file @
b50f2445
...
...
@@ -146,7 +146,6 @@ csvEncodeOptions = ( defaultEncodeOptions
{
encDelimiter
=
fromIntegral
$
ord
'
\t
'
}
)
------------------------------------------------------------------------
------------------------------------------------------------------------
readCsvOn
::
[
CsvDoc
->
Text
]
->
FilePath
->
IO
[
Text
]
...
...
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