pliosoft / toml-parse

Haskell library for reading TOML and easily querying it
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Type-generic versions of lookupStr, together with lenses #2

Open clord opened 8 years ago

clord commented 8 years ago

A generic method to call in cases where the type is known to the compiler already, perhaps called simply query or perhaps even an operator. Also, it should have the Toml document as it's first argument for easy currying. (in fact, not sure why I put the Toml argument second everywhere... perhaps consistency with Data.Map?)

query :: Toml -> TomlPath -> Maybe a

And also one that has a default value provided:

queryDef :: Toml -> a -> TomlPath -> a

Then users can do something like:

let webserverASection = queryDef config Toml.empty "webservers.serverA"
let webserverSocket = queryDef webserverASection 8080 "port"