snippet-0.0.0.0: src/Snippet/Region.hs
-- |
--
-- Module : Snippet.Region
-- Copyright : (c) 2026 Patrick Brisbin
-- License : AGPL-3
-- Maintainer : pbrisbin@gmail.com
-- Stability : experimental
-- Portability : POSIX
module Snippet.Region
( Region (..)
-- * Single-line helpers
, lineRegion
, lineRegionFrom
, lineRegionFromTo
) where
import Prelude
data Region = Region
{ startLine :: Int
, endLine :: Maybe Int
-- ^ Defaults to 'startLine' if missing
, startColumn :: Maybe Int
-- ^ Defaults to @1@ if missing
, endColumn :: Maybe Int
-- ^ If missing, the entire last line is considered focused
}
deriving stock (Eq, Show)
lineRegion :: Int -> Region
lineRegion startLine =
Region
{ startLine
, endLine = Nothing
, startColumn = Nothing
, endColumn = Nothing
}
lineRegionFrom :: Int -> Int -> Region
lineRegionFrom startLine sc =
Region
{ startLine
, endLine = Nothing
, startColumn = Just sc
, endColumn = Nothing
}
lineRegionFromTo :: Int -> Int -> Int -> Region
lineRegionFromTo startLine sc ec =
Region
{ startLine
, endLine = Nothing
, startColumn = Just sc
, endColumn = Just ec
}