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
dce66b50
Commit
dce66b50
authored
Mar 18, 2021
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FUN] with filePath
parent
f73590ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
10 deletions
+23
-10
Utils.hs
src/Gargantext/Prelude/Utils.hs
+23
-10
No files found.
src/Gargantext/Prelude/Utils.hs
View file @
dce66b50
...
...
@@ -12,6 +12,7 @@ Portability : POSIX
module
Gargantext.Prelude.Utils
where
import
Data.Tuple.Extra
(
both
)
import
Control.Exception
import
Control.Lens
(
view
)
import
Control.Monad.Reader
(
MonadReader
)
...
...
@@ -39,24 +40,36 @@ shuffle ns = SRS.shuffleM ns
data
NodeToHash
=
NodeToHash
{
nodeType
::
NodeType
,
nodeId
::
NodeId
}
-------------------------------------------------------------------
type
FolderPath
=
FilePath
type
FileName
=
FilePath
-- | toPath example of use:
-- toPath 2 "gargantexthello"
-- ("ga/rg","antexthello")
--
-- toPath 3 "gargantexthello"
-- ("gar/gan","texthello")
-- | toPath' example of use:
{-
>>> toPath' (1,2) ("","helloword")
("/he","lloword")
>>> toPath' (2,2) ("","helloword")
("/he/ll","oword")
>>> toPath' (2,3) ("","helloword")
("/hel/low","ord")
-}
toPath
::
Int
->
Text
->
(
FolderPath
,
FileName
)
toPath
n
x
=
(
Text
.
unpack
$
Text
.
intercalate
"/"
[
x1
,
x2
],
Text
.
unpack
xs
)
toPath
n
tx
=
both
Text
.
unpack
$
toPath'
(
2
,
n
)
(
""
,
tx
)
toPath'
::
(
Int
,
Int
)
->
(
Text
,
Text
)
->
(
Text
,
Text
)
toPath'
(
n
,
m
)
(
t
,
x
)
=
foldl'
(
\
tx
_
->
toPath''
m
tx
)
(
t
,
x
)
[
1
..
n
]
toPath''
::
Int
->
(
Text
,
Text
)
->
(
Text
,
Text
)
toPath''
n
(
fp
,
fn
)
=
(
fp''
,
fn'
)
where
(
x1
,
x'
)
=
Text
.
splitAt
n
x
(
x2
,
xs
)
=
Text
.
splitAt
n
x'
(
fp'
,
fn'
)
=
Text
.
splitAt
n
fn
fp''
=
Text
.
intercalate
"/"
[
fp
,
fp'
]
-------------------------------------------------------------------
-------------------------------------------------------------------
class
SaveFile
a
where
saveFile'
::
FilePath
->
a
->
IO
()
...
...
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