packages feed

text-format-heavy 0.1.5.0 → 0.1.5.1

raw patch · 3 files changed

+64/−1 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Data.Text.Format.Heavy.Instances: instance Data.Text.Format.Heavy.Types.Formatable x => Data.Text.Format.Heavy.Types.VarContainer (Data.Map.Base.Map Data.Text.Internal.Lazy.Text x)
- Data.Text.Format.Heavy.Time: instance Data.Text.Format.Heavy.Types.Formatable Data.Time.Clock.UTC.UTCTime
- Data.Text.Format.Heavy.Time: instance Data.Text.Format.Heavy.Types.Formatable Data.Time.LocalTime.LocalTime.LocalTime
- Data.Text.Format.Heavy.Time: instance Data.Text.Format.Heavy.Types.Formatable Data.Time.LocalTime.LocalTime.ZonedTime
- Data.Text.Format.Heavy.Time: instance Data.Text.Format.Heavy.Types.Formatable Data.Time.LocalTime.TimeOfDay.TimeOfDay
- Data.Text.Format.Heavy.Time: instance Data.Text.Format.Heavy.Types.Formatable Data.Time.LocalTime.TimeZone.TimeZone
+ Data.Text.Format.Heavy.Instances: instance (Data.Text.Format.Heavy.Types.ClosedVarContainer c1, Data.Text.Format.Heavy.Types.ClosedVarContainer c2) => Data.Text.Format.Heavy.Types.ClosedVarContainer (Data.Text.Format.Heavy.Instances.ThenCheck c1 c2)
+ Data.Text.Format.Heavy.Instances: instance (Data.Text.Format.Heavy.Types.Formatable a, Data.Text.Format.Heavy.Types.Formatable b) => Data.Text.Format.Heavy.Types.ClosedVarContainer (a, b)
+ Data.Text.Format.Heavy.Instances: instance (Data.Text.Format.Heavy.Types.Formatable a, Data.Text.Format.Heavy.Types.Formatable b, Data.Text.Format.Heavy.Types.Formatable c) => Data.Text.Format.Heavy.Types.ClosedVarContainer (a, b, c)
+ Data.Text.Format.Heavy.Instances: instance (Data.Text.Format.Heavy.Types.Formatable a, Data.Text.Format.Heavy.Types.Formatable b, Data.Text.Format.Heavy.Types.Formatable c, Data.Text.Format.Heavy.Types.Formatable d) => Data.Text.Format.Heavy.Types.ClosedVarContainer (a, b, c, d)
+ Data.Text.Format.Heavy.Instances: instance (Data.Text.Format.Heavy.Types.Formatable a, Data.Text.Format.Heavy.Types.Formatable b, Data.Text.Format.Heavy.Types.Formatable c, Data.Text.Format.Heavy.Types.Formatable d, Data.Text.Format.Heavy.Types.Formatable e) => Data.Text.Format.Heavy.Types.ClosedVarContainer (a, b, c, d, e)
+ Data.Text.Format.Heavy.Instances: instance (Data.Text.Format.Heavy.Types.Formatable a, Data.Text.Format.Heavy.Types.Formatable b, Data.Text.Format.Heavy.Types.Formatable c, Data.Text.Format.Heavy.Types.Formatable d, Data.Text.Format.Heavy.Types.Formatable e, Data.Text.Format.Heavy.Types.Formatable f) => Data.Text.Format.Heavy.Types.ClosedVarContainer (a, b, c, d, e, f)
+ Data.Text.Format.Heavy.Instances: instance (Data.Text.Format.Heavy.Types.Formatable a, Data.Text.Format.Heavy.Types.Formatable b, Data.Text.Format.Heavy.Types.Formatable c, Data.Text.Format.Heavy.Types.Formatable d, Data.Text.Format.Heavy.Types.Formatable e, Data.Text.Format.Heavy.Types.Formatable f, Data.Text.Format.Heavy.Types.Formatable g) => Data.Text.Format.Heavy.Types.ClosedVarContainer (a, b, c, d, e, f, g)
+ Data.Text.Format.Heavy.Instances: instance (Data.Text.Format.Heavy.Types.Formatable a, Data.Text.Format.Heavy.Types.Formatable b, Data.Text.Format.Heavy.Types.Formatable c, Data.Text.Format.Heavy.Types.Formatable d, Data.Text.Format.Heavy.Types.Formatable e, Data.Text.Format.Heavy.Types.Formatable f, Data.Text.Format.Heavy.Types.Formatable g, Data.Text.Format.Heavy.Types.Formatable h) => Data.Text.Format.Heavy.Types.ClosedVarContainer (a, b, c, d, e, f, g, h)
+ Data.Text.Format.Heavy.Instances: instance (Data.Text.Format.Heavy.Types.Formatable a, Data.Text.Format.Heavy.Types.Formatable b, Data.Text.Format.Heavy.Types.Formatable c, Data.Text.Format.Heavy.Types.Formatable d, Data.Text.Format.Heavy.Types.Formatable e, Data.Text.Format.Heavy.Types.Formatable f, Data.Text.Format.Heavy.Types.Formatable g, Data.Text.Format.Heavy.Types.Formatable h, Data.Text.Format.Heavy.Types.Formatable i) => Data.Text.Format.Heavy.Types.ClosedVarContainer (a, b, c, d, e, f, g, h, i)
+ Data.Text.Format.Heavy.Instances: instance (Data.Text.Format.Heavy.Types.Formatable a, Data.Text.Format.Heavy.Types.Formatable b, Data.Text.Format.Heavy.Types.Formatable c, Data.Text.Format.Heavy.Types.Formatable d, Data.Text.Format.Heavy.Types.Formatable e, Data.Text.Format.Heavy.Types.Formatable f, Data.Text.Format.Heavy.Types.Formatable g, Data.Text.Format.Heavy.Types.Formatable h, Data.Text.Format.Heavy.Types.Formatable i, Data.Text.Format.Heavy.Types.Formatable j) => Data.Text.Format.Heavy.Types.ClosedVarContainer (a, b, c, d, e, f, g, h, i, j)
+ Data.Text.Format.Heavy.Instances: instance Data.Text.Format.Heavy.Types.ClosedVarContainer ()
+ Data.Text.Format.Heavy.Instances: instance Data.Text.Format.Heavy.Types.Formatable a => Data.Text.Format.Heavy.Types.ClosedVarContainer (Data.Text.Format.Heavy.Instances.Several a)
+ Data.Text.Format.Heavy.Instances: instance Data.Text.Format.Heavy.Types.Formatable a => Data.Text.Format.Heavy.Types.ClosedVarContainer (Data.Text.Format.Heavy.Instances.Single a)
+ Data.Text.Format.Heavy.Instances: instance Data.Text.Format.Heavy.Types.Formatable a => Data.Text.Format.Heavy.Types.ClosedVarContainer (GHC.Base.Maybe a)
+ Data.Text.Format.Heavy.Instances: instance Data.Text.Format.Heavy.Types.Formatable x => Data.Text.Format.Heavy.Types.ClosedVarContainer (Data.Map.Internal.Map Data.Text.Internal.Lazy.Text x)
+ Data.Text.Format.Heavy.Instances: instance Data.Text.Format.Heavy.Types.Formatable x => Data.Text.Format.Heavy.Types.ClosedVarContainer [(Data.Text.Internal.Lazy.Text, x)]
+ Data.Text.Format.Heavy.Instances: instance Data.Text.Format.Heavy.Types.Formatable x => Data.Text.Format.Heavy.Types.VarContainer (Data.Map.Internal.Map Data.Text.Internal.Lazy.Text x)
+ Data.Text.Format.Heavy.Time: instance Data.Text.Format.Heavy.Types.Formatable Data.Time.Clock.Internal.UTCTime.UTCTime
+ Data.Text.Format.Heavy.Time: instance Data.Text.Format.Heavy.Types.Formatable Data.Time.LocalTime.Internal.LocalTime.LocalTime
+ Data.Text.Format.Heavy.Time: instance Data.Text.Format.Heavy.Types.Formatable Data.Time.LocalTime.Internal.TimeOfDay.TimeOfDay
+ Data.Text.Format.Heavy.Time: instance Data.Text.Format.Heavy.Types.Formatable Data.Time.LocalTime.Internal.TimeZone.TimeZone
+ Data.Text.Format.Heavy.Time: instance Data.Text.Format.Heavy.Types.Formatable Data.Time.LocalTime.Internal.ZonedTime.ZonedTime
+ Data.Text.Format.Heavy.Types: allVarNames :: ClosedVarContainer c => c -> [VarName]
+ Data.Text.Format.Heavy.Types: class VarContainer c => ClosedVarContainer c

Files

Data/Text/Format/Heavy/Instances.hs view
@@ -16,6 +16,7 @@ import Data.Word import Data.Int import Data.Maybe+import Data.List (union) import qualified Data.Map as M import qualified Data.Text as T import qualified Data.Text.Encoding as TE@@ -204,19 +205,32 @@   lookupVar "0" (Single x) = Just $ Variable x   lookupVar _ _ = Nothing +instance Formatable a => ClosedVarContainer (Single a) where+  allVarNames _ = ["0"]+ instance VarContainer () where   lookupVar _ _ = Nothing +instance ClosedVarContainer () where+  allVarNames _ = []+ -- | Maybe container contains one variable (named 0); Nothing contains an empty string. instance Formatable a => VarContainer (Maybe a) where   lookupVar "0" (Just x) = Just $ Variable x   lookupVar "0" Nothing = Just $ Variable ()   lookupVar _ _ = Nothing +instance Formatable a => ClosedVarContainer (Maybe a) where+  allVarNames Nothing = []+  allVarNames (Just _) = ["0"]+ instance (Formatable a, Formatable b) => VarContainer (a, b) where   lookupVar "0" (a,_) = Just $ Variable a   lookupVar "1" (_,b) = Just $ Variable b   lookupVar _ _ = Nothing++instance (Formatable a, Formatable b) => ClosedVarContainer (a, b) where+  allVarNames _ = ["0", "1"]    instance (Formatable a, Formatable b, Formatable c) => VarContainer (a, b, c) where   lookupVar "0" (a,_,_) = Just $ Variable a@@ -224,6 +238,9 @@   lookupVar "2" (_,_,c) = Just $ Variable c   lookupVar _ _ = Nothing   +instance (Formatable a, Formatable b, Formatable c) => ClosedVarContainer (a, b, c) where+  allVarNames _ = ["0", "1", "2"]+ instance (Formatable a, Formatable b, Formatable c, Formatable d) => VarContainer (a, b, c, d) where   lookupVar "0" (a,_,_,_) = Just $ Variable a   lookupVar "1" (_,b,_,_) = Just $ Variable b@@ -231,6 +248,9 @@   lookupVar "3" (_,_,_,d) = Just $ Variable d   lookupVar _ _ = Nothing +instance (Formatable a, Formatable b, Formatable c, Formatable d) => ClosedVarContainer (a, b, c, d) where+  allVarNames _ = ["0", "1", "2", "3"]+ instance (Formatable a, Formatable b, Formatable c, Formatable d, Formatable e)      => VarContainer (a, b, c, d, e) where   lookupVar "0" (a,_,_,_,_) = Just $ Variable a@@ -240,6 +260,10 @@   lookupVar "4" (_,_,_,_,e) = Just $ Variable e   lookupVar _ _ = Nothing +instance (Formatable a, Formatable b, Formatable c, Formatable d, Formatable e)+     => ClosedVarContainer (a, b, c, d, e) where+  allVarNames _ = ["0", "1", "2", "3", "4"]+ instance (Formatable a, Formatable b, Formatable c, Formatable d, Formatable e, Formatable f)      => VarContainer (a, b, c, d, e, f) where   lookupVar "0" (a,_,_,_,_,_) = Just $ Variable a@@ -250,6 +274,10 @@   lookupVar "5" (_,_,_,_,_,f) = Just $ Variable f   lookupVar _ _ = Nothing +instance (Formatable a, Formatable b, Formatable c, Formatable d, Formatable e, Formatable f)+     => ClosedVarContainer (a, b, c, d, e, f) where+  allVarNames _ = ["0", "1", "2", "3", "4", "5"]+ instance (Formatable a, Formatable b, Formatable c, Formatable d, Formatable e, Formatable f, Formatable g)      => VarContainer (a, b, c, d, e, f, g) where   lookupVar "0" (a,_,_,_,_,_,_) = Just $ Variable a@@ -261,6 +289,10 @@   lookupVar "6" (_,_,_,_,_,_,g) = Just $ Variable g   lookupVar _ _ = Nothing +instance (Formatable a, Formatable b, Formatable c, Formatable d, Formatable e, Formatable f, Formatable g)+     => ClosedVarContainer (a, b, c, d, e, f, g) where+  allVarNames _ = ["0", "1", "2", "3", "4", "5", "6"]+ instance (Formatable a, Formatable b, Formatable c, Formatable d, Formatable e, Formatable f, Formatable g,           Formatable h)      => VarContainer (a, b, c, d, e, f, g, h) where@@ -275,6 +307,11 @@   lookupVar _ _ = Nothing  instance (Formatable a, Formatable b, Formatable c, Formatable d, Formatable e, Formatable f, Formatable g,+          Formatable h)+     => ClosedVarContainer (a, b, c, d, e, f, g, h) where+  allVarNames _ = ["0", "1", "2", "3", "4", "5", "6", "7"]++instance (Formatable a, Formatable b, Formatable c, Formatable d, Formatable e, Formatable f, Formatable g,           Formatable h, Formatable i)      => VarContainer (a, b, c, d, e, f, g, h, i) where   lookupVar "0" (a,_,_,_,_,_,_,_,_) = Just $ Variable a@@ -289,6 +326,11 @@   lookupVar _ _ = Nothing  instance (Formatable a, Formatable b, Formatable c, Formatable d, Formatable e, Formatable f, Formatable g,+          Formatable h, Formatable i)+     => ClosedVarContainer (a, b, c, d, e, f, g, h, i) where+  allVarNames _ = ["0", "1", "2", "3", "4", "5", "6", "7", "8"]++instance (Formatable a, Formatable b, Formatable c, Formatable d, Formatable e, Formatable f, Formatable g,           Formatable h, Formatable i, Formatable j)      => VarContainer (a, b, c, d, e, f, g, h, i, j) where   lookupVar "0" (a,_,_,_,_,_,_,_,_,_) = Just $ Variable a@@ -303,6 +345,11 @@   lookupVar "9" (_,_,_,_,_,_,_,_,_,j) = Just $ Variable j   lookupVar _ _ = Nothing +instance (Formatable a, Formatable b, Formatable c, Formatable d, Formatable e, Formatable f, Formatable g,+          Formatable h, Formatable i, Formatable j)+     => ClosedVarContainer (a, b, c, d, e, f, g, h, i, j) where+  allVarNames _ = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]+ instance Formatable a => VarContainer (Several a) where   lookupVar name (Several lst) =     if not $ TL.all isDigit name@@ -312,12 +359,21 @@                then Nothing                else Just $ Variable (lst !! n)   +instance Formatable a => ClosedVarContainer (Several a) where+  allVarNames (Several lst) = map (TL.pack . show) [0 .. length lst - 1]+ instance Formatable x => VarContainer [(TL.Text, x)] where   lookupVar name pairs = Variable `fmap` lookup name pairs +instance Formatable x => ClosedVarContainer [(TL.Text, x)] where+  allVarNames pairs = map fst pairs+ instance Formatable x => VarContainer (M.Map TL.Text x) where   lookupVar name pairs = Variable `fmap` M.lookup name pairs +instance Formatable x => ClosedVarContainer (M.Map TL.Text x) where+  allVarNames pairs = M.keys pairs+ -- | Variable container which contains fixed value for any variable name. data DefaultValue = DefaultValue Variable @@ -336,6 +392,10 @@     case lookupVar name c1 of       Just result -> Just result       Nothing -> lookupVar name c2++instance (ClosedVarContainer c1, ClosedVarContainer c2) => ClosedVarContainer (ThenCheck c1 c2) where+  allVarNames (ThenCheck c1 c2) =+    allVarNames c1 `union` allVarNames c2  -- | Use variables from specified container, or use default value if -- variable is not found in container.
Data/Text/Format/Heavy/Types.hs view
@@ -78,5 +78,8 @@ class VarContainer c where   lookupVar :: VarName -> c -> Maybe Variable +class VarContainer c => ClosedVarContainer c where+  allVarNames :: c -> [VarName]+ ------------------------------------------------------------------------------ 
text-format-heavy.cabal view
@@ -1,5 +1,5 @@ name:                text-format-heavy-version:             0.1.5.0+version:             0.1.5.1 synopsis:            Full-weight string formatting library, analog of Python's string.format description:         This package contains full-featured string formatting function, similar to                      Python's string.format. Features include: