Coder Social home page Coder Social logo

dhall-nethack's Introduction

dhall-nethack

This repository illustrates best practices for the Dhall configuration language using the NetHack configuration format 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 formats

Note: 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

-- ./example.dhall

let 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
$ 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:

You can also use dhall repl to explore this project. Try these commands to get started:

$ 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-nethack's People

Contributors

gabriella439 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dhall-nethack's Issues

LICENSE missing

Hi!

As per current international law, unless a project has a license of some sort, there is no right to copy and/or modify for anyone except the copyright holder (typically the author) and those whom the copyright holder has given a license to.

Please add a free software license so that we could learn and build upon this example.

Thank you in advance.

Example on the main README doesn't work

I'm new to Dhall and just found this repo, which looks like a great way to learn Dhall. Thanks!

It looks like the example from the quickstart doesn't work (anymore). The error I get:

dhall:
Error: Failed to resolve imports. Error list:


↳ ./toNetHack.dhall
  ↳ ./render/Config.dhall
    ↳ ./Prelude.dhall
      ↳ env:DHALL_PRELUDE

Error: Missing environment variable

↳ DHALL_PRELUDE


↳ ./toNetHack.dhall
  ↳ ./render/Config.dhall
    ↳ ./Prelude.dhall
      ↳ https://raw.githubusercontent.com/dhall-lang/dhall-lang/v8.0.0/Prelude/package.dhall sha256:0c04cbe34f1f2d408e8c8b8cb0aa3ff4d5656336910f7e86190a6d14326f966d
        ↳ https://raw.githubusercontent.com/dhall-lang/dhall-lang/v8.0.0/Prelude/Optional/package.dhall sha256:36a366af67a3c26cd5d196e095d3023f18953c5b5db3a03956fa554609e5442a
          ↳ https://raw.githubusercontent.com/dhall-lang/dhall-lang/v8.0.0/Prelude/Optional/all sha256:b9b015fe8be14da940901aa1510ee1d5e205df37ee651c32ac975a799782c410

Error: Unbound variable: Optional/fold

18│         Optional/fold

and then a whole lot of other unbound Optional/fold.

I updated the Prelude version in ./Prelude.dhall, but then I still got an error:

dhall text --file './example.dhall'
dhall:
↳ ./toNetHack.dhall
  ↳ ./render/Config.dhall
    ↳ ./render/Disclose.dhall

Error: Unbound variable: Optional/fold

10│         Optional/fold

/Users/niels.uitdebos/git/playground/dhall/dhall-nethack/render/Disclose.dhall:10:9

88│                                               ./Disclose.dhall

/Users/niels.uitdebos/git/playground/dhall/dhall-nethack/render/Config.dhall:88:47

but those were all the errors I got.

The file examples/small.dhall does seem to work, but it doesn't use toNetHack.

I'm on Mac and dhall version returns 1.34.0 (latest, it looks like).

How would versioning work?

I think I understood the structure of these examples, but one thing that comes up often in practice: versioned configuration.

That is, the program in question changes the types of some fields, removes some fields, adds some fields …

How would I write a dhall config that can handle this? Where the user should (if possible) be able to import a dhall file that corresponds to the version of the program one wants to generate the config for, and dhall will typecheck for that version number.

Of course on the dhall side there should be as little duplication as possible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.