Commit 9acf7ad9 authored by Mudada's avatar Mudada

add new type for struct's call

parent 000e2322
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
module HAL.Doc.Struct where
import GHC.Generics
import Data.Aeson
import Data.Default
import Data.Text (pack, Text)
import Control.Applicative ((<|>))
import qualified Control.Lens as L
import Servant.API (ToHttpApiData(..))
data Struct = Struct
{
_struct_docid :: Int,
_struct_label :: Text,
_struct_parent_docid :: [Int]
} deriving (Show, Generic)
L.makeLenses ''Struct
instance Default Struct where
def = Struct def "" def
instance FromJSON Struct where
parseJSON (Object o) = Struct <$>
(o .: "docid")
<*> (o .: "label_s")
<*> (o .: "parentDocid_i" <|> return [])
instance ToHttpApiData Struct where
toUrlPiece _ = "docid,label_s,parentDocid_i"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment