-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
661320a
commit 5bbd647
Showing
1 changed file
with
74 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,83 @@ | ||
# dhall-golang | ||
|
||
Go bindings for dhall. | ||
[![GoDoc](https://godoc.org/github.com/philandstuff/dhall-golang?status.svg)][dhall-golang godoc] | ||
|
||
Go bindings for the [dhall configuration language][dhall]. | ||
|
||
[dhall]: https://dhall-lang.org/ | ||
|
||
## Quick start | ||
|
||
Here's a minimal example of how you might use dhall-golang to load a | ||
Dhall file into your own struct: | ||
|
||
```golang | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
|
||
"github.com/philandstuff/dhall-golang" | ||
) | ||
|
||
// Config can be a fairly arbitrary Go datatype. You would put your | ||
// application configuration in this struct. | ||
type Config struct { | ||
Port int | ||
Name string | ||
} | ||
|
||
func main() { | ||
var config Config | ||
bytes, err := ioutil.ReadFile("/path/to/config.dhall") | ||
if err != nil { | ||
panic(err) | ||
} | ||
err = dhall.Unmarshal(bytes, &config) | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Printf("Loaded config: %#v\n", config) | ||
} | ||
``` | ||
|
||
## Documentation | ||
|
||
You can find more documentation in the [dhall-golang godoc][]. | ||
|
||
[dhall-golang godoc]: https://godoc.org/github.com/philandstuff/dhall-golang | ||
|
||
## Development | ||
|
||
This is a fairly standard Go project. It uses go modules, so no | ||
vendoring of dependencies is required. | ||
|
||
### Running the tests | ||
|
||
go test ./... | ||
|
||
## Progress | ||
|
||
- [X] Type, Kind, Sort | ||
- [X] Variables | ||
- [X] de bruijn indices | ||
- [x] quoted variables | ||
- [X] Lambdas, Pis, function application | ||
- [x] Alpha normalization | ||
- [X] Let bindings | ||
- [X] Type annotations | ||
- [X] Bools | ||
- [X] if | ||
- [x] `&&`, `||` | ||
- [x] `==`, `!=` | ||
- [X] Naturals | ||
- [X] `l + r` Natural addition | ||
- [x] `l * r` Natural multiplication | ||
- [x] Natural/* standard functions | ||
- [X] Integers | ||
- [x] Integer/toDouble and Integer/show | ||
- [X] Doubles | ||
- [x] Double/show (it exists but doesn't pass tests) | ||
- [X] Lists | ||
- [x] `l # r` list append | ||
- [x] List/* functions | ||
- [x] Text | ||
- [x] double quote literals | ||
- [x] single quote literals | ||
- [x] text interpolation | ||
- [x] `l ++ r` text append | ||
- [x] Text/show standard functions | ||
- [x] Optionals | ||
- [x] Optional/fold and Optional/build | ||
- [x] Records | ||
- [x] `f.a` | ||
- [x] `f.{ xs… }` | ||
- [x] `f.(s)` | ||
- [x] `l ∧ r` | ||
- [x] `l ⫽ r` | ||
- [x] `l ⩓ r` | ||
- [x] Unions | ||
- [x] types | ||
- [x] constructors | ||
- [x] `merge` | ||
- [ ] Imports | ||
- [x] local imports (except home-rooted paths) | ||
- [x] remote imports | ||
- [x] environment variable imports | ||
- [ ] `using ./headers` | ||
- [x] import caching | ||
- [x] importing expressions | ||
- [x] importing `as Text` | ||
- [x] `x ? y` alternate import operator | ||
- [x] `missing` | ||
- [X] unmarshalling into Go types | ||
- [ ] better errors | ||
- [ ] better godoc | ||
go test -short ./... # skips long-running tests | ||
|
||
### Making changes to the PEG grammar | ||
|
||
Dhall-golang uses [pigeon][] to generate the parser source file | ||
`parser/internal/dhall.go` from the PEG grammar at | ||
`parser/internal/dhall.peg`. If you change the PEG grammar, you need | ||
to first install the pigeon binary if you don't already have it: | ||
|
||
# either outside a module directory, or with GO111MODULE=off | ||
go get github.com/mna/pigeon | ||
|
||
Then, to regenerate the parser: | ||
|
||
go generate ./parser | ||
|
||
[pigeon]: https://godoc.org/github.com/mna/pigeon | ||
|
||
## Support | ||
|
||
Issues and pull requests are welcome on this repository. If you have | ||
a question, you can ask it on the [Dhall discourse][]. | ||
|
||
[Dhall discourse]: https://discourse.dhall-lang.org/ |