1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00
semantic/semantic-python/test/Instances.hs

30 lines
890 B
Haskell
Raw Normal View History

{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
2019-08-27 18:27:53 +03:00
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Instances () where
2019-08-27 18:27:53 +03:00
-- 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.
2019-10-11 19:37:11 +03:00
import Analysis.File
2019-08-27 18:27:53 +03:00
import Data.Aeson
2019-12-20 19:43:15 +03:00
import Data.Text (pack)
2019-10-11 01:08:25 +03:00
import qualified System.Path as Path
instance ToJSON a => ToJSON (File a) where
2019-10-10 21:18:56 +03:00
toJSON File{filePath, fileSpan, fileBody} = object
[ "path" .= filePath
, "span" .= fileSpan
, "body" .= fileBody
]
2019-08-27 18:27:53 +03:00
2019-10-11 01:08:25 +03:00
instance ToJSON Path.AbsRelFile where
2019-10-11 19:13:57 +03:00
toJSON p = toJSON (pack (Path.toString p))