From 0170d75092b4750ad03d9c606918cf659703e8d5 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sun, 15 Sep 2019 00:43:48 +0200 Subject: completion: move to Completion module & factor out types --- .../dhallsh/Completion/Command/type.dhall | 10 ++ .../dhallsh/Completion/Option/type.dhall | 9 ++ .../profpatsch/dhallsh/Completion/completion.dhall | 114 ++++++++++++++++++ pkgs/profpatsch/dhallsh/completion.dhall | 134 --------------------- 4 files changed, 133 insertions(+), 134 deletions(-) create mode 100644 pkgs/profpatsch/dhallsh/Completion/Command/type.dhall create mode 100644 pkgs/profpatsch/dhallsh/Completion/Option/type.dhall create mode 100644 pkgs/profpatsch/dhallsh/Completion/completion.dhall delete mode 100644 pkgs/profpatsch/dhallsh/completion.dhall diff --git a/pkgs/profpatsch/dhallsh/Completion/Command/type.dhall b/pkgs/profpatsch/dhallsh/Completion/Command/type.dhall new file mode 100644 index 00000000..a0fd4e98 --- /dev/null +++ b/pkgs/profpatsch/dhallsh/Completion/Command/type.dhall @@ -0,0 +1,10 @@ + λ(a : Type) +→ { name : + Text + , description : + Text + , options : + List ../Option/type.dhall + , subcommands : + List a + } diff --git a/pkgs/profpatsch/dhallsh/Completion/Option/type.dhall b/pkgs/profpatsch/dhallsh/Completion/Option/type.dhall new file mode 100644 index 00000000..44f62d2e --- /dev/null +++ b/pkgs/profpatsch/dhallsh/Completion/Option/type.dhall @@ -0,0 +1,9 @@ +{ short : + Optional Text +, long : + Text +, description : + Text +, argument : + Optional Text +} diff --git a/pkgs/profpatsch/dhallsh/Completion/completion.dhall b/pkgs/profpatsch/dhallsh/Completion/completion.dhall new file mode 100644 index 00000000..e5b849a7 --- /dev/null +++ b/pkgs/profpatsch/dhallsh/Completion/completion.dhall @@ -0,0 +1,114 @@ +let Void = ../imports/Void.dhall + +let Option = ./Option/type.dhall + +let Command = ./Command/type.dhall + +let opt = + λ(long : Text) + → λ(description : Text) + → { long = + long + , description = + description + , argument = + None Text + , short = + None Text + } + +let fileOpt = + opt "file" "Read expression from a file instead of standard input" + ⫽ { argument = Some "FILE" } + +let alphaOpt = opt "alpha" "α-normalize expression" + +let inplaceOpt = + opt "inplace" "Modify the specified file in-place" + ⫽ { argument = Some "FILE" } + +let jsonOpt = opt "json" "Use JSON representation of CBOR" + +let leafCommand = + λ(name : Text) + → λ(description : Text) + → { options = + [] : List Option + , subcommands = + [] : List Void + , name = + name + , description = + description + } + +in { name = + "dhall" + , description = + "Interpreter for the Dhall language" + , options = + [ opt "annotate" "Add a type annotation to the output" + , alphaOpt + , opt "explain" "Explain error messages in more detail" + , opt "plain" "Disable syntax highlighting" + , opt "ascii" "Format code using only ASCII syntax" + , opt "standard-version" "The standard version to use" + ⫽ { argument = Some "X.Y.Z" } + ] + , subcommands = + [ leafCommand + "version" + "Display version" + , leafCommand "resolve" "Resolve an expression's imports" + ⫽ { options = + [ fileOpt + , opt "dot" "Output import dependency graph in dot format" + , opt + "immediate-dependencies" + "List immediate import dependencies" + , opt + "transitive-dependencies" + "List transitive import dependencies" + ] + } + , leafCommand "type" "Infer an expression's type" + ⫽ { options = [ fileOpt ] } + , leafCommand "normalize" "Normalize an expression" + ⫽ { options = [ fileOpt, alphaOpt ] } + , leafCommand "repl" "Interpret expressions in a REPL" + , leafCommand + "diff" + "Render the difference between the normal form of two expressions" + , leafCommand "hash" "Compute semantic hashes for Dhall expressions" + , leafCommand "lint" "Improve Dhall code" + ⫽ { options = [ inplaceOpt ] } + , leafCommand "format" "Formatter for the Dhall language" + ⫽ { options = + [ opt "check" "Only check if the input is formatted" + , inplaceOpt + ] + } + , leafCommand + "freeze" + "Add integrity checks to remote import statements of an expression" + ⫽ { options = + [ inplaceOpt + , opt + "all" + "Add integrity checks to all imports (not just remote imports)" + , opt + "cache" + "Add fallback unprotected imports when using integrity checks purely for caching purposes" + ] + } + , leafCommand "encode" "Encode a Dhall expression to binary" + ⫽ { options = [ fileOpt, jsonOpt ] } + , leafCommand "decode" "Decode a Dhall expression from binary" + ⫽ { options = [ fileOpt, jsonOpt ] } + , leafCommand + "text" + "Render a Dhall expression that evaluates to a Text literal" + ⫽ { options = [ fileOpt ] } + ] + } + : Command (Command Void) diff --git a/pkgs/profpatsch/dhallsh/completion.dhall b/pkgs/profpatsch/dhallsh/completion.dhall deleted file mode 100644 index 9df63144..00000000 --- a/pkgs/profpatsch/dhallsh/completion.dhall +++ /dev/null @@ -1,134 +0,0 @@ -let Void = - https://raw.githubusercontent.com/sellout/dada/master/Void/Type sha256:a413d5091ac5fb02410f02bdbede12eacd89ae52a933a6d24bb68eadbff92613 - -let Option = - { short : - Optional Text - , long : - Text - , description : - Text - , argument : - Optional Text - } - -let Command = - λ(a : Type) - → { name : - Text - , description : - Text - , options : - List Option - , subcommands : - List a - } - -let opt = - λ(long : Text) - → λ(description : Text) - → { long = - long - , description = - description - , argument = - None Text - , short = - None Text - } - -let fileOpt = - opt "file" "Read expression from a file instead of standard input" - ⫽ { argument = Some "FILE" } - -let alphaOpt = opt "alpha" "α-normalize expression" - -let inplaceOpt = - opt "inplace" "Modify the specified file in-place" - ⫽ { argument = Some "FILE" } - -let jsonOpt = opt "json" "Use JSON representation of CBOR" - -let leafCommand = - λ(name : Text) - → λ(description : Text) - → { options = - [] : List Option - , subcommands = - [] : List Void - , name = - name - , description = - description - } - -in { name = - "dhall" - , description = - "Interpreter for the Dhall language" - , options = - [ opt "annotate" "Add a type annotation to the output" - , alphaOpt - , opt "explain" "Explain error messages in more detail" - , opt "plain" "Disable syntax highlighting" - , opt "ascii" "Format code using only ASCII syntax" - , opt "standard-version" "The standard version to use" - ⫽ { argument = Some "X.Y.Z" } - ] - , subcommands = - [ leafCommand - "version" - "Display version" - , leafCommand "resolve" "Resolve an expression's imports" - ⫽ { options = - [ fileOpt - , opt "dot" "Output import dependency graph in dot format" - , opt - "immediate-dependencies" - "List immediate import dependencies" - , opt - "transitive-dependencies" - "List transitive import dependencies" - ] - } - , leafCommand "type" "Infer an expression's type" - ⫽ { options = [ fileOpt ] } - , leafCommand "normalize" "Normalize an expression" - ⫽ { options = [ fileOpt, alphaOpt ] } - , leafCommand "repl" "Interpret expressions in a REPL" - , leafCommand - "diff" - "Render the difference between the normal form of two expressions" - , leafCommand "hash" "Compute semantic hashes for Dhall expressions" - , leafCommand "lint" "Improve Dhall code" - ⫽ { options = [ inplaceOpt ] } - , leafCommand "format" "Formatter for the Dhall language" - ⫽ { options = - [ opt "check" "Only check if the input is formatted" - , inplaceOpt - ] - } - , leafCommand - "freeze" - "Add integrity checks to remote import statements of an expression" - ⫽ { options = - [ inplaceOpt - , opt - "all" - "Add integrity checks to all imports (not just remote imports)" - , opt - "cache" - "Add fallback unprotected imports when using integrity checks purely for caching purposes" - ] - } - , leafCommand "encode" "Encode a Dhall expression to binary" - ⫽ { options = [ fileOpt, jsonOpt ] } - , leafCommand "decode" "Decode a Dhall expression from binary" - ⫽ { options = [ fileOpt, jsonOpt ] } - , leafCommand - "text" - "Render a Dhall expression that evaluates to a Text literal" - ⫽ { options = [ fileOpt ] } - ] - } - : Command (Command Void) -- cgit 1.4.1