module Gargantext.Core
where
+import Gargantext.Prelude
+import GHC.Generics (Generic)
+import Data.Aeson
+import Data.Either(Either(Left))
+import Data.Swagger
+import Servant.API
------------------------------------------------------------------------
-- | Language of a Text
-- For simplicity, we suppose text has an homogenous language
-- - SP == spanish (not implemented yet)
--
-- ... add your language and help us to implement it (:
-data Lang = EN | FR -- | DE | SP | CH
- deriving (Show, Eq, Ord, Bounded, Enum)
+-- | All languages supported
+-- TODO : DE | SP | CH
+data Lang = EN | FR | All
+ deriving (Show, Eq, Ord, Bounded, Enum, Generic)
+
+instance ToJSON Lang
+instance FromJSON Lang
+instance ToSchema Lang
+instance FromHttpApiData Lang
+ where
+ parseUrlPiece "EN" = pure EN
+ parseUrlPiece "FR" = pure FR
+ parseUrlPiece "All" = pure All
+ parseUrlPiece _ = Left "Unexpected value of OrderBy"
allLangs :: [Lang]
allLangs = [minBound ..]