]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Core.hs
Merge branch 'dev' into dev-phylo
[gargantext.git] / src / Gargantext / Core.hs
1 {-|
2 Module : Gargantext.Core
3 Description : Supported Natural language
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 -}
11
12 {-# LANGUAGE NoImplicitPrelude #-}
13 {-# LANGUAGE DeriveGeneric #-}
14 {-# LANGUAGE TemplateHaskell #-}
15 {-# LANGUAGE OverloadedStrings #-}
16
17 module Gargantext.Core
18 where
19
20 import Gargantext.Prelude
21 import GHC.Generics (Generic)
22 import Data.Aeson
23 import Data.Either(Either(Left))
24 import Data.Swagger
25 import Servant.API
26 ------------------------------------------------------------------------
27 -- | Language of a Text
28 -- For simplicity, we suppose text has an homogenous language
29 --
30 -- Next steps: | DE | IT | SP
31 --
32 -- - EN == english
33 -- - FR == french
34 -- - DE == deutch (not implemented yet)
35 -- - IT == italian (not implemented yet)
36 -- - SP == spanish (not implemented yet)
37 --
38 -- ... add your language and help us to implement it (:
39
40 -- | All languages supported
41 -- TODO : DE | SP | CH
42 data Lang = EN | FR | All
43 deriving (Show, Eq, Ord, Bounded, Enum, Generic)
44
45 instance ToJSON Lang
46 instance FromJSON Lang
47 instance ToSchema Lang
48 instance FromHttpApiData Lang
49 where
50 parseUrlPiece "EN" = pure EN
51 parseUrlPiece "FR" = pure FR
52 parseUrlPiece "All" = pure All
53 parseUrlPiece _ = Left "Unexpected value of OrderBy"
54 allLangs :: [Lang]
55 allLangs = [minBound ..]