ronn-1.2.0.0: src/Ronn/ManRef.hs
-- |
--
-- Module : Ronn.ManRef
-- Copyright : (c) 2024 Patrick Brisbin
-- License : AGPL-3
-- Maintainer : pbrisbin@gmail.com
-- Stability : experimental
-- Portability : POSIX
module Ronn.ManRef
( ManRef (..)
, ManSection (..)
, manSectionNumber
)
where
import Prelude
import Data.Ord
import Data.Text
import Prettyprinter (Pretty (..), parens)
data ManRef = ManRef
{ name :: Text
, section :: ManSection
}
deriving stock (Eq, Show)
instance Ord ManRef where
compare a b = comparing (.section) a b <> comparing (.name) a b
instance Pretty ManRef where
pretty (ManRef n s) = pretty n <> parens (pretty s)
data ManSection
= ManSection1
| ManSection2
| ManSection3
| ManSection4
| ManSection5
| ManSection6
| ManSection7
| ManSection8
deriving stock (Eq, Ord, Bounded, Enum, Show)
instance Pretty ManSection where
pretty = pretty . manSectionNumber
manSectionNumber :: ManSection -> Int
manSectionNumber = (+ 1) . fromEnum