kill me
This commit is contained in:
@@ -24,8 +24,11 @@ import Control.Monad.Errorful
|
||||
import Data.Text (Text)
|
||||
import Data.Text qualified as T
|
||||
import GHC.Exts (IsString(..))
|
||||
import Control.Lens
|
||||
import GHC.Generics
|
||||
import Control.Lens hiding ((.=))
|
||||
import Compiler.Types
|
||||
|
||||
import Data.Aeson
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
data MsgEnvelope e = MsgEnvelope
|
||||
@@ -35,8 +38,17 @@ data MsgEnvelope e = MsgEnvelope
|
||||
}
|
||||
deriving (Functor, Show)
|
||||
|
||||
instance (ToJSON e) => ToJSON (MsgEnvelope e) where
|
||||
toJSON msg = object
|
||||
[ "span" .= _msgSpan msg
|
||||
, "severity" .= _msgSeverity msg
|
||||
, "diagnostic" .= _msgDiagnostic msg
|
||||
]
|
||||
|
||||
newtype RlpcError = Text [Text]
|
||||
deriving Show
|
||||
deriving (Show, Generic)
|
||||
deriving (ToJSON)
|
||||
via Generically [Text]
|
||||
|
||||
instance IsString RlpcError where
|
||||
fromString = Text . pure . T.pack
|
||||
@@ -50,7 +62,9 @@ instance IsRlpcError RlpcError where
|
||||
data Severity = SevWarning
|
||||
| SevError
|
||||
| SevDebug Text -- ^ Tag
|
||||
deriving Show
|
||||
deriving (Show, Generic)
|
||||
deriving (ToJSON)
|
||||
via Generically Severity
|
||||
|
||||
makeLenses ''MsgEnvelope
|
||||
|
||||
|
||||
@@ -33,8 +33,10 @@ import Data.Functor.Compose
|
||||
import Data.Functor.Foldable
|
||||
import Data.Semigroup.Foldable
|
||||
import Data.Fix hiding (cata, ana)
|
||||
|
||||
import Data.Kind
|
||||
import Control.Lens hiding ((<<~), (:<))
|
||||
import Data.Aeson
|
||||
import Control.Lens hiding ((<<~), (:<), (.=))
|
||||
|
||||
import Data.List.NonEmpty (NonEmpty)
|
||||
import Data.Function (on)
|
||||
@@ -45,6 +47,13 @@ import Misc.CofreeF
|
||||
data Located a = Located SrcSpan a
|
||||
deriving (Show, Lift, Functor)
|
||||
|
||||
instance ToJSON SrcSpan where
|
||||
toJSON (SrcSpan l c a s) = object
|
||||
[ "line" .= l
|
||||
, "column" .= c
|
||||
, "abs" .= a
|
||||
, "length" .= s]
|
||||
|
||||
(<~>) :: a -> b -> SrcSpan
|
||||
(<~>) = undefined
|
||||
|
||||
|
||||
Reference in New Issue
Block a user