{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
#if __GLASGOW_HASKELL__ >= 710
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ViewPatterns #-}
#endif
module Data.Time.Calendar.Quarter.Compat (
QuarterOfYear(..), addQuarters, diffQuarters,
Quarter(..),
#if __GLASGOW_HASKELL__ >= 710
pattern YearQuarter,
#endif
monthOfYearQuarter,
monthQuarter,
dayQuarter,
fromYearQuarter,
toYearQuarter,
) where
#if MIN_VERSION_time(1,11,0)
import Data.Time.Calendar (Year)
import Data.Time.Calendar.Quarter
fromYearQuarter :: Year -> QuarterOfYear -> Quarter
fromYearQuarter = YearQuarter
toYearQuarter :: Quarter -> (Year, QuarterOfYear)
toYearQuarter (YearQuarter y m) = (y, m)
#else
import Data.Data (Data)
import Data.Typeable (Typeable)
import Text.Read (Read (..))
import Data.Fixed (mod', divMod')
import Text.ParserCombinators.ReadPrec (lift)
import Text.ParserCombinators.ReadP (char)
import Control.DeepSeq (NFData (..))
import Data.Ix (Ix (..))
import Data.Hashable (Hashable (..))
import Data.Time.Calendar
import Data.Time.Calendar.Types
import Data.Time.Calendar.Private
import Data.Time.Calendar.Month.Compat
data QuarterOfYear = Q1 | Q2 | Q3 | Q4 deriving (QuarterOfYear -> QuarterOfYear -> Bool
(QuarterOfYear -> QuarterOfYear -> Bool)
-> (QuarterOfYear -> QuarterOfYear -> Bool) -> Eq QuarterOfYear
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QuarterOfYear -> QuarterOfYear -> Bool
$c/= :: QuarterOfYear -> QuarterOfYear -> Bool
== :: QuarterOfYear -> QuarterOfYear -> Bool
$c== :: QuarterOfYear -> QuarterOfYear -> Bool
Eq, Eq QuarterOfYear
Eq QuarterOfYear
-> (QuarterOfYear -> QuarterOfYear -> Ordering)
-> (QuarterOfYear -> QuarterOfYear -> Bool)
-> (QuarterOfYear -> QuarterOfYear -> Bool)
-> (QuarterOfYear -> QuarterOfYear -> Bool)
-> (QuarterOfYear -> QuarterOfYear -> Bool)
-> (QuarterOfYear -> QuarterOfYear -> QuarterOfYear)
-> (QuarterOfYear -> QuarterOfYear -> QuarterOfYear)
-> Ord QuarterOfYear
QuarterOfYear -> QuarterOfYear -> Bool
QuarterOfYear -> QuarterOfYear -> Ordering
QuarterOfYear -> QuarterOfYear -> QuarterOfYear
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: QuarterOfYear -> QuarterOfYear -> QuarterOfYear
$cmin :: QuarterOfYear -> QuarterOfYear -> QuarterOfYear
max :: QuarterOfYear -> QuarterOfYear -> QuarterOfYear
$cmax :: QuarterOfYear -> QuarterOfYear -> QuarterOfYear
>= :: QuarterOfYear -> QuarterOfYear -> Bool
$c>= :: QuarterOfYear -> QuarterOfYear -> Bool
> :: QuarterOfYear -> QuarterOfYear -> Bool
$c> :: QuarterOfYear -> QuarterOfYear -> Bool
<= :: QuarterOfYear -> QuarterOfYear -> Bool
$c<= :: QuarterOfYear -> QuarterOfYear -> Bool
< :: QuarterOfYear -> QuarterOfYear -> Bool
$c< :: QuarterOfYear -> QuarterOfYear -> Bool
compare :: QuarterOfYear -> QuarterOfYear -> Ordering
$ccompare :: QuarterOfYear -> QuarterOfYear -> Ordering
$cp1Ord :: Eq QuarterOfYear
Ord, Typeable QuarterOfYear
DataType
Constr
Typeable QuarterOfYear
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> QuarterOfYear -> c QuarterOfYear)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c QuarterOfYear)
-> (QuarterOfYear -> Constr)
-> (QuarterOfYear -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c QuarterOfYear))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c QuarterOfYear))
-> ((forall b. Data b => b -> b) -> QuarterOfYear -> QuarterOfYear)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> QuarterOfYear -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> QuarterOfYear -> r)
-> (forall u. (forall d. Data d => d -> u) -> QuarterOfYear -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> QuarterOfYear -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> QuarterOfYear -> m QuarterOfYear)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> QuarterOfYear -> m QuarterOfYear)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> QuarterOfYear -> m QuarterOfYear)
-> Data QuarterOfYear
QuarterOfYear -> DataType
QuarterOfYear -> Constr
(forall b. Data b => b -> b) -> QuarterOfYear -> QuarterOfYear
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> QuarterOfYear -> c QuarterOfYear
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c QuarterOfYear
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> QuarterOfYear -> u
forall u. (forall d. Data d => d -> u) -> QuarterOfYear -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> QuarterOfYear -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> QuarterOfYear -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> QuarterOfYear -> m QuarterOfYear
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> QuarterOfYear -> m QuarterOfYear
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c QuarterOfYear
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> QuarterOfYear -> c QuarterOfYear
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c QuarterOfYear)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c QuarterOfYear)
$cQ4 :: Constr
$cQ3 :: Constr
$cQ2 :: Constr
$cQ1 :: Constr
$tQuarterOfYear :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> QuarterOfYear -> m QuarterOfYear
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> QuarterOfYear -> m QuarterOfYear
gmapMp :: (forall d. Data d => d -> m d) -> QuarterOfYear -> m QuarterOfYear
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> QuarterOfYear -> m QuarterOfYear
gmapM :: (forall d. Data d => d -> m d) -> QuarterOfYear -> m QuarterOfYear
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> QuarterOfYear -> m QuarterOfYear
gmapQi :: Int -> (forall d. Data d => d -> u) -> QuarterOfYear -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> QuarterOfYear -> u
gmapQ :: (forall d. Data d => d -> u) -> QuarterOfYear -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> QuarterOfYear -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> QuarterOfYear -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> QuarterOfYear -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> QuarterOfYear -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> QuarterOfYear -> r
gmapT :: (forall b. Data b => b -> b) -> QuarterOfYear -> QuarterOfYear
$cgmapT :: (forall b. Data b => b -> b) -> QuarterOfYear -> QuarterOfYear
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c QuarterOfYear)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c QuarterOfYear)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c QuarterOfYear)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c QuarterOfYear)
dataTypeOf :: QuarterOfYear -> DataType
$cdataTypeOf :: QuarterOfYear -> DataType
toConstr :: QuarterOfYear -> Constr
$ctoConstr :: QuarterOfYear -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c QuarterOfYear
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c QuarterOfYear
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> QuarterOfYear -> c QuarterOfYear
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> QuarterOfYear -> c QuarterOfYear
$cp1Data :: Typeable QuarterOfYear
Data, Typeable, ReadPrec [QuarterOfYear]
ReadPrec QuarterOfYear
Int -> ReadS QuarterOfYear
ReadS [QuarterOfYear]
(Int -> ReadS QuarterOfYear)
-> ReadS [QuarterOfYear]
-> ReadPrec QuarterOfYear
-> ReadPrec [QuarterOfYear]
-> Read QuarterOfYear
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [QuarterOfYear]
$creadListPrec :: ReadPrec [QuarterOfYear]
readPrec :: ReadPrec QuarterOfYear
$creadPrec :: ReadPrec QuarterOfYear
readList :: ReadS [QuarterOfYear]
$creadList :: ReadS [QuarterOfYear]
readsPrec :: Int -> ReadS QuarterOfYear
$creadsPrec :: Int -> ReadS QuarterOfYear
Read, Int -> QuarterOfYear -> ShowS
[QuarterOfYear] -> ShowS
QuarterOfYear -> String
(Int -> QuarterOfYear -> ShowS)
-> (QuarterOfYear -> String)
-> ([QuarterOfYear] -> ShowS)
-> Show QuarterOfYear
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QuarterOfYear] -> ShowS
$cshowList :: [QuarterOfYear] -> ShowS
show :: QuarterOfYear -> String
$cshow :: QuarterOfYear -> String
showsPrec :: Int -> QuarterOfYear -> ShowS
$cshowsPrec :: Int -> QuarterOfYear -> ShowS
Show)
instance NFData QuarterOfYear where
rnf :: QuarterOfYear -> ()
rnf QuarterOfYear
Q1 = ()
rnf QuarterOfYear
Q2 = ()
rnf QuarterOfYear
Q3 = ()
rnf QuarterOfYear
Q4 = ()
instance Hashable QuarterOfYear where
hashWithSalt :: Int -> QuarterOfYear -> Int
hashWithSalt Int
salt = Int -> Int -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
salt (Int -> Int) -> (QuarterOfYear -> Int) -> QuarterOfYear -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QuarterOfYear -> Int
forall a. Enum a => a -> Int
fromEnum
instance Enum QuarterOfYear where
toEnum :: Int -> QuarterOfYear
toEnum Int
i =
case Int -> Int -> Int
forall a. Real a => a -> a -> a
mod' Int
i Int
4 of
Int
1 -> QuarterOfYear
Q1
Int
2 -> QuarterOfYear
Q2
Int
3 -> QuarterOfYear
Q3
Int
_ -> QuarterOfYear
Q4
fromEnum :: QuarterOfYear -> Int
fromEnum QuarterOfYear
Q1 = Int
1
fromEnum QuarterOfYear
Q2 = Int
2
fromEnum QuarterOfYear
Q3 = Int
3
fromEnum QuarterOfYear
Q4 = Int
4
instance Bounded QuarterOfYear where
minBound :: QuarterOfYear
minBound = QuarterOfYear
Q1
maxBound :: QuarterOfYear
maxBound = QuarterOfYear
Q4
newtype Quarter = MkQuarter Integer deriving (Quarter -> Quarter -> Bool
(Quarter -> Quarter -> Bool)
-> (Quarter -> Quarter -> Bool) -> Eq Quarter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Quarter -> Quarter -> Bool
$c/= :: Quarter -> Quarter -> Bool
== :: Quarter -> Quarter -> Bool
$c== :: Quarter -> Quarter -> Bool
Eq, Eq Quarter
Eq Quarter
-> (Quarter -> Quarter -> Ordering)
-> (Quarter -> Quarter -> Bool)
-> (Quarter -> Quarter -> Bool)
-> (Quarter -> Quarter -> Bool)
-> (Quarter -> Quarter -> Bool)
-> (Quarter -> Quarter -> Quarter)
-> (Quarter -> Quarter -> Quarter)
-> Ord Quarter
Quarter -> Quarter -> Bool
Quarter -> Quarter -> Ordering
Quarter -> Quarter -> Quarter
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Quarter -> Quarter -> Quarter
$cmin :: Quarter -> Quarter -> Quarter
max :: Quarter -> Quarter -> Quarter
$cmax :: Quarter -> Quarter -> Quarter
>= :: Quarter -> Quarter -> Bool
$c>= :: Quarter -> Quarter -> Bool
> :: Quarter -> Quarter -> Bool
$c> :: Quarter -> Quarter -> Bool
<= :: Quarter -> Quarter -> Bool
$c<= :: Quarter -> Quarter -> Bool
< :: Quarter -> Quarter -> Bool
$c< :: Quarter -> Quarter -> Bool
compare :: Quarter -> Quarter -> Ordering
$ccompare :: Quarter -> Quarter -> Ordering
$cp1Ord :: Eq Quarter
Ord, Typeable Quarter
DataType
Constr
Typeable Quarter
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Quarter -> c Quarter)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Quarter)
-> (Quarter -> Constr)
-> (Quarter -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Quarter))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Quarter))
-> ((forall b. Data b => b -> b) -> Quarter -> Quarter)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Quarter -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Quarter -> r)
-> (forall u. (forall d. Data d => d -> u) -> Quarter -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Quarter -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Quarter -> m Quarter)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Quarter -> m Quarter)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Quarter -> m Quarter)
-> Data Quarter
Quarter -> DataType
Quarter -> Constr
(forall b. Data b => b -> b) -> Quarter -> Quarter
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Quarter -> c Quarter
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Quarter
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Quarter -> u
forall u. (forall d. Data d => d -> u) -> Quarter -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Quarter -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Quarter -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Quarter -> m Quarter
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Quarter -> m Quarter
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Quarter
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Quarter -> c Quarter
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Quarter)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Quarter)
$cMkQuarter :: Constr
$tQuarter :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Quarter -> m Quarter
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Quarter -> m Quarter
gmapMp :: (forall d. Data d => d -> m d) -> Quarter -> m Quarter
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Quarter -> m Quarter
gmapM :: (forall d. Data d => d -> m d) -> Quarter -> m Quarter
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Quarter -> m Quarter
gmapQi :: Int -> (forall d. Data d => d -> u) -> Quarter -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Quarter -> u
gmapQ :: (forall d. Data d => d -> u) -> Quarter -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Quarter -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Quarter -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Quarter -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Quarter -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Quarter -> r
gmapT :: (forall b. Data b => b -> b) -> Quarter -> Quarter
$cgmapT :: (forall b. Data b => b -> b) -> Quarter -> Quarter
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Quarter)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Quarter)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Quarter)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Quarter)
dataTypeOf :: Quarter -> DataType
$cdataTypeOf :: Quarter -> DataType
toConstr :: Quarter -> Constr
$ctoConstr :: Quarter -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Quarter
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Quarter
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Quarter -> c Quarter
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Quarter -> c Quarter
$cp1Data :: Typeable Quarter
Data, Typeable)
instance NFData Quarter where
rnf :: Quarter -> ()
rnf (MkQuarter Integer
m) = Integer -> ()
forall a. NFData a => a -> ()
rnf Integer
m
instance Hashable Quarter where
hashWithSalt :: Int -> Quarter -> Int
hashWithSalt Int
salt (MkQuarter Integer
x) = Int -> Integer -> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
salt Integer
x
instance Enum Quarter where
succ :: Quarter -> Quarter
succ (MkQuarter Integer
a) = Integer -> Quarter
MkQuarter (Integer -> Integer
forall a. Enum a => a -> a
succ Integer
a)
pred :: Quarter -> Quarter
pred (MkQuarter Integer
a) = Integer -> Quarter
MkQuarter (Integer -> Integer
forall a. Enum a => a -> a
pred Integer
a)
toEnum :: Int -> Quarter
toEnum = Integer -> Quarter
MkQuarter (Integer -> Quarter) -> (Int -> Integer) -> Int -> Quarter
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a. Enum a => Int -> a
toEnum
fromEnum :: Quarter -> Int
fromEnum (MkQuarter Integer
a) = Integer -> Int
forall a. Enum a => a -> Int
fromEnum Integer
a
enumFrom :: Quarter -> [Quarter]
enumFrom (MkQuarter Integer
a) = (Integer -> Quarter) -> [Integer] -> [Quarter]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Integer -> Quarter
MkQuarter (Integer -> [Integer]
forall a. Enum a => a -> [a]
enumFrom Integer
a)
enumFromThen :: Quarter -> Quarter -> [Quarter]
enumFromThen (MkQuarter Integer
a) (MkQuarter Integer
b) = (Integer -> Quarter) -> [Integer] -> [Quarter]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Integer -> Quarter
MkQuarter (Integer -> Integer -> [Integer]
forall a. Enum a => a -> a -> [a]
enumFromThen Integer
a Integer
b)
enumFromTo :: Quarter -> Quarter -> [Quarter]
enumFromTo (MkQuarter Integer
a) (MkQuarter Integer
b) = (Integer -> Quarter) -> [Integer] -> [Quarter]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Integer -> Quarter
MkQuarter (Integer -> Integer -> [Integer]
forall a. Enum a => a -> a -> [a]
enumFromTo Integer
a Integer
b)
enumFromThenTo :: Quarter -> Quarter -> Quarter -> [Quarter]
enumFromThenTo (MkQuarter Integer
a) (MkQuarter Integer
b) (MkQuarter Integer
c) =
(Integer -> Quarter) -> [Integer] -> [Quarter]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Integer -> Quarter
MkQuarter (Integer -> Integer -> Integer -> [Integer]
forall a. Enum a => a -> a -> a -> [a]
enumFromThenTo Integer
a Integer
b Integer
c)
instance Ix Quarter where
range :: (Quarter, Quarter) -> [Quarter]
range (MkQuarter Integer
a, MkQuarter Integer
b) = (Integer -> Quarter) -> [Integer] -> [Quarter]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Integer -> Quarter
MkQuarter ((Integer, Integer) -> [Integer]
forall a. Ix a => (a, a) -> [a]
range (Integer
a, Integer
b))
index :: (Quarter, Quarter) -> Quarter -> Int
index (MkQuarter Integer
a, MkQuarter Integer
b) (MkQuarter Integer
c) = (Integer, Integer) -> Integer -> Int
forall a. Ix a => (a, a) -> a -> Int
index (Integer
a, Integer
b) Integer
c
inRange :: (Quarter, Quarter) -> Quarter -> Bool
inRange (MkQuarter Integer
a, MkQuarter Integer
b) (MkQuarter Integer
c) = (Integer, Integer) -> Integer -> Bool
forall a. Ix a => (a, a) -> a -> Bool
inRange (Integer
a, Integer
b) Integer
c
rangeSize :: (Quarter, Quarter) -> Int
rangeSize (MkQuarter Integer
a, MkQuarter Integer
b) = (Integer, Integer) -> Int
forall a. Ix a => (a, a) -> Int
rangeSize (Integer
a, Integer
b)
instance Show Quarter where
show :: Quarter -> String
show Quarter
q = case Quarter -> (Integer, QuarterOfYear)
toYearQuarter Quarter
q of
(Integer
y, QuarterOfYear
qy) -> Integer -> String
forall t. ShowPadded t => t -> String
show4 Integer
y String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"-" String -> ShowS
forall a. [a] -> [a] -> [a]
++ QuarterOfYear -> String
forall a. Show a => a -> String
show QuarterOfYear
qy
instance Read Quarter where
readPrec :: ReadPrec Quarter
readPrec = do
Integer
y <- ReadPrec Integer
forall a. Read a => ReadPrec a
readPrec
Char
_ <- ReadP Char -> ReadPrec Char
forall a. ReadP a -> ReadPrec a
lift (ReadP Char -> ReadPrec Char) -> ReadP Char -> ReadPrec Char
forall a b. (a -> b) -> a -> b
$ Char -> ReadP Char
char Char
'-'
QuarterOfYear
m <- ReadPrec QuarterOfYear
forall a. Read a => ReadPrec a
readPrec
Quarter -> ReadPrec Quarter
forall (m :: * -> *) a. Monad m => a -> m a
return (Quarter -> ReadPrec Quarter) -> Quarter -> ReadPrec Quarter
forall a b. (a -> b) -> a -> b
$ Integer -> QuarterOfYear -> Quarter
fromYearQuarter Integer
y QuarterOfYear
m
addQuarters :: Integer -> Quarter -> Quarter
addQuarters :: Integer -> Quarter -> Quarter
addQuarters Integer
n (MkQuarter Integer
a) = Integer -> Quarter
MkQuarter (Integer -> Quarter) -> Integer -> Quarter
forall a b. (a -> b) -> a -> b
$ Integer
a Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Integer
n
diffQuarters :: Quarter -> Quarter -> Integer
diffQuarters :: Quarter -> Quarter -> Integer
diffQuarters (MkQuarter Integer
a) (MkQuarter Integer
b) = Integer
a Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
- Integer
b
#if __GLASGOW_HASKELL__ >= 710
pattern YearQuarter :: Year -> QuarterOfYear -> Quarter
pattern $bYearQuarter :: Integer -> QuarterOfYear -> Quarter
$mYearQuarter :: forall r.
Quarter -> (Integer -> QuarterOfYear -> r) -> (Void# -> r) -> r
YearQuarter y qy <- (toYearQuarter -> (y, qy))
where YearQuarter Integer
y QuarterOfYear
qy = Integer -> QuarterOfYear -> Quarter
fromYearQuarter Integer
y QuarterOfYear
qy
#if __GLASGOW_HASKELL__ >= 802
{-# COMPLETE YearQuarter #-}
#endif
#endif
monthOfYearQuarter :: MonthOfYear -> QuarterOfYear
monthOfYearQuarter :: Int -> QuarterOfYear
monthOfYearQuarter Int
my | Int
my Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
3 = QuarterOfYear
Q1
monthOfYearQuarter Int
my | Int
my Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
6 = QuarterOfYear
Q2
monthOfYearQuarter Int
my | Int
my Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
9 = QuarterOfYear
Q3
monthOfYearQuarter Int
_ = QuarterOfYear
Q4
monthQuarter :: Month -> Quarter
monthQuarter :: Month -> Quarter
monthQuarter Month
m = case Month -> (Integer, Int)
toYearMonth Month
m of
(Integer
y, Int
my) -> Integer -> QuarterOfYear -> Quarter
fromYearQuarter Integer
y (QuarterOfYear -> Quarter) -> QuarterOfYear -> Quarter
forall a b. (a -> b) -> a -> b
$ Int -> QuarterOfYear
monthOfYearQuarter Int
my
dayQuarter :: Day -> Quarter
dayQuarter :: Day -> Quarter
dayQuarter Day
d = case Day -> (Month, Int)
toMonthDay Day
d of
(Month
m, Int
_) -> Month -> Quarter
monthQuarter Month
m
fromYearQuarter :: Year -> QuarterOfYear -> Quarter
fromYearQuarter :: Integer -> QuarterOfYear -> Quarter
fromYearQuarter Integer
y QuarterOfYear
qy = Integer -> Quarter
MkQuarter (Integer -> Quarter) -> Integer -> Quarter
forall a b. (a -> b) -> a -> b
$ Integer
y Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
4 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
+ Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> Int
forall a. Enum a => a -> a
pred (Int -> Int) -> Int -> Int
forall a b. (a -> b) -> a -> b
$ QuarterOfYear -> Int
forall a. Enum a => a -> Int
fromEnum QuarterOfYear
qy)
toYearQuarter :: Quarter -> (Year, QuarterOfYear)
toYearQuarter :: Quarter -> (Integer, QuarterOfYear)
toYearQuarter (MkQuarter Integer
y) = case Integer -> Integer -> (Integer, Integer)
forall a b. (Real a, Integral b) => a -> a -> (b, a)
divMod' Integer
y Integer
4 of
(Integer
y, Integer
qy) -> (Integer
y, Int -> QuarterOfYear
forall a. Enum a => Int -> a
toEnum (Int -> Int
forall a. Enum a => a -> a
succ (Integer -> Int
forall a. Num a => Integer -> a
fromInteger Integer
qy)))
#endif