diff options
author | Joris | 2016-03-26 20:29:15 +0100 |
---|---|---|
committer | Joris | 2016-03-26 20:29:36 +0100 |
commit | 2e411664ce8da96fd50340b1ecb9e6e2e16f6ca2 (patch) | |
tree | 4d9399723a470a2fcd24b1df05aeb481468492de /Data/ConfigManager/Instances.hs | |
parent | 88aef982ff7a1be7fba2abf7264773b511608404 (diff) |
Parse durations
Diffstat (limited to 'Data/ConfigManager/Instances.hs')
-rw-r--r-- | Data/ConfigManager/Instances.hs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Data/ConfigManager/Instances.hs b/Data/ConfigManager/Instances.hs new file mode 100644 index 0000000..0855117 --- /dev/null +++ b/Data/ConfigManager/Instances.hs @@ -0,0 +1,24 @@ +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE IncoherentInstances #-} +{-# OPTIONS_GHC -fno-warn-orphans #-} + +module Data.ConfigManager.Instances + () where + +import qualified Data.Text as T +import Data.Time.Clock (DiffTime, NominalDiffTime) + +import Text.Read (readMaybe) + +import Data.ConfigManager.Types.Internal +import Data.ConfigManager.Parser.Duration (parseDuration) + +instance Configured DiffTime where + convert value = parseDuration value + +instance Configured NominalDiffTime where + convert value = realToFrac <$> parseDuration value + +instance Read a => Configured a where + convert = readMaybe . T.unpack |