mirror of
https://github.com/github/semantic.git
synced 2024-11-24 17:04:47 +03:00
30 lines
890 B
Haskell
30 lines
890 B
Haskell
{-# LANGUAGE DerivingStrategies #-}
|
|
{-# LANGUAGE FlexibleInstances #-}
|
|
{-# LANGUAGE NamedFieldPuns #-}
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
{-# LANGUAGE QuantifiedConstraints #-}
|
|
{-# LANGUAGE TypeOperators #-}
|
|
{-# LANGUAGE UndecidableInstances #-}
|
|
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
|
|
|
module Instances () where
|
|
|
|
-- Testing code depends on certain instances that we don't want to
|
|
-- expose in semantic-core proper, yet are important enough that
|
|
-- we should keep track of them in a dedicated file.
|
|
|
|
import Analysis.File
|
|
import Data.Aeson
|
|
import Data.Text (pack)
|
|
import qualified System.Path as Path
|
|
|
|
instance ToJSON a => ToJSON (File a) where
|
|
toJSON File{filePath, fileSpan, fileBody} = object
|
|
[ "path" .= filePath
|
|
, "span" .= fileSpan
|
|
, "body" .= fileBody
|
|
]
|
|
|
|
instance ToJSON Path.AbsRelFile where
|
|
toJSON p = toJSON (pack (Path.toString p))
|