]> gitweb @ CieloNegro.org - hs-rrdtool.git/blobdiff - Database/RRDtool/Create.hs
make use of hString
[hs-rrdtool.git] / Database / RRDtool / Create.hs
index a3b51e54171d74e14d1ad822ece4fd8281a0c870..3c403db46f99de5ad8af3c9bfb41b90145692361 100644 (file)
@@ -1,3 +1,7 @@
+{-# LANGUAGE
+  TypeFamilies,
+  UndecidableInstances
+  #-}
 module Database.RRDtool.Create
     ( DataSource
     , ExternalDSType(..)
@@ -28,6 +32,7 @@ import Data.HList
 import Data.Time.Clock
 import Data.Time.Clock.POSIX
 import Database.RRDtool.Expression
+import Types.Data.Bool
 
 
 -- |A single RRD can accept input from several data sources (DS), for
@@ -86,14 +91,12 @@ data ExternalDSType
                -- number of messages since the last update.
     deriving (Show, Eq, Ord)
 
-instance DataSource ExternalDSType
-
-data ExternalDataSource
+data ExternalDataSource vn
     = ExternalDataSource {
         -- |The name you will use to reference this particular data
         -- source from an RRD. A ds name must be 1 to 19 characters
         -- long in the characters @[a-zA-Z0-9_]@.
-        edsName :: !String
+        edsName :: !vn
         -- |The type of this data source.
       , edsType :: !ExternalDSType
         -- |Defines the maximum number of seconds that may pass
@@ -119,6 +122,10 @@ data ExternalDataSource
       }
     deriving (Show, Eq, Ord)
 
+instance ( IsVarName vn ~ True
+         )
+    => DataSource (ExternalDataSource vn)
+
 
 -- |ComputedDataSource is for storing the result of a formula applied
 -- to other data sources in the RRD. This data source is not supplied
@@ -131,10 +138,10 @@ data ExternalDataSource
 -- \"computed\" columns.
 --
 -- FIXME: doc links
-data ComputedDataSource e
+data ComputedDataSource vn e
     = ComputedDataSource {
         -- |See 'edsName'
-        cdsName :: !String
+        cdsName :: !vn
         -- |rpn-expression defines the formula used to compute the
         -- PDPs of a COMPUTE data source from other data sources in
         -- the same \<RRD\>. It is similar to defining a CDEF argument
@@ -152,15 +159,19 @@ data ComputedDataSource e
     }
     deriving (Show, Eq, Ord)
 
-instance IsCommonExpr e => DataSource (ComputedDataSource e)
-
+instance ( IsVarName vn ~ True
+         , IsCommonExpr e ~ True
+         )
+    => DataSource (ComputedDataSource vn e)
 
+{-
 dsTest = ComputedDataSource {
            cdsName = "foo"
---       dsExpr = Previous :<: Const 100
---       dsExpr = Var "foo" :<: Const 100
+--         , cdsExpr = Previous :<: Const 100
+--         , cdsExpr = Var "foo" :<: Const 100
          , cdsExpr = AverageOf (Const 100 .*. Const 200 .*. HNil)
          }
+-}
 
 -- |The 'createRRD' function lets you set up new Round Robin Database
 -- (RRD) files. The file is created at its final, full size and filled