packages feed

ValveValueKeyvalue 1.0.0.0 → 1.0.1.0

raw patch · 3 files changed

+16/−3 lines, 3 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

+ Text.ValveVKV: parseToVKV :: String -> Either ParseError [ValveKeyValueEntry]

Files

README.md view
@@ -9,4 +9,13 @@ ```
 The first parameter is the entry that should be turned into your type, and the 2nd one is the parent of that entry. The ^: operator receives an entry on the left side and a string on the right side. It tries to find the string subentry named the string inside the entry you gave in on the left. The .: operator is similar, but can return any type, not just string.
 
-The entry type ValveKeyValueEntry has 3 constructors. KVObject, which has a Pair of a KeyValueEntry list. KVInt, which has a Pair of Int and KVString, which has a pair of string. The Pair type itself is one constructor of a string and the type parameter.+The entry type ValveKeyValueEntry has 3 constructors. KVObject, which has a Pair of a KeyValueEntry list. KVInt, which has a Pair of Int and KVString, which has a pair of string. The Pair type itself is one constructor of a string and the type parameter.
+
+So you can now run
+```
+a :: IO My
+a = do
+    contents <- readFile "file.txt"
+    return $ parseValveVKV contents
+```
+This will open file "file.txt", read its contents and return the "My" type.
ValveValueKeyvalue.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4
 name:               ValveValueKeyvalue
-version:            1.0.0.0
+version:            1.0.1.0
 
 -- A short (one-line) description of the package.
 synopsis: A Valve Value-keyvalue parser for Haskell made with Parsec.
app/Text/ValveVKV.hs view
@@ -1,5 +1,5 @@ module Text.ValveVKV(vkvParser, parseValveVKV, fromValveVKV, (.:), (^:), unpair, ValveVKV,
-    ValveKeyValueEntry(KVObject, KVInt, KVString), Pair (Pair), Context) where
+    ValveKeyValueEntry(KVObject, KVInt, KVString), Pair (Pair), Context, parseToVKV) where
 -- Library for processing Valve's value keyvalue format. The main function you will wish to use is parseValveVKV. To convert it into your own type, you
 -- will need to write a 'ValveVKV' instance for it.
 
@@ -17,3 +17,7 @@         Right a ->
             let topObj = KVObject (Pair "top" a) in
             fromValveVKV topObj topObj
+
+-- | Parses it directly to a list of entries. Most of the times, 'parseValveVKV' will be better to directly turn it into a Haskell type of your choice
+parseToVKV :: String -> Either ParseError [ValveKeyValueEntry]
+parseToVKV = parse vkvParser ""