]> gitweb @ CieloNegro.org - hs-rrdtool.git/blobdiff - Database/RRDtool/Create.hs
HOccurs series
[hs-rrdtool.git] / Database / RRDtool / Create.hs
index 3c403db46f99de5ad8af3c9bfb41b90145692361..5dd3b9f8fc12aadee9c64bef068dd335ee99b289 100644 (file)
@@ -1,4 +1,6 @@
 {-# LANGUAGE
+  FlexibleContexts,
+  FlexibleInstances,
   TypeFamilies,
   UndecidableInstances
   #-}
@@ -10,7 +12,7 @@ module Database.RRDtool.Create
     , createRRD
 
     -- Data.HList
-    , (.*.)    
+    , (.&.)
     , HNil(..)
 
     -- Database.RRDtool.Expression
@@ -173,22 +175,39 @@ dsTest = ComputedDataSource {
          }
 -}
 
+-- |The name of the RRD you want to create. RRD files should end with
+-- the extension @.rrd@. However, RRDtool will accept any filename.
+newtype RRDPath = RRDPath FilePath
+
+-- |Do not clobber an existing file of the same name.
+data KeepOldRRD = KeepOldRRD
+
+-- |Specifies the time in seconds since @1970-01-01 UTC@ when the
+-- first value should be added to the RRD. RRDtool will not accept any
+-- data timed before or at the time specified. (default: @now - 10s@)
+newtype RRDStartTime = RRDStartTime POSIXTime
+
+-- |Specifies the base interval in seconds with which data will be fed
+-- into the RRD. (default: 300 sec)
+newtype RRDInterval = RRDInterval NominalDiffTime
+
+class RRDSpec s
+instance ( HOccurs    RRDPath      s
+         , HOccursOpt KeepOldRRD   s
+         , HOccursOpt RRDStartTime s
+         , HOccursOpt RRDInterval  s
+         )
+    => RRDSpec s
+
 -- |The 'createRRD' function lets you set up new Round Robin Database
 -- (RRD) files. The file is created at its final, full size and filled
 -- with @*UNKNOWN*@ data.
-createRRD
-    :: FilePath -- ^The name of the RRD you want to create. RRD files
-                -- should end with the extension @.rrd@. However,
-                -- RRDtool will accept any filename.
-    -> Bool -- ^Do not clobber an existing file of the same name.
-    -> Maybe POSIXTime -- ^Specifies the time in seconds since
-                       -- @1970-01-01 UTC@ when the first value should
-                       -- be added to the RRD. RRDtool will not accept
-                       -- any data timed before or at the time
-                       -- specified. (default: @now - 10s@)
-    -> Maybe NominalDiffTime -- ^Specifies the base interval in
-                             -- seconds with which data will be fed
-                             -- into the RRD. (default: 300 sec)
---    -> [DataSource] -- ^Data sources to accept input from.
-    -> IO ()
+createRRD :: RRDSpec s => s -> IO ()
 createRRD = error "FIXME"
+
+testMain :: IO ()
+testMain = let s = RRDPath "test.rrd" .&.
+                   KeepOldRRD         .&.
+                   HNil
+           in
+             createRRD s