{-# LANGUAGE StrictData #-}

module Currycarbon.Types where

import qualified Data.Vector         as V
import qualified Data.Vector.Unboxed as VU

-- * Data types
--
-- $dataTypes
--
-- This module defines the relevant data types for handling radiocarbon dates

-- | currycarbon includes different calibration algorithms. Currently two distinct
-- implementations are available. Maybe more algorithms will be added in the future.
-- A good default is @Bchron { distribution = StudentTDist 100 }@.
data CalibrationMethod =
  -- | A matrix multiplication method generally following [this blog post by Martin Hinz](https://www.martinhinz.info/jekyll/update/blog/2016/06/03/simple_calibration.html).
  -- This method is slower and the underlying code more verbose than 'Bchron', but it
  -- has some advantages regarding didactics and the inspection of intermediate data
  -- products for debugging.
  -- Using this method is generally not advisable, except for specific applications,
  -- where a more technical insight into C14 calibration is needed
    MatrixMultiplication
  -- | A fast and reliable calibration algorithm very similar to the implementation in the
  -- [R package Bchron by Andrew Parnell](https://github.com/andrewcparnell/Bchron/blob/master/R/BchronCalibrate.R).
  -- This algorithm can be run with a simple normal distribution ('NormalDist') or
  -- Student's t-distribution ('StudentTDist'), which is recommended
  | Bchron { CalibrationMethod -> CalibrationDistribution
distribution :: CalibrationDistribution }
  deriving (Int -> CalibrationMethod -> ShowS
[CalibrationMethod] -> ShowS
CalibrationMethod -> String
(Int -> CalibrationMethod -> ShowS)
-> (CalibrationMethod -> String)
-> ([CalibrationMethod] -> ShowS)
-> Show CalibrationMethod
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CalibrationMethod -> ShowS
showsPrec :: Int -> CalibrationMethod -> ShowS
$cshow :: CalibrationMethod -> String
show :: CalibrationMethod -> String
$cshowList :: [CalibrationMethod] -> ShowS
showList :: [CalibrationMethod] -> ShowS
Show, CalibrationMethod -> CalibrationMethod -> Bool
(CalibrationMethod -> CalibrationMethod -> Bool)
-> (CalibrationMethod -> CalibrationMethod -> Bool)
-> Eq CalibrationMethod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CalibrationMethod -> CalibrationMethod -> Bool
== :: CalibrationMethod -> CalibrationMethod -> Bool
$c/= :: CalibrationMethod -> CalibrationMethod -> Bool
/= :: CalibrationMethod -> CalibrationMethod -> Bool
Eq)

-- | A data type to cover the configuration options of the calibrateDates function
data CalibrateDatesConf = CalibrateDatesConf {
      -- | Allow calibration to run outside of the range of the calibration curve
        CalibrateDatesConf -> Bool
_calConfAllowOutside                  :: Bool
      -- | Interpolate the calibration curve before calibration.
      -- This is a simple linear interpolation only to increase the output
      -- resolution for earlier time periods, where the typical calibration
      -- curves are less dense by default. With the interpolation, the output
      -- will be a per-year density. The mechanism is inspired by the
      -- [implementation in the Bchron R package](https://github.com/andrewcparnell/Bchron/blob/b202d18550319b488e676a8b542aba55853f6fa3/R/BchronCalibrate.R#L118-L119)
      , CalibrateDatesConf -> Bool
_calConfInterpolateCalCurve           :: Bool
      -- | Trim the calibration curve before the calibration.
      -- Reduces the calibration curve to a segment around the mean of the
      -- uncalibrated date +/- six times its standard deviation.
      -- This speeds up calibration.
      , CalibrateDatesConf -> Bool
_calConfTrimCalCurveBeforeCalibration :: Bool
      -- | Trim the output CalPDF with a fixed threshold.
      -- Years before or after the first or the last density value of
      -- 0.00001 get removed.
      , CalibrateDatesConf -> Bool
_calConfTrimCalPDFAfterCalibration    :: Bool
    } deriving (Int -> CalibrateDatesConf -> ShowS
[CalibrateDatesConf] -> ShowS
CalibrateDatesConf -> String
(Int -> CalibrateDatesConf -> ShowS)
-> (CalibrateDatesConf -> String)
-> ([CalibrateDatesConf] -> ShowS)
-> Show CalibrateDatesConf
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CalibrateDatesConf -> ShowS
showsPrec :: Int -> CalibrateDatesConf -> ShowS
$cshow :: CalibrateDatesConf -> String
show :: CalibrateDatesConf -> String
$cshowList :: [CalibrateDatesConf] -> ShowS
showList :: [CalibrateDatesConf] -> ShowS
Show, CalibrateDatesConf -> CalibrateDatesConf -> Bool
(CalibrateDatesConf -> CalibrateDatesConf -> Bool)
-> (CalibrateDatesConf -> CalibrateDatesConf -> Bool)
-> Eq CalibrateDatesConf
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CalibrateDatesConf -> CalibrateDatesConf -> Bool
== :: CalibrateDatesConf -> CalibrateDatesConf -> Bool
$c/= :: CalibrateDatesConf -> CalibrateDatesConf -> Bool
/= :: CalibrateDatesConf -> CalibrateDatesConf -> Bool
Eq)

-- | A default configuration that should yield almost identical calibration results
-- to the [Bchron R package](https://github.com/andrewcparnell/Bchron)
defaultCalConf :: CalibrateDatesConf
defaultCalConf :: CalibrateDatesConf
defaultCalConf = CalibrateDatesConf {
        _calConfAllowOutside :: Bool
_calConfAllowOutside = Bool
False
      , _calConfInterpolateCalCurve :: Bool
_calConfInterpolateCalCurve = Bool
True
      , _calConfTrimCalCurveBeforeCalibration :: Bool
_calConfTrimCalCurveBeforeCalibration = Bool
True
      , _calConfTrimCalPDFAfterCalibration :: Bool
_calConfTrimCalPDFAfterCalibration = Bool
True
    }

-- | Statistical distributions to be used with the 'CalibrationMethod' 'Bchron'
data CalibrationDistribution =
  -- | Normal distribution
    NormalDist
  -- | Student's t-distribution.
  | StudentTDist {
      CalibrationDistribution -> Double
ndf :: Double -- ^ number of degrees of freedom
    }
  deriving (Int -> CalibrationDistribution -> ShowS
[CalibrationDistribution] -> ShowS
CalibrationDistribution -> String
(Int -> CalibrationDistribution -> ShowS)
-> (CalibrationDistribution -> String)
-> ([CalibrationDistribution] -> ShowS)
-> Show CalibrationDistribution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CalibrationDistribution -> ShowS
showsPrec :: Int -> CalibrationDistribution -> ShowS
$cshow :: CalibrationDistribution -> String
show :: CalibrationDistribution -> String
$cshowList :: [CalibrationDistribution] -> ShowS
showList :: [CalibrationDistribution] -> ShowS
Show, CalibrationDistribution -> CalibrationDistribution -> Bool
(CalibrationDistribution -> CalibrationDistribution -> Bool)
-> (CalibrationDistribution -> CalibrationDistribution -> Bool)
-> Eq CalibrationDistribution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CalibrationDistribution -> CalibrationDistribution -> Bool
== :: CalibrationDistribution -> CalibrationDistribution -> Bool
$c/= :: CalibrationDistribution -> CalibrationDistribution -> Bool
/= :: CalibrationDistribution -> CalibrationDistribution -> Bool
Eq)

-- | A type to represent years BP. All numbers are positive and describe the distance in years
-- to 1950AD: 3000 = 3000BP = 1050BC
type YearBP = Word
-- | A type to represent years BC or AD. Negative values describe years BC, positive values
-- years AD: -5000 = 5000BC and 1300 = 1300AD
type YearBCAD = Int
-- | A type to represent a range of years
type YearRange = Word

-- | A data type to represent an uncalibrated radiocarbon date
data UncalC14 = UncalC14 {
    -- | Sample identifier, e.g. a lab number
      UncalC14 -> String
_uncalC14Id    :: String
    -- | C14 age in years BP
    , UncalC14 -> YearBP
_uncalC14UnCal :: YearBP
    -- | C14 standard deviation (one sigma in years)
    , UncalC14 -> YearBP
_uncalC14Sigma :: YearRange
    } deriving (Int -> UncalC14 -> ShowS
[UncalC14] -> ShowS
UncalC14 -> String
(Int -> UncalC14 -> ShowS)
-> (UncalC14 -> String) -> ([UncalC14] -> ShowS) -> Show UncalC14
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UncalC14 -> ShowS
showsPrec :: Int -> UncalC14 -> ShowS
$cshow :: UncalC14 -> String
show :: UncalC14 -> String
$cshowList :: [UncalC14] -> ShowS
showList :: [UncalC14] -> ShowS
Show, UncalC14 -> UncalC14 -> Bool
(UncalC14 -> UncalC14 -> Bool)
-> (UncalC14 -> UncalC14 -> Bool) -> Eq UncalC14
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UncalC14 -> UncalC14 -> Bool
== :: UncalC14 -> UncalC14 -> Bool
$c/= :: UncalC14 -> UncalC14 -> Bool
/= :: UncalC14 -> UncalC14 -> Bool
Eq)

-- | A data type to represent a year-wise probability density for uncalibrated dates
-- Although technically not correct, we still call this a probability density function (PDF)
data UncalPDF = UncalPDF {
    -- | Sample identifier, e.g. a lab number
      UncalPDF -> String
_uncalPDFid     :: String
    -- | Years BP
    , UncalPDF -> Vector YearBP
_uncalPDFUnCals :: VU.Vector YearBP
    -- | Probability densities
    , UncalPDF -> Vector Double
_uncalPDFDens   :: VU.Vector Double
    } deriving Int -> UncalPDF -> ShowS
[UncalPDF] -> ShowS
UncalPDF -> String
(Int -> UncalPDF -> ShowS)
-> (UncalPDF -> String) -> ([UncalPDF] -> ShowS) -> Show UncalPDF
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UncalPDF -> ShowS
showsPrec :: Int -> UncalPDF -> ShowS
$cshow :: UncalPDF -> String
show :: UncalPDF -> String
$cshowList :: [UncalPDF] -> ShowS
showList :: [UncalPDF] -> ShowS
Show

-- | A data type to represent a calibration curve with 'YearBP'
data CalCurveBP = CalCurveBP {
    -- | Years calBP
      CalCurveBP -> Vector YearBP
_calCurveBPCals   :: VU.Vector YearBP
    -- | Years BP
    , CalCurveBP -> Vector YearBP
_calCurveBPUnCals :: VU.Vector YearBP
    -- | Standard deviation (one sigma in years)
    , CalCurveBP -> Vector YearBP
_calCurveBPSigmas :: VU.Vector YearRange
    } deriving Int -> CalCurveBP -> ShowS
[CalCurveBP] -> ShowS
CalCurveBP -> String
(Int -> CalCurveBP -> ShowS)
-> (CalCurveBP -> String)
-> ([CalCurveBP] -> ShowS)
-> Show CalCurveBP
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CalCurveBP -> ShowS
showsPrec :: Int -> CalCurveBP -> ShowS
$cshow :: CalCurveBP -> String
show :: CalCurveBP -> String
$cshowList :: [CalCurveBP] -> ShowS
showList :: [CalCurveBP] -> ShowS
Show

-- | A second data type to represent a calibration curve, here now with 'YearBCAD'
data CalCurveBCAD = CalCurveBCAD {
    -- | Years calBCAD
      CalCurveBCAD -> Vector Int
_calCurveBCADCals   :: VU.Vector YearBCAD
    -- | Years BCAD
    , CalCurveBCAD -> Vector Int
_calCurveBCADUnCals :: VU.Vector YearBCAD
    -- | Standard deviation (one sigma in years)
    , CalCurveBCAD -> Vector YearBP
_calCurveBCADSigmas :: VU.Vector YearRange
    } deriving Int -> CalCurveBCAD -> ShowS
[CalCurveBCAD] -> ShowS
CalCurveBCAD -> String
(Int -> CalCurveBCAD -> ShowS)
-> (CalCurveBCAD -> String)
-> ([CalCurveBCAD] -> ShowS)
-> Show CalCurveBCAD
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CalCurveBCAD -> ShowS
showsPrec :: Int -> CalCurveBCAD -> ShowS
$cshow :: CalCurveBCAD -> String
show :: CalCurveBCAD -> String
$cshowList :: [CalCurveBCAD] -> ShowS
showList :: [CalCurveBCAD] -> ShowS
Show

-- | A data type to represent a calibration curve in a /wide/ matrix form
data CalCurveMatrix = CalCurveMatrix {
    -- | Row names of the calibration curve matrix: Years BCAD
      CalCurveMatrix -> Vector Int
_calCurveMatrixUnCals :: VU.Vector YearBCAD
    -- | Column names of the calibration curve matrix: Years calBCAD
    , CalCurveMatrix -> Vector Int
_calCurveMatrixCals   :: VU.Vector YearBCAD
    -- | Matrix (as a list of columns) with the probability densities
    , CalCurveMatrix -> Vector (Vector Double)
_calCurveMatrixDens   :: V.Vector (VU.Vector Double)
    } deriving Int -> CalCurveMatrix -> ShowS
[CalCurveMatrix] -> ShowS
CalCurveMatrix -> String
(Int -> CalCurveMatrix -> ShowS)
-> (CalCurveMatrix -> String)
-> ([CalCurveMatrix] -> ShowS)
-> Show CalCurveMatrix
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CalCurveMatrix -> ShowS
showsPrec :: Int -> CalCurveMatrix -> ShowS
$cshow :: CalCurveMatrix -> String
show :: CalCurveMatrix -> String
$cshowList :: [CalCurveMatrix] -> ShowS
showList :: [CalCurveMatrix] -> ShowS
Show

-- | A data type to represent a year-wise probability density for calibrated dates.
-- Although technically not correct, we still call this a probability density function (PDF)
data CalPDF = CalPDF {
    -- | Sample identifier, e.g. a lab number
      CalPDF -> String
_calPDFid   :: String
    -- | Years calBCAD
    , CalPDF -> Vector Int
_calPDFCals :: VU.Vector YearBCAD
    -- | Probability densities for each year in '_calPDFCals'
    , CalPDF -> Vector Double
_calPDFDens :: VU.Vector Double
    } deriving (Int -> CalPDF -> ShowS
[CalPDF] -> ShowS
CalPDF -> String
(Int -> CalPDF -> ShowS)
-> (CalPDF -> String) -> ([CalPDF] -> ShowS) -> Show CalPDF
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CalPDF -> ShowS
showsPrec :: Int -> CalPDF -> ShowS
$cshow :: CalPDF -> String
show :: CalPDF -> String
$cshowList :: [CalPDF] -> ShowS
showList :: [CalPDF] -> ShowS
Show, CalPDF -> CalPDF -> Bool
(CalPDF -> CalPDF -> Bool)
-> (CalPDF -> CalPDF -> Bool) -> Eq CalPDF
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CalPDF -> CalPDF -> Bool
== :: CalPDF -> CalPDF -> Bool
$c/= :: CalPDF -> CalPDF -> Bool
/= :: CalPDF -> CalPDF -> Bool
Eq)

-- | A data type for named calibration expressions
data NamedCalExpr = NamedCalExpr {
    -- | Expression identifier
      NamedCalExpr -> String
_exprID :: String
    -- | Expression
    , NamedCalExpr -> CalExpr
_expr   :: CalExpr
    } deriving (Int -> NamedCalExpr -> ShowS
[NamedCalExpr] -> ShowS
NamedCalExpr -> String
(Int -> NamedCalExpr -> ShowS)
-> (NamedCalExpr -> String)
-> ([NamedCalExpr] -> ShowS)
-> Show NamedCalExpr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NamedCalExpr -> ShowS
showsPrec :: Int -> NamedCalExpr -> ShowS
$cshow :: NamedCalExpr -> String
show :: NamedCalExpr -> String
$cshowList :: [NamedCalExpr] -> ShowS
showList :: [NamedCalExpr] -> ShowS
Show, NamedCalExpr -> NamedCalExpr -> Bool
(NamedCalExpr -> NamedCalExpr -> Bool)
-> (NamedCalExpr -> NamedCalExpr -> Bool) -> Eq NamedCalExpr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NamedCalExpr -> NamedCalExpr -> Bool
== :: NamedCalExpr -> NamedCalExpr -> Bool
$c/= :: NamedCalExpr -> NamedCalExpr -> Bool
/= :: NamedCalExpr -> NamedCalExpr -> Bool
Eq)

-- | A data type to represent an expression for sum- or product calibration
data CalExpr =
      UnCalDate UncalC14
    | WindowBP TimeWindowBP
    | WindowBCAD TimeWindowBCAD
    | CalDate CalPDF
    | SumCal CalExpr CalExpr
    | ProductCal CalExpr CalExpr
    deriving (Int -> CalExpr -> ShowS
[CalExpr] -> ShowS
CalExpr -> String
(Int -> CalExpr -> ShowS)
-> (CalExpr -> String) -> ([CalExpr] -> ShowS) -> Show CalExpr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CalExpr -> ShowS
showsPrec :: Int -> CalExpr -> ShowS
$cshow :: CalExpr -> String
show :: CalExpr -> String
$cshowList :: [CalExpr] -> ShowS
showList :: [CalExpr] -> ShowS
Show, CalExpr -> CalExpr -> Bool
(CalExpr -> CalExpr -> Bool)
-> (CalExpr -> CalExpr -> Bool) -> Eq CalExpr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CalExpr -> CalExpr -> Bool
== :: CalExpr -> CalExpr -> Bool
$c/= :: CalExpr -> CalExpr -> Bool
/= :: CalExpr -> CalExpr -> Bool
Eq)
-- http://www.cse.chalmers.se/edu/year/2018/course/TDA452/lectures/RecursiveDataTypes.html

data TimeWindowBP = TimeWindowBP String YearBP YearBP
    deriving (Int -> TimeWindowBP -> ShowS
[TimeWindowBP] -> ShowS
TimeWindowBP -> String
(Int -> TimeWindowBP -> ShowS)
-> (TimeWindowBP -> String)
-> ([TimeWindowBP] -> ShowS)
-> Show TimeWindowBP
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TimeWindowBP -> ShowS
showsPrec :: Int -> TimeWindowBP -> ShowS
$cshow :: TimeWindowBP -> String
show :: TimeWindowBP -> String
$cshowList :: [TimeWindowBP] -> ShowS
showList :: [TimeWindowBP] -> ShowS
Show, TimeWindowBP -> TimeWindowBP -> Bool
(TimeWindowBP -> TimeWindowBP -> Bool)
-> (TimeWindowBP -> TimeWindowBP -> Bool) -> Eq TimeWindowBP
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TimeWindowBP -> TimeWindowBP -> Bool
== :: TimeWindowBP -> TimeWindowBP -> Bool
$c/= :: TimeWindowBP -> TimeWindowBP -> Bool
/= :: TimeWindowBP -> TimeWindowBP -> Bool
Eq)

data TimeWindowBCAD = TimeWindowBCAD String YearBCAD YearBCAD
    deriving (Int -> TimeWindowBCAD -> ShowS
[TimeWindowBCAD] -> ShowS
TimeWindowBCAD -> String
(Int -> TimeWindowBCAD -> ShowS)
-> (TimeWindowBCAD -> String)
-> ([TimeWindowBCAD] -> ShowS)
-> Show TimeWindowBCAD
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TimeWindowBCAD -> ShowS
showsPrec :: Int -> TimeWindowBCAD -> ShowS
$cshow :: TimeWindowBCAD -> String
show :: TimeWindowBCAD -> String
$cshowList :: [TimeWindowBCAD] -> ShowS
showList :: [TimeWindowBCAD] -> ShowS
Show, TimeWindowBCAD -> TimeWindowBCAD -> Bool
(TimeWindowBCAD -> TimeWindowBCAD -> Bool)
-> (TimeWindowBCAD -> TimeWindowBCAD -> Bool) -> Eq TimeWindowBCAD
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TimeWindowBCAD -> TimeWindowBCAD -> Bool
== :: TimeWindowBCAD -> TimeWindowBCAD -> Bool
$c/= :: TimeWindowBCAD -> TimeWindowBCAD -> Bool
/= :: TimeWindowBCAD -> TimeWindowBCAD -> Bool
Eq)

-- | A data type to represent a human readable summary of a calibrated radiocarbon date
data CalC14 = CalC14 {
    -- | Identifier, e.g. a lab number
      CalC14 -> String
_calC14id           :: String
    -- | Summary of the range of the calibrated date
    , CalC14 -> CalRangeSummary
_calC14RangeSummary :: CalRangeSummary
    -- | One-sigma high density regions
    , CalC14 -> [HDR]
_calC14HDROneSigma  :: [HDR]
    -- | Two-sigma high density regions
    , CalC14 -> [HDR]
_calC14HDRTwoSigma  :: [HDR]
    } deriving Int -> CalC14 -> ShowS
[CalC14] -> ShowS
CalC14 -> String
(Int -> CalC14 -> ShowS)
-> (CalC14 -> String) -> ([CalC14] -> ShowS) -> Show CalC14
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CalC14 -> ShowS
showsPrec :: Int -> CalC14 -> ShowS
$cshow :: CalC14 -> String
show :: CalC14 -> String
$cshowList :: [CalC14] -> ShowS
showList :: [CalC14] -> ShowS
Show

-- | A data type to store a simple range summary of the calibrated date, including
-- the median age
data CalRangeSummary = CalRangeSummary {
    -- | Start of the two-sigma age range
      CalRangeSummary -> Int
_calRangeStartTwoSigma :: YearBCAD
    -- | Start of the one-sigma age range
    , CalRangeSummary -> Int
_calRangeStartOneSigma :: YearBCAD
    -- | Median age
    , CalRangeSummary -> Int
_calRangeMedian        :: YearBCAD
    -- | End of the one-sigma age range
    , CalRangeSummary -> Int
_calRangeStopOneSigma  :: YearBCAD
    -- | End of the two-sigma age range
    , CalRangeSummary -> Int
_calRangeStopTwoSigma  :: YearBCAD
} deriving Int -> CalRangeSummary -> ShowS
[CalRangeSummary] -> ShowS
CalRangeSummary -> String
(Int -> CalRangeSummary -> ShowS)
-> (CalRangeSummary -> String)
-> ([CalRangeSummary] -> ShowS)
-> Show CalRangeSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CalRangeSummary -> ShowS
showsPrec :: Int -> CalRangeSummary -> ShowS
$cshow :: CalRangeSummary -> String
show :: CalRangeSummary -> String
$cshowList :: [CalRangeSummary] -> ShowS
showList :: [CalRangeSummary] -> ShowS
Show

-- | A data type to represent a high density region of a probability distribution.
-- A high density region is here defined as an age range, within which the respective
-- cumulative probability (e.g. of an calibrated radiocarbon date density curve)
-- is above a certain threshold
data HDR = HDR {
    -- | Start of the high density region in years calBCAD
      HDR -> Int
_hdrstart :: YearBCAD
    -- | End of the high density region in years calBCAD
    , HDR -> Int
_hdrstop  :: YearBCAD
    } deriving (Int -> HDR -> ShowS
[HDR] -> ShowS
HDR -> String
(Int -> HDR -> ShowS)
-> (HDR -> String) -> ([HDR] -> ShowS) -> Show HDR
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HDR -> ShowS
showsPrec :: Int -> HDR -> ShowS
$cshow :: HDR -> String
show :: HDR -> String
$cshowList :: [HDR] -> ShowS
showList :: [HDR] -> ShowS
Show, HDR -> HDR -> Bool
(HDR -> HDR -> Bool) -> (HDR -> HDR -> Bool) -> Eq HDR
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HDR -> HDR -> Bool
== :: HDR -> HDR -> Bool
$c/= :: HDR -> HDR -> Bool
/= :: HDR -> HDR -> Bool
Eq)

-- | A data type to store random samples drawn from a calPDF
data RandomAgeSample = RandomAgeSample {
    -- | Identifier
      RandomAgeSample -> String
_rasId      :: String
    -- | Random samples
    , RandomAgeSample -> Vector Int
_rasSamples :: VU.Vector YearBCAD
    } deriving Int -> RandomAgeSample -> ShowS
[RandomAgeSample] -> ShowS
RandomAgeSample -> String
(Int -> RandomAgeSample -> ShowS)
-> (RandomAgeSample -> String)
-> ([RandomAgeSample] -> ShowS)
-> Show RandomAgeSample
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RandomAgeSample -> ShowS
showsPrec :: Int -> RandomAgeSample -> ShowS
$cshow :: RandomAgeSample -> String
show :: RandomAgeSample -> String
$cshowList :: [RandomAgeSample] -> ShowS
showList :: [RandomAgeSample] -> ShowS
Show