DataForecast-0.1.0.0: Type-safe data analysis.

Safe HaskellNone
LanguageHaskell2010

DataForecast.TimeSeries

Contents

Description

 

Synopsis

TimeSeries

data TimeSeries parts where Source #

Time series date representation with the resolution breakdown encoded in the type.

parts has kind '[TsPeriod]' which represents the hierarchical breakdown of your data. You are responsible for providing the correct type hierarchy for your data initially, but once you have done that the library ensures that all analysis performed is valid.

In general you should not use the TimeSeries constructor directly, instead use the raw and fromParts construction functions defined below.

Constructors

TimeSeries :: SPeriod p -> SummaryData -> Subparts subparts -> TimeSeries (p ': subparts) 

Instances

Eq (TimeSeries parts) Source # 

Methods

(==) :: TimeSeries parts -> TimeSeries parts -> Bool #

(/=) :: TimeSeries parts -> TimeSeries parts -> Bool #

Show (TimeSeries parts) Source # 

Methods

showsPrec :: Int -> TimeSeries parts -> ShowS #

show :: TimeSeries parts -> String #

showList :: [TimeSeries parts] -> ShowS #

getSD :: TimeSeries parts -> SummaryData Source #

Get the SummaryData out of a TimeSeries.

setSD :: SummaryData -> TimeSeries parts -> TimeSeries parts Source #

Set the SummaryData field of a TimeSeries. We can't use record syntax because https://ghc.haskell.org/trac/ghc/ticket/2595 is not implemented.

getSub :: TimeSeries (p ': subparts) -> Subparts subparts Source #

Get the Subparts out of a TimeSeries.

setSub :: Subparts subparts -> TimeSeries (p ': subparts) -> TimeSeries (p ': subparts) Source #

Set the Subparts of the TimeSeries.

Construction.

class BuildTS p where Source #

Typeclass for constructing TimeSeries with default data.

This is used by several of the TimeSeries construction functions such as raw. It provides a convenient way for constructing time series of different types with the same functions and allowing the concrete type to be pinned down by a type signature.

Minimal complete definition

build

Methods

build :: SummaryData -> Subparts rest -> TimeSeries (p ': rest) Source #

raw :: BuildTS p => Double -> TimeSeries '[p] Source #

Construct a leaf TimeSeries with the given rawData. Usually you should not need to use this directly and can instead use fromRawData.

Example:

raw 42 :: TimeSeries '[ 'Year ]

fromRawData :: (BuildTS p, BuildTS parts) => [Double] -> TimeSeries '[p, parts] Source #

Construct a TimeSeries given the constituent raw data.

Example:

yearByQuarter :: TimeSeries '[ 'Year, 'Quarter ]
yearByQuarter = fromRawData [ 10, 20, 30, 15 ]

fromParts :: BuildTS part => [TimeSeries subparts] -> TimeSeries (part ': subparts) Source #

Construct a TimeSeries given the constituent TimeSeries parts.

TsPeriod

data TsPeriod Source #

Use promoted constructors to represent the different timeseries that we have. When using these as kinds you must prefix them with a single quote (').

Example:

raw 4 :: TimeSeries '[ 'Day ]

Constructors

Decade 
Year 
Quarter 
Month 
Week 
Day 

SummaryData

data SummaryData Source #

The summarization of the entire time series rooted at the current 'TimeSeries.

Constructors

SummaryData 

Subparts

data Subparts parts Source #

The constituent components of a TimeSeries. If the TimeSeries is just a leaf with raw data then subs will be Nothing.

Constructors

Subparts 

Fields

Instances

Eq (Subparts parts) Source # 

Methods

(==) :: Subparts parts -> Subparts parts -> Bool #

(/=) :: Subparts parts -> Subparts parts -> Bool #

Show (Subparts parts) Source # 

Methods

showsPrec :: Int -> Subparts parts -> ShowS #

show :: Subparts parts -> String #

showList :: [Subparts parts] -> ShowS #

Default (Subparts ([] TsPeriod)) Source # 

Methods

def :: Subparts [TsPeriod] #