{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module Headroom.Types
(
HeadroomError(..)
, fromHeadroomError
, toHeadroomError
, TemplateMeta(..)
, HaddockFieldOffsets(..)
, CurrentYear(..)
)
where
import Data.Default.Class ( Default(..) )
import Data.Typeable ( cast )
import RIO
data HeadroomError = forall e . Exception e => HeadroomError e
instance Show HeadroomError where
show (HeadroomError he) = show he
instance Exception HeadroomError where
displayException (HeadroomError he) = displayException he
toHeadroomError :: Exception e
=> e
-> SomeException
toHeadroomError = toException . HeadroomError
fromHeadroomError :: Exception e
=> SomeException
-> Maybe e
fromHeadroomError e = do
HeadroomError he <- fromException e
cast he
newtype CurrentYear = CurrentYear
{ unCurrentYear :: Integer
}
deriving (Eq, Show)
data HaddockFieldOffsets = HaddockFieldOffsets
{ hfoCopyright :: !(Maybe Int)
}
deriving (Eq, Show)
instance Default HaddockFieldOffsets where
def = HaddockFieldOffsets { hfoCopyright = Nothing }
data TemplateMeta = HaskellTemplateMeta !HaddockFieldOffsets
deriving (Eq, Show)