{-# LANGUAGE TemplateHaskell #-}
module Vgrep.Results
    ( File (..)
    , fileName

    , LineReference (..)
    , lineNumber
    , lineText

    , FileLineReference (..)
    , file
    , lineReference
    ) where

import Lens.Micro.Platform
import Data.Text       (Text)

import Vgrep.Ansi (AnsiFormatted)


newtype File = File
    { File -> Text
_fileName :: Text
    } deriving (File -> File -> Bool
(File -> File -> Bool) -> (File -> File -> Bool) -> Eq File
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: File -> File -> Bool
$c/= :: File -> File -> Bool
== :: File -> File -> Bool
$c== :: File -> File -> Bool
Eq, Int -> File -> ShowS
[File] -> ShowS
File -> String
(Int -> File -> ShowS)
-> (File -> String) -> ([File] -> ShowS) -> Show File
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [File] -> ShowS
$cshowList :: [File] -> ShowS
show :: File -> String
$cshow :: File -> String
showsPrec :: Int -> File -> ShowS
$cshowsPrec :: Int -> File -> ShowS
Show)

makeLenses ''File

data LineReference = LineReference
    { LineReference -> Maybe Int
_lineNumber :: Maybe Int
    , LineReference -> AnsiFormatted
_lineText   :: AnsiFormatted
    } deriving (LineReference -> LineReference -> Bool
(LineReference -> LineReference -> Bool)
-> (LineReference -> LineReference -> Bool) -> Eq LineReference
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LineReference -> LineReference -> Bool
$c/= :: LineReference -> LineReference -> Bool
== :: LineReference -> LineReference -> Bool
$c== :: LineReference -> LineReference -> Bool
Eq, Int -> LineReference -> ShowS
[LineReference] -> ShowS
LineReference -> String
(Int -> LineReference -> ShowS)
-> (LineReference -> String)
-> ([LineReference] -> ShowS)
-> Show LineReference
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LineReference] -> ShowS
$cshowList :: [LineReference] -> ShowS
show :: LineReference -> String
$cshow :: LineReference -> String
showsPrec :: Int -> LineReference -> ShowS
$cshowsPrec :: Int -> LineReference -> ShowS
Show)

makeLenses ''LineReference

data FileLineReference = FileLineReference
    { FileLineReference -> File
_file          :: File
    , FileLineReference -> LineReference
_lineReference :: LineReference
    } deriving (FileLineReference -> FileLineReference -> Bool
(FileLineReference -> FileLineReference -> Bool)
-> (FileLineReference -> FileLineReference -> Bool)
-> Eq FileLineReference
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileLineReference -> FileLineReference -> Bool
$c/= :: FileLineReference -> FileLineReference -> Bool
== :: FileLineReference -> FileLineReference -> Bool
$c== :: FileLineReference -> FileLineReference -> Bool
Eq, Int -> FileLineReference -> ShowS
[FileLineReference] -> ShowS
FileLineReference -> String
(Int -> FileLineReference -> ShowS)
-> (FileLineReference -> String)
-> ([FileLineReference] -> ShowS)
-> Show FileLineReference
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FileLineReference] -> ShowS
$cshowList :: [FileLineReference] -> ShowS
show :: FileLineReference -> String
$cshow :: FileLineReference -> String
showsPrec :: Int -> FileLineReference -> ShowS
$cshowsPrec :: Int -> FileLineReference -> ShowS
Show)

makeLenses ''FileLineReference