From: PHO Date: Thu, 22 Apr 2010 10:28:46 +0000 (+0900) Subject: wip X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=79dfae84547f2148b52c317c40bd672e3e52bd5d;p=hs-rrdtool.git wip --- diff --git a/Database/RRDtool.hs b/Database/RRDtool.hs index 6e7b332..f588fdb 100644 --- a/Database/RRDtool.hs +++ b/Database/RRDtool.hs @@ -17,6 +17,7 @@ module Database.RRDtool , CommonSetOp(..) , VariableShiftPredictOp(..) , FixedShiftPredictOp(..) + , CommonValue(..) , IterativeValue(..) , AggregativeUnaryOp(..) @@ -155,7 +156,7 @@ dsTest = COMPUTE { dsName = "foo" -- , dsExpr = Previous :<: Const 100 -- , dsExpr = Var "foo" :<: Const 100 - , dsExpr = Average (Const 100 .*. Const 200 .*. HNil) + , dsExpr = AverageOf (Const 100 .*. Const 200 .*. HNil) } class (Show e, Eq e) => Expr e @@ -163,7 +164,6 @@ class Expr e => CommonExpr e class Expr e => IterativeExpr e class Expr e => AggregativeExpr e instance CommonExpr e => IterativeExpr e -instance CommonExpr e => AggregativeExpr e class (Show es, Eq es, HList es) => ExprSet es instance ExprSet HNil @@ -244,7 +244,7 @@ instance (CommonExpr a, CommonExpr b, CommonExpr c) -- multiple values onto the stack... data CommonSetOp es - = Average !es + = AverageOf !es deriving (Show, Eq, Ord) instance ExprSet es => Expr (CommonSetOp es) instance CommonExprSet es => CommonExpr (CommonSetOp es) @@ -267,19 +267,45 @@ instance (Expr sm, Expr w) instance (CommonExpr sm, CommonExpr w) => CommonExpr (FixedShiftPredictOp sm w) +-- Common special values +data CommonValue + = Unknown + | Infinity + | NegativeInfinity + | Now + deriving (Show, Eq, Ord) +instance Expr CommonValue +instance CommonExpr CommonValue + -- Iterative special values data IterativeValue = Previous + | PreviousOf !Variable + | Count + | TakenTime + | TakenLocalTime deriving (Show, Eq, Ord) instance Expr IterativeValue instance IterativeExpr IterativeValue --- Aggregative operators -data AggregativeUnaryOp a - = Maximum !a +-- Aggregative operators (fairly restricted due to rrdtool's +-- restriction) +data AggregativeUnaryOp + = Maximum !Variable + | Minimum !Variable + | Average !Variable + | StandardDeviation !Variable + | First !Variable + | Last !Variable + | Total !Variable + | Percent !Variable !Constant + | PercentNan !Variable !Constant + | LSLSlope !Variable + | LSLInt !Variable + | LSLCorrel !Variable deriving (Show, Eq, Ord) -instance Expr a => Expr (AggregativeUnaryOp a) -instance AggregativeExpr a => AggregativeExpr (AggregativeUnaryOp a) +instance Expr AggregativeUnaryOp +instance AggregativeExpr AggregativeUnaryOp -- |The 'createRRD' function lets you set up new Round Robin Database -- (RRD) files. The file is created at its final, full size and filled