module Codec.Sarsi.GHC where

import Codec.Sarsi
import Data.Text (strip)

import qualified Codec.GHC.Log as Log

fromGHCLog :: Log.Message -> Message
fromGHCLog :: Message -> Message
fromGHCLog (Log.Message Text
fp (Log.Pos Int
col Int
ln) Level
lvl [Text]
texts) =
  Location -> Level -> [Text] -> Message
Message
    (Text -> Int -> Int -> Location
Location (Text -> Text
strip Text
fp) (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
col) (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ln))
    (Level -> Level
fromGHCLevel Level
lvl) (Text -> Text
strip (Text -> Text) -> [Text] -> [Text]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text]
texts)

fromGHCLevel :: Log.Level -> Level
fromGHCLevel :: Level -> Level
fromGHCLevel Level
Log.Warning = Level
Warning
fromGHCLevel Level
Log.Error = Level
Error