Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriella439 committed Jan 31, 2020
1 parent 16604e1 commit 2b7ea59
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 91 deletions.
48 changes: 21 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,28 @@ 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
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
```
Expand Down
2 changes: 1 addition & 1 deletion examples/small.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ in types.Config::{
, autopickup = Some False
, disclose =
let secret = Some { default = False, prompt = False }

in Some
{ attributes = secret
, conduct = secret
Expand Down
2 changes: 1 addition & 1 deletion examples/unvalidated.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
./validated.dhall
{ rlecomp = Some False
, SOUND =
[ { regex = "This door is locked", filename = "lock.wav", volume = 100 } ]
[ { regex = "This door is locked", filename = "lock.wav", volume = 100 } ]
, SOUNDDIR = Some "C:\\foo"
, zerocomp = Some False
}
63 changes: 29 additions & 34 deletions examples/validated.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,35 @@ let types = ../types.dhall

in types.Config::{
, AUTOCOMPLETE =
[ { enable = True, value = "zap" }
, { enable = False, value = "annotate" }
]
[ { enable = True, value = "zap" }
, { enable = False, value = "annotate" }
]
, acoustics = Some True
, align = Some { enable = True, value = types.Alignment.chaotic }
, autodescribe = Some False
, autodig = Some False
, AUTOPICKUP_EXCEPTION =
[ { pickup = False, name = "chest" }
, { pickup = True, name = "dagger" }
]
[ { pickup = False, name = "chest" }, { pickup = True, name = "dagger" } ]
, BIND =
[ { keybinding = "!", command = "loot" }
, { keybinding = "^v", command = "untrap" }
, { keybinding = "M-x", command = "terrain" }
]
[ { keybinding = "!", command = "loot" }
, { keybinding = "^v", command = "untrap" }
, { keybinding = "M-x", command = "terrain" }
]
, catname = Some "Mirri"
, checkpoint = Some True
, checkspace = Some True
, clicklook = Some False
, cmdassist = Some True
, confirm = Some True
, dark_room = Some False
, disclose =
Some
types.Disclose::{
, inventory = Some { prompt = True, default = True }
, attributes = Some { prompt = True, default = False }
, monsters_killed = Some { prompt = False, default = True }
, monsters_genocided = Some { prompt = False, default = False }
, conduct = Some { prompt = False, default = False }
, dungeon_overview = Some { prompt = False, default = False }
}
, disclose = Some types.Disclose::{
, inventory = Some { prompt = True, default = True }
, attributes = Some { prompt = True, default = False }
, monsters_killed = Some { prompt = False, default = True }
, monsters_genocided = Some { prompt = False, default = False }
, conduct = Some { prompt = False, default = False }
, dungeon_overview = Some { prompt = False, default = False }
}
, dogname = Some "Cujo"
, extmenu = Some False
, fixinv = Some True
Expand All @@ -50,15 +46,14 @@ in types.Config::{
, help = Some True
, hilite_pet = Some False
, hilite_pile = Some False
, hilite_status =
types.HiliteStatus::{
, gold =
[ { color = types.Color.yellow
, trigger = Some types.Numeric.always
, attributes = None types.Attributes.Type
}
]
}
, hilite_status = types.HiliteStatus::{
, gold =
[ { color = types.Color.yellow
, trigger = Some types.Numeric.always
, attributes = None types.Attributes.Type
}
]
}
, hitpointbar = Some True
, horsename = Some "Erhir"
, ignintr = Some False
Expand All @@ -69,11 +64,11 @@ in types.Config::{
, mail = Some True
, mention_walls = Some False
, menucolors =
[ { regex = "blessed"
, color = Some types.Color.cyan
, attributes = types.Attributes::{ bold = Some True }
}
]
[ { regex = "blessed"
, color = Some types.Color.cyan
, attributes = types.Attributes::{ bold = Some True }
}
]
, menustyle = Some types.MenuStyle.traditional
, menu_deselect_all = Some "-"
, menu_deselect_page = Some "\\"
Expand Down
2 changes: 1 addition & 1 deletion render/AUTOPICKUP_EXCEPTION.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ let types = ../types.dhall

in λ(x : types.AUTOPICKUP_EXCEPTION)
let prefix = if x.pickup then "<" else ">"

in "AUTOPICKUP_EXCEPTION=\"${prefix}${x.name}\""
12 changes: 9 additions & 3 deletions render/Config.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ let renderOptionalNatural = renderNamedOptional Natural Natural/show
let renderList =
λ(a : Type)
λ(f : a Text)
Prelude.Text.concatMap a (λ(x : a) "${f x}\n")
Prelude.Text.concatMap
a
( λ(x : a)
''
${f x}
''
)

let renderOptionalEnabled =
λ(a : Type)
Expand Down Expand Up @@ -84,9 +90,9 @@ let renderDisclose =
let renderMenuColors =
λ(x : List types.MenuColor)
if Prelude.List.null types.MenuColor x

then ""

else ''
OPTIONS=menucolors
${renderList types.MenuColor ./MenuColor.dhall x}''
Expand Down
8 changes: 4 additions & 4 deletions render/Disclosure.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ let types = ../types.dhall

in λ(x : types.Disclosure)
if x.prompt

then if x.default then "y" else "n"

else if x.default

then "+"

else "-"
6 changes: 3 additions & 3 deletions render/Hilite.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ in λ(a : Type)
Text
(λ(trigger : a) "/${renderTrigger trigger}")
""

let attributes =
Optional/fold
types.Attributes.Type
hilite.attributes
Text
(λ(a : types.Attributes.Type) "&${./Attributes.dhall a}")
""

let color = "/${./Color.dhall hilite.color}"

in "${trigger}${color}${attributes}"
10 changes: 5 additions & 5 deletions render/HiliteStatus.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ in λ(x : types.HiliteStatus.Type)
renderTrigger
h}"
)

let renderTextualHilites = renderHilites types.Textual ./Textual.dhall

let renderNumericHilites = renderHilites types.Numeric ./Numeric.dhall

let renderPercentHilites = renderHilites types.Percent ./Percent.dhall

let renderConditionHilites =
renderHilites types.Condition ./Condition.dhall

in renderTextualHilites "title" x.title
++ renderNumericHilites "strength" x.strength
++ renderNumericHilites "dexterity" x.dexterity
Expand Down
4 changes: 2 additions & 2 deletions render/MenuColor.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ let types = ../types.dhall

in λ(x : types.MenuColor)
let attributes = ./Attributes.dhall x.attributes

let suffix =
Optional/fold
types.Color
x.color
Text
(λ(c : types.Color) "${./Color.dhall c}&${attributes}")
attributes

in "MENUCOLOR=\"${x.regex}\"=${suffix}"
2 changes: 1 addition & 1 deletion render/MsgType.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ in λ(x : types.MsgType)
, show = λ(t : Text) "show \"${t}\""
}
x

in "MSGTYPE=${value}"
6 changes: 3 additions & 3 deletions render/ParanoidConfirmation.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ in λ(x : types.ParanoidConfirmation.Type)
# renderConfirmation "Were-change" x.Were-change
# renderConfirmation "Remove" x.Remove
# renderConfirmation "all" x.all

in if Prelude.List.null Text confirmations

then ""

else ''
OPTIONS=paranoid_confirmation:${Prelude.Text.concatSep
" "
Expand Down
12 changes: 6 additions & 6 deletions render/Scores.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ in λ(x : types.Scores.Type)
(List Text)
(λ(b : Bool) [ "${./Bool.dhall b}o" ])
([] : List Text)

let around =
Optional/fold
Natural
x.around
(List Text)
(λ(n : Natural) [ "${Natural/show n}a" ])
([] : List Text)

let top =
Optional/fold
Natural
x.top
(List Text)
(λ(n : Natural) [ "${Natural/show n}t" ])
([] : List Text)

let scores = own # around # top

in if Prelude.List.null Text scores

then ""

else ''
OPTIONS=scores:${Prelude.Text.concatSep " " scores}
''

0 comments on commit 2b7ea59

Please sign in to comment.