From 066514fdc2f7561d4a3446b205499a796799a075 Mon Sep 17 00:00:00 2001 From: Nicolas Pouillard <nicolas.pouillard@gmail.com> Date: Fri, 1 Mar 2019 10:44:38 +0100 Subject: [PATCH] [NGRAMS-REPO]: uniformize TermList constructors --- src/Gargantext/Types.purs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Gargantext/Types.purs b/src/Gargantext/Types.purs index 873d7098..dd1d4480 100644 --- a/src/Gargantext/Types.purs +++ b/src/Gargantext/Types.purs @@ -26,21 +26,22 @@ termSizes = [ { desc: "All types", mval: Nothing } ] data TermList = GraphTerm | StopTerm | CandidateTerm +-- TODO use generic JSON instance derive instance eqTermList :: Eq TermList instance encodeJsonTermList :: EncodeJson TermList where - encodeJson GraphTerm = encodeJson "GraphList" - encodeJson StopTerm = encodeJson "StopList" - encodeJson CandidateTerm = encodeJson "CandidateList" + encodeJson GraphTerm = encodeJson "GraphTerm" + encodeJson StopTerm = encodeJson "StopTerm" + encodeJson CandidateTerm = encodeJson "CandidateTerm" instance decodeJsonTermList :: DecodeJson TermList where decodeJson json = do s <- decodeJson json case s of - "GraphList" -> pure GraphTerm - "StopList" -> pure StopTerm - "CandidateList" -> pure CandidateTerm + "GraphTerm" -> pure GraphTerm + "StopTerm" -> pure StopTerm + "CandidateTerm" -> pure CandidateTerm _ -> Left "Unexpected list name" type ListTypeId = Int @@ -51,15 +52,15 @@ listTypeId StopTerm = 2 listTypeId CandidateTerm = 3 instance showTermList :: Show TermList where - show GraphTerm = "Graph" - show StopTerm = "Stop" - show CandidateTerm = "Candidate" + show GraphTerm = "GraphTerm" + show StopTerm = "StopTerm" + show CandidateTerm = "CandidateTerm" readTermList :: String -> Maybe TermList -readTermList "Graph" = Just GraphTerm -readTermList "Stop" = Just StopTerm -readTermList "Candidate" = Just CandidateTerm -readTermList _ = Nothing +readTermList "GraphTerm" = Just GraphTerm +readTermList "StopTerm" = Just StopTerm +readTermList "CandidateTerm" = Just CandidateTerm +readTermList _ = Nothing termLists :: Array { desc :: String, mval :: Maybe TermList } termLists = [ { desc: "All terms", mval: Nothing } -- 2.21.0