Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-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
Grégoire Locqueville
purescript-gargantext
Commits
5042e219
Commit
5042e219
authored
Jan 07, 2019
by
Nicolas Pouillard
Committed by
Alexandre Delanoë
Feb 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NGRAMS-TABLE] finish the encodeJsonePatchMap instance (+ add some TODO)
parent
51228e87
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+6
-5
No files found.
src/Gargantext/Components/NgramsTable.purs
View file @
5042e219
...
...
@@ -16,7 +16,7 @@ module Gargantext.Components.NgramsTable
import Control.Monad.State (class MonadState, execState)
import Control.Monad.Cont.Trans (lift)
import Data.Argonaut ( Json, class DecodeJson, decodeJson, class EncodeJson
import Data.Argonaut ( Json, class DecodeJson, decodeJson, class EncodeJson
, encodeJson
, jsonEmptyObject, fromObject, (:=), (~>), (.?), (.??) )
import Data.Either (Either(..))
import Data.Foldable (class Foldable, foldMap, foldl, foldr)
...
...
@@ -206,12 +206,14 @@ instance monoidPatchSet :: Ord a => Monoid (PatchSet a) where
instance encodeJsonPatchSet :: EncodeJson a => EncodeJson (PatchSet a) where
encodeJson (PatchSet {rem, add})
-- TODO only include non empty fields
= "rem" := (Set.toUnfoldable rem :: Array a)
~> "add" := (Set.toUnfoldable add :: Array a)
~> jsonEmptyObject
instance decodeJsonPatchSet :: (Ord a, DecodeJson a) => DecodeJson (PatchSet a) where
decodeJson json = do
-- TODO handle empty fields
obj <- decodeJson json
rem <- mkSet <$> (obj .? "rem")
add <- mkSet <$> (obj .? "add")
...
...
@@ -243,6 +245,7 @@ instance monoidNgramsPatch :: Monoid NgramsPatch where
mempty = NgramsPatch { patch_children: mempty, patch_list: mempty }
instance encodeJsonNgramsPatch :: EncodeJson NgramsPatch where
-- TODO only include non empty fields
encodeJson (NgramsPatch { patch_children, patch_list })
= "patch_children" := patch_children
~> "patch_list" := patch_list
...
...
@@ -251,6 +254,7 @@ instance encodeJsonNgramsPatch :: EncodeJson NgramsPatch where
instance decodeJsonNgramsPatch :: DecodeJson NgramsPatch where
decodeJson json = do
obj <- decodeJson json
-- TODO handle empty fields
patch_list <- obj .? "patch_list"
patch_children <- obj .? "patch_children"
pure $ NgramsPatch { patch_list, patch_children }
...
...
@@ -302,10 +306,7 @@ instance traversableWithIndexPatchMap :: TraversableWithIndex k (PatchMap k) whe
instance encodeJsonPatchMap :: EncodeJson p => EncodeJson (PatchMap String p) where
encodeJson (PatchMap m) =
fromObject $
FO.fromFoldable $
([] :: Array (Tuple String Json))
-- (Map.toUnfoldable $ (encodeJson <$> m :: Map String Json) :: Array _)
encodeJson $ FO.fromFoldable $ (Map.toUnfoldable m :: Array _)
instance decodeJsonPatchMap :: DecodeJson p => DecodeJson (PatchMap String p) where
decodeJson json = do
...
...
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