Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dhall-lang/dhall-nethack
Generate NetHack configurations using Dhall
https://github.com/dhall-lang/dhall-nethack
Last synced: 17 days ago
JSON representation
Generate NetHack configurations using Dhall
- Host: GitHub
- URL: https://github.com/dhall-lang/dhall-nethack
- Owner: dhall-lang
- Created: 2018-11-24T22:41:25.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-07-22T10:16:06.000Z (over 3 years ago)
- Last Synced: 2024-04-13T20:54:17.990Z (7 months ago)
- Language: Dhall
- Size: 65.4 KB
- Stars: 35
- Watchers: 5
- Forks: 5
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-dhall - dhall-nethack - Generate NetHack configurations using Dhall. (Libraries)
README
# `dhall-nethack`
This repository illustrates best practices for the
[Dhall configuration language][dhall-lang] using the
[NetHack configuration format][nethack] as an example use case. You can use
this repository :* as a template for organizing your own large Dhall projects
* as a case study for adapting Dhall to large and complex configuration formatsNote: this repository covers the non-platform-specific NetHack options, omits
redundant options (such as `female`, which is superseded by `gender`), and
also omits underspecified options (such as `herecmd_menu`).## Quick start
```haskell
-- ./example.dhalllet types = ./types.dhall
let toNetHack = ./toNetHack.dhall
let config =
types.Config::{
, name = Some "Kaeru"
, role = Some { enable = True, value = types.Role.wizard }
, align = Some { enable = True, value = types.Alignment.chaotic }
, race = Some { enable = True, value = types.Race.elf }
, gender = Some types.Gender.female
, pettype = Some types.PetType.cat
, catname = Some "Imoen"
, fruit = Some "apple pie"
, autopickup = Some False
, disclose =
let secret = Some { default = False, prompt = False }in Some
{ attributes = secret
, conduct = secret
, dungeon_overview = secret
, inventory = secret
, monsters_genocided = secret
, monsters_killed = secret
}
}in toNetHack config
``````bash
$ dhall text --file './example.dhall'
OPTIONS=align:chaotic
OPTIONS=!autopickup
OPTIONS=catname:Imoen
OPTIONS=disclose:-i -a -v -g -c -o
OPTIONS=fruit:apple pie
OPTIONS=gender:female
OPTIONS=name:Kaeru
OPTIONS=pettype:cat
OPTIONS=race:elf
OPTIONS=role:wizard
```## Exploring the project
You can begin to explore the project by browsing these files and their
dependencies:* [`./types.dhall`](./types.dhall)
* [`./types/Config.dhall`](./types/Config.dhall)
* [`./render.dhall`](./render.dhall)
* [`./render/Config.dhall`](./render/Config.dhall)
* [`./Prelude.dhall`](./Prelude.dhall)
* [`./examples/validated.dhall`](./examples/validated.dhall)You can also use `dhall repl` to explore this project. Try these commands to
get started:```haskell
$ dhall repl
⊢ :let types = ./types.dhall -- Import all types as a giant record
⊢ types.Config -- Display the `Config` type
⊢ types.Scores -- Display the `Scores` type⊢ :let render = ./render.dhall -- Import all rendering functions
⊢ render.Config types.Config.default -- Render the default configuration
⊢ render.Config ./examples/small.dhall -- Render a small configuration
⊢ render.Config ./examples/validated.dhall -- Render a large configuration
⊢ render.Config (types.Config::{ scores = types.Scores::{ top = Some 3 } })
⊢ render.Scores (types.Scores::{ top = Some 3 })⊢ :type render.Scores -- What is the type of the `render.Scores` function?
⊢ render.Scores -- What is the implementation of `render.Scores`?
⊢ :type render.Config -- What is the type of the `render.Config` function?
⊢ render.Config -- What is the implementation of `render.Config`?
```[dhall-lang]: https://github.com/dhall-lang/dhall-lang/
[nethack]: https://nethackwiki.com/wiki/Options