From 33f5e740cf2d85750550937a238e2427dcdcd6de Mon Sep 17 00:00:00 2001 From: PHO Date: Thu, 22 Apr 2010 18:57:20 +0900 Subject: [PATCH] wip --- Database/RRDtool.hs | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/Database/RRDtool.hs b/Database/RRDtool.hs index 7d4fda9..6e7b332 100644 --- a/Database/RRDtool.hs +++ b/Database/RRDtool.hs @@ -10,10 +10,13 @@ module Database.RRDtool , CommonExprSet , Constant(..) + , Variable(..) , CommonUnaryOp(..) , CommonBinaryOp(..) , CommonTrinaryOp(..) , CommonSetOp(..) + , VariableShiftPredictOp(..) + , FixedShiftPredictOp(..) , IterativeValue(..) , AggregativeUnaryOp(..) @@ -155,18 +158,18 @@ dsTest = COMPUTE { , dsExpr = Average (Const 100 .*. Const 200 .*. HNil) } -class Show e => Expr e +class (Show e, Eq e) => Expr e 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, HList es) => ExprSet es +class (Show es, Eq es, HList es) => ExprSet es instance ExprSet HNil instance (Expr e, ExprSet es) => ExprSet (HCons e es) -class (Show es, HList es) => CommonExprSet es +class (Show es, Eq es, HList es) => CommonExprSet es instance CommonExprSet es => ExprSet es instance CommonExprSet HNil instance (CommonExpr e, CommonExprSet es) => CommonExprSet (HCons e es) @@ -175,11 +178,16 @@ instance (CommonExpr e, CommonExprSet es) => CommonExprSet (HCons e es) -- Constants and variable names data Constant = Const !Double - | Var !String deriving (Show, Eq, Ord) instance Expr Constant instance CommonExpr Constant +data Variable + = Var !String + deriving (Show, Eq, Ord) +instance Expr Variable +instance CommonExpr Variable + -- Common operators data CommonUnaryOp a = IsUnknown !a @@ -195,6 +203,8 @@ data CommonUnaryOp a | Deg2Rad !a | Rad2Deg !a | Abs !a + | Trend !Variable !a + | TrendNan !Variable !a deriving (Show, Eq, Ord) instance Expr a => Expr (CommonUnaryOp a) instance CommonExpr a => CommonExpr (CommonUnaryOp a) @@ -239,6 +249,24 @@ data CommonSetOp es instance ExprSet es => Expr (CommonSetOp es) instance CommonExprSet es => CommonExpr (CommonSetOp es) +data VariableShiftPredictOp ss w + = VariableShiftPredictAverage !ss !w !Variable + | VariableShiftPredictSigma !ss !w !Variable + deriving (Show, Eq, Ord) +instance (ExprSet ss, Expr w) + => Expr (VariableShiftPredictOp ss w) +instance (CommonExprSet ss, CommonExpr w) + => CommonExpr (VariableShiftPredictOp ss w) + +data FixedShiftPredictOp sm w + = FixedShiftPredictAverage !sm !w !Variable + | FixedShiftPredictSigma !sm !w !Variable + deriving (Show, Eq, Ord) +instance (Expr sm, Expr w) + => Expr (FixedShiftPredictOp sm w) +instance (CommonExpr sm, CommonExpr w) + => CommonExpr (FixedShiftPredictOp sm w) + -- Iterative special values data IterativeValue = Previous -- 2.40.0