about summary refs log tree commit diff
path: root/users/Profpatsch/ini/ini.dhall
blob: f2efbc0af4f1b3faa454425a38967fb44ef2a68e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
let lib = ../dhall/lib.dhall

let NameVal = λ(T : Type) → { name : Text, value : T }

let ValueList = λ(T : Type) → List (NameVal T)

let Section = ValueList Text

let Sections = ValueList Section

let Ini = { globalSection : Section, sections : Sections }

let
    -- Takes to INI files and merges their global sections and their section lists,
    -- without duplicating by section name.
    appendInis =
      λ(inis : List Ini) →
          { globalSection =
              lib.List/concat
                (NameVal Text)
                (lib.List/map Ini Section (λ(i : Ini) → i.globalSection) inis)
          , sections =
              lib.List/concat
                (NameVal Section)
                (lib.List/map Ini Sections (λ(i : Ini) → i.sections) inis)
          }
        : Ini

let
    -- Signatures of functions that are input via FFI.
    Externs =
      { -- given a dsl of functions to create an Ini, render the ini file
        renderIni : Ini → Text
      }

in  { NameVal, ValueList, Section, Sections, Ini, appendInis, Externs }