module Scion.PersistentHoogle.Instances.Json where
import Control.Applicative
import Data.Aeson hiding (Result)
import qualified Data.Text as T
import Scion.PersistentBrowser ()
import Scion.PersistentHoogle.Types
instance ToJSON (Result) where
toJSON (RPackage pids) = object [ "type" .= T.pack "package"
, "results" .= pids
]
toJSON (RModule mds) = object [ "type" .= T.pack "module"
, "results" .= mds
]
toJSON (RDeclaration decls) = object [ "type" .= T.pack "declaration"
, "results" .= decls
]
toJSON (RConstructor decls) = object [ "type" .= T.pack "constructor"
, "results" .= decls
]
toJSON (RKeyword kw) = object [ "type" .= T.pack "keyword"
, "name" .= kw
]
instance FromJSON (Query) where
parseJSON q = Query <$> parseJSON q