mirror of
https://github.com/github/semantic.git
synced 2024-12-25 16:02:43 +03:00
Auto derive ToJSON right in Language.hs
This commit is contained in:
parent
feb54b14ad
commit
572c24d36d
@ -1,6 +1,7 @@
|
||||
{-# LANGUAGE DataKinds, DeriveGeneric #-}
|
||||
{-# LANGUAGE DataKinds, DeriveGeneric, DeriveAnyClass #-}
|
||||
module Language where
|
||||
|
||||
import Data.Aeson
|
||||
import Data.Record
|
||||
import Data.String
|
||||
import Info
|
||||
@ -16,7 +17,7 @@ data Language =
|
||||
| Ruby
|
||||
| TypeScript -- ^ Also JavaScript.
|
||||
| Python
|
||||
deriving (Show, Eq, Read, Generic)
|
||||
deriving (Show, Eq, Read, Generic, ToJSON)
|
||||
|
||||
-- | Returns a Language based on the file extension (including the ".").
|
||||
languageForType :: String -> Maybe Language
|
||||
|
@ -113,8 +113,6 @@ instance ToJSONFields (Union '[] a) where
|
||||
data File a = File { filePath :: FilePath, fileLanguage :: Maybe Language, fileContent :: a }
|
||||
deriving (Generic, Show)
|
||||
|
||||
instance ToJSON Language
|
||||
|
||||
instance ToJSON a => ToJSON (File a) where
|
||||
toJSON File{..} = object [ "filePath" .= filePath, "language" .= fileLanguage, "programNode" .= fileContent ]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user