1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 23:42:31 +03:00

Auto derive ToJSON right in Language.hs

This commit is contained in:
Timothy Clem 2017-06-08 07:01:03 -07:00
parent feb54b14ad
commit 572c24d36d
2 changed files with 3 additions and 4 deletions

View File

@ -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

View File

@ -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 ]